Skip to content

Commit

Permalink
Ensure reproducible output from generate task (#119)
Browse files Browse the repository at this point in the history
The descriptors file generated by 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, to ensure generated descriptors have a canonical representation to avoid triggering unnecessary rebuilds downstream.
  • Loading branch information
lptr authored and zhangkun83 committed Mar 22, 2017
1 parent e41c241 commit 8444e98
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ public class GenerateProtoTask extends DefaultTask {
Preconditions.checkState(state == State.FINALIZED, 'doneConfig() has not been called')

ToolsLocator tools = project.protobuf.tools
Set<File> protoFiles = inputs.sourceFiles.files
// Sort to ensure generated descriptors have a canonical representation
// to avoid triggering unnecessary rebuilds downstream
List<File> protoFiles = inputs.sourceFiles.files.sort()

[builtins, plugins]*.each { plugin ->
File outputDir = new File(getOutputDir(plugin))
Expand Down

0 comments on commit 8444e98

Please sign in to comment.