Create reproducible artifacts #6322
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Configures Maven to create bit-by-bit reproducible artifacts.
As with Gradle and Bnd, timestamps in jars are normalized to 1980 February 1st CET. This is not without controversy, as shown by this example issue: FasterXML/jackson-databind#3680
An alternative albeit slightly more complex approach is to update
project.build.outputTimestamp
at release time, as shown in this FAQ: https://maven.apache.org/guides/mini/guide-reproducible-builds.html#faqFinally, for reference purposes I've used the excellent
diffoscope
tool to create a visual diff ofguava-31.1-jre
release vs. the same code built with this change. Openindex.html
in this archive: guava-diff.zipSteps to reproduce the above:
$ git checkout v31.1
$ git cherry-pick ###
# the commit of this PR$ mvn clean install -U -DskipTests=true
$ curl https://repo1.maven.org/maven2/com/google/guava/guava/31.1-jre/guava-31.1-jre.jar --output ~/Downloads/guava-31.1-jre.jar # sha1sum should be 60458f877d055d0c9114d9e1a2efb737b4bc282c
$ diffoscope --exclude \*.class --html-dir guava-diff ~/Downloads/guava-31.1-jre.jar guava/target/guava-31.1-jre.jar
The important things to notice in the diff:
zipinfo
output shows normalized timestamps in the zip catalog on RHSMETA-INF/MANIFEST.MF
: ProblematicBnd-LastModified
andBuilt-By
attributes are gone. DifferentTool
version is used bymaven-bundle-plugin
.META-INF/**/pom.properties
: Problematic comment with timestamp is goneNote that in step 5 I excluded class files from analysis; that's because
diffoscope
delegates to a decompiler which seemed confused about inlined Strings and lambdas, creating false-positives. I suspect this is a difference between my local JDK and/or vendor vs. the released artifact.NB: There appear to be other past changes related to reproducible builds: #3534, #3681 and #3686