From 29d001eced142698ef5ae877d96e7215c68b3077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=CC=81ra=CC=81nt=20Pinte=CC=81r?= Date: Thu, 9 Mar 2017 15:31:31 +0100 Subject: [PATCH 1/2] Ensure reproducible output from generate task The output of protoc depends on the order of the source files passed to it. This change makes sure that the input files passed to it are always in a consistent order. --- .../groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy b/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy index 45951dd0..4b1d27bb 100644 --- a/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy +++ b/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy @@ -361,7 +361,8 @@ public class GenerateProtoTask extends DefaultTask { Preconditions.checkState(state == State.FINALIZED, 'doneConfig() has not been called') ToolsLocator tools = project.protobuf.tools - Set protoFiles = inputs.sourceFiles.files + // Sort to make sure files are in a consistent order + List protoFiles = inputs.sourceFiles.files.sort() [builtins, plugins]*.each { plugin -> File outputDir = new File(getOutputDir(plugin)) From ee1120f82a3c22d99691f3b6e2a8afd9d5b83bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=CC=81ra=CC=81nt=20Pinte=CC=81r?= Date: Wed, 22 Mar 2017 11:18:20 +0100 Subject: [PATCH 2/2] More descriptive comment --- .../groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy b/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy index 4b1d27bb..bd2bc49b 100644 --- a/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy +++ b/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy @@ -361,7 +361,8 @@ public class GenerateProtoTask extends DefaultTask { Preconditions.checkState(state == State.FINALIZED, 'doneConfig() has not been called') ToolsLocator tools = project.protobuf.tools - // Sort to make sure files are in a consistent order + // Sort to ensure generated descriptors have a canonical representation + // to avoid triggering unnecessary rebuilds downstream List protoFiles = inputs.sourceFiles.files.sort() [builtins, plugins]*.each { plugin ->