-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure reproducible output from generate task #119
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<File> protoFiles = inputs.sourceFiles.files | ||
// Sort to make sure files are in a consistent order | ||
List<File> protoFiles = inputs.sourceFiles.files.sort() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still trying to understand what the problem is. This will only affect the order of the proto files passed to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The protoc tool itself generates different output when the files are in different order. It's not functionally different, but you get different bytes as output, which then destroy the up-to-date checks downstream. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still don't understand how the order the files are written would impact up-to-date checks. Can you elaborate? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What output changes? If the output does change then it sounds like the order in significant and shouldn't be sorted. If it is minor, then maybe we should fix protoc? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the descriptor files that can change. In the example I know of, the descriptors were being packaged into a jar which (sometimes) made the jar different. Here's a self contained example:
This should produce something like: The two "first" files will be the same and the two "second" files will be the same. I ran it twice to show that it's not something like the timestamp that makes the files different. Looking at the generated descriptors, it seems like the only difference is the order that protoc saw the input files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense; it is the generated descriptors with |
||
|
||
[builtins, plugins]*.each { plugin -> | ||
File outputDir = new File(getOutputDir(plugin)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment says what you are doing and the obvious implication, but not why. Maybe:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I've changed it.