Skip to content
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

Support AbstractArchiveTask.preserveFileTimestamps for reproducible builds #391

Merged
merged 2 commits into from
Sep 12, 2018
Merged

Conversation

Macil
Copy link
Contributor

@Macil Macil commented Jul 27, 2018

With this PR, the officially recommended Gradle config for reproducible builds now successfully creates reproducible builds when used with shadowJar:

tasks.withType(AbstractArchiveTask) {
    preserveFileTimestamps = false
    reproducibleFileOrder = true
}

Gradle 3.4 added support for reproducible builds of archives, but shadowJar doesn't respect the preserveFileTimestamps setting despite extending AbstractArchiveTask which exposes that. This PR makes the shadowJar task handle the preserveFileTimestamps setting. (I believe the reproducibleFileOrder setting is handled by Gradle in a way that already works for shadowJar.)

Solves #229 and #389.

The implementation and choice of the default constant timestamp are inspired by Gradle's own ZipCopyAction class.

This does make the plugin incompatible with versions of Gradle before 3.4. I think I could change the PR to use reflection to read the preserveFileTimestamps value if backwards compatibility with those versions was considered important.

I know that the inspiration for #333 was to allow a user to configure build.gradle to zero out timestamps, but I don't think this PR is redundant with it: this PR adds support to shadowJar for the standard Gradle configuration for reproducible builds without adding any new shadow APIs.

@johnrengelman
Copy link
Collaborator

Thanks for the PR!
This looks good and I just need to figure out the release plan for the next version before merging.

@johnrengelman johnrengelman added this to the 2.1.0 milestone Sep 12, 2018
@johnrengelman johnrengelman merged commit caaa335 into GradleUp:master Sep 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants