diabonas commented on pull request #578:
URL: https://github.com/apache/commons-lang/pull/578#issuecomment-656022221
@garydgregory AFAIKT maven-bundle-plugin has no special configuration in
version 3.10 at all, so additional manifest headers are included, making it
impossible to reproduce a previously built JAR. You can see the difference
between two builds of version 3.10 in the following diff, both built with `mvn
-Dproject.build.outputTimestamp=1594285478 clean package` to remove other
sources of unreproducibility like differing file timestamps:
```
--- commons-lang3-3.10_build1.jar
+++ commons-lang3-3.10_build2.jar
├── zipinfo -v {}
│ @@ -27,15 +27,15 @@
│ minimum file system compatibility required: MS-DOS, OS/2 or NT FAT
│ minimum software version required to extract: 2.0
│ compression method: deflated
│ compression sub-type (deflation): normal
│ file security status: not encrypted
│ extended local header: no
│ file last modified on (DOS date/time): 2020 Jul 9 09:04:38
│ - 32-bit CRC value (hex): 6b84a6c5
│ + 32-bit CRC value (hex): 9bb8ba7e
│ compressed size: 694 bytes
│ uncompressed size: 1869 bytes
│ length of filename: 20 characters
│ length of extra field: 0 bytes
│ length of file comment: 0 characters
│ disk number on which file begins: disk 1
│ apparent file type: binary
├── META-INF/MANIFEST.MF
│ @@ -4,15 +4,15 @@
│ Specification-Title: Apache Commons Lang
│ Specification-Version: 3.10
│ Specification-Vendor: The Apache Software Foundation
│ Implementation-Title: Apache Commons Lang
│ Implementation-Version: 3.10
│ Implementation-Vendor: The Apache Software Foundation
│ Automatic-Module-Name: org.apache.commons.lang3
│ -Bnd-LastModified: 1594285565704
│ +Bnd-LastModified: 1594285992219
│ Build-Jdk: 14.0.1
│ Built-By: builduser
│ Bundle-Description: Apache Commons Lang, a package of Java utility class
│ es for the classes that are in java.lang's hierarchy, or are considere
│ d to be so standard as to justify existence in java.lang.
│ Bundle-DocURL: https://commons.apache.org/proper/commons-lang/
│ Bundle-License: https://www.apache.org/licenses/LICENSE-2.0.txt
│ @@ -27,12 +27,12 @@
│ s.lang3.concurrent;version="3.10",org.apache.commons.lang3.event;versio
│ n="3.10",org.apache.commons.lang3.exception;version="3.10",org.apache.c
│ ommons.lang3.math;version="3.10",org.apache.commons.lang3.mutable;versi
│ on="3.10",org.apache.commons.lang3.reflect;version="3.10",org.apache.co
│ mmons.lang3.text;version="3.10",org.apache.commons.lang3.text.translate
│ ;version="3.10",org.apache.commons.lang3.time;version="3.10",org.apache
│ .commons.lang3.tuple;version="3.10"
│ -Include-Resource: META-INF/LICENSE.txt=LICENSE.txt,META-INF/NOTICE.txt=N
│ - OTICE.txt
│ +Include-Resource: META-INF/NOTICE.txt=NOTICE.txt,META-INF/LICENSE.txt=LI
│ + CENSE.txt
│ Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
│ Tool: Bnd-4.2.0.201903051501
```
As you can see, `Bnd-LastModified` does not respect
[`project.build.outputTimestamp`](https://maven.apache.org/guides/mini/guide-reproducible-builds.html)
(or the [`SOURCE_DATE_EPOCH`
specification](https://reproducible-builds.org/docs/source-date-epoch/)),
making it impossible to get the same JAR each time. Furthermore,
`Include-Resource` seems to depend on the file system order (the first build
was on a Btrfs file system, the second on a tmpfs file system).
After
[backporting](https://git.archlinux.org/svntogit/community.git/tree/trunk/java-commons-lang-3.10_improve-reproducibility-of-generated-JARs.patch?h=packages/java-commons-lang)
the patch proposed in this PR to version 3.10, the JAR is fully reproducible
between rebuilds since the offending manifest headers are removed. The
comparison with the unpatched, unreproducible JAR is as follows:
```
--- commons-lang3-3.10_build1.jar
+++ commons-lang3-3.10_build3-patched.jar
├── zipinfo {}
│ @@ -1,9 +1,9 @@
│ -Zip file size: 526952 bytes, number of entries: 314
│ --rw-r--r-- 2.0 unx 1869 b- defN 20-Jul-09 09:04 META-INF/MANIFEST.MF
│ +Zip file size: 526929 bytes, number of entries: 314
│ +-rw-r--r-- 2.0 unx 1720 b- defN 20-Jul-09 09:04 META-INF/MANIFEST.MF
│ drwxr-xr-x 2.0 unx 0 b- stor 20-Jul-09 09:04 META-INF/
│ drwxr-xr-x 2.0 unx 0 b- stor 20-Jul-09 09:04 org/
│ drwxr-xr-x 2.0 unx 0 b- stor 20-Jul-09 09:04 org/apache/
│ drwxr-xr-x 2.0 unx 0 b- stor 20-Jul-09 09:04 org/apache/commons/
│ drwxr-xr-x 2.0 unx 0 b- stor 20-Jul-09 09:04
org/apache/commons/lang3/
│ drwxr-xr-x 2.0 unx 0 b- stor 20-Jul-09 09:04
org/apache/commons/lang3/arch/
│ drwxr-xr-x 2.0 unx 0 b- stor 20-Jul-09 09:04
org/apache/commons/lang3/builder/
│ @@ -307,10 +307,10 @@
│ -rw-r--r-- 2.0 unx 2443 b- defN 20-Jul-09 09:04
org/apache/commons/lang3/tuple/ImmutableTriple.class
│ -rw-r--r-- 2.0 unx 3065 b- defN 20-Jul-09 09:04
org/apache/commons/lang3/tuple/MutablePair.class
│ -rw-r--r-- 2.0 unx 2636 b- defN 20-Jul-09 09:04
org/apache/commons/lang3/tuple/MutableTriple.class
│ -rw-r--r-- 2.0 unx 1266 b- defN 20-Jul-09 09:04
org/apache/commons/lang3/tuple/Pair$PairAdapter.class
│ -rw-r--r-- 2.0 unx 4228 b- defN 20-Jul-09 09:04
org/apache/commons/lang3/tuple/Pair.class
│ -rw-r--r-- 2.0 unx 1216 b- defN 20-Jul-09 09:04
org/apache/commons/lang3/tuple/Triple$TripleAdapter.class
│ -rw-r--r-- 2.0 unx 3764 b- defN 20-Jul-09 09:04
org/apache/commons/lang3/tuple/Triple.class
│ --rw-r--r-- 2.0 unx 30549 b- defN 20-Jul-09 09:04
META-INF/maven/org.apache.commons/commons-lang3/pom.xml
│ +-rw-r--r-- 2.0 unx 30901 b- defN 20-Jul-09 09:04
META-INF/maven/org.apache.commons/commons-lang3/pom.xml
│ -rw-r--r-- 2.0 unx 65 b- defN 20-Jul-09 09:04
META-INF/maven/org.apache.commons/commons-lang3/pom.properties
│ -314 files, 1150972 bytes uncompressed, 468924 bytes compressed: 59.3%
│ +314 files, 1151175 bytes uncompressed, 468901 bytes compressed: 59.3%
├── META-INF/MANIFEST.MF
│ @@ -4,15 +4,14 @@
│ Specification-Title: Apache Commons Lang
│ Specification-Version: 3.10
│ Specification-Vendor: The Apache Software Foundation
│ Implementation-Title: Apache Commons Lang
│ Implementation-Version: 3.10
│ Implementation-Vendor: The Apache Software Foundation
│ Automatic-Module-Name: org.apache.commons.lang3
│ -Bnd-LastModified: 1594285565704
│ Build-Jdk: 14.0.1
│ Built-By: builduser
│ Bundle-Description: Apache Commons Lang, a package of Java utility class
│ es for the classes that are in java.lang's hierarchy, or are considere
│ d to be so standard as to justify existence in java.lang.
│ Bundle-DocURL: https://commons.apache.org/proper/commons-lang/
│ Bundle-License: https://www.apache.org/licenses/LICENSE-2.0.txt
│ @@ -27,12 +26,9 @@
│ s.lang3.concurrent;version="3.10",org.apache.commons.lang3.event;versio
│ n="3.10",org.apache.commons.lang3.exception;version="3.10",org.apache.c
│ ommons.lang3.math;version="3.10",org.apache.commons.lang3.mutable;versi
│ on="3.10",org.apache.commons.lang3.reflect;version="3.10",org.apache.co
│ mmons.lang3.text;version="3.10",org.apache.commons.lang3.text.translate
│ ;version="3.10",org.apache.commons.lang3.time;version="3.10",org.apache
│ .commons.lang3.tuple;version="3.10"
│ -Include-Resource: META-INF/LICENSE.txt=LICENSE.txt,META-INF/NOTICE.txt=N
│ - OTICE.txt
│ Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
│ -Tool: Bnd-4.2.0.201903051501
├── META-INF/maven/org.apache.commons/commons-lang3/pom.xml
│ ├── META-INF/maven/org.apache.commons/commons-lang3/pom.xml
│ │ @@ -742,14 +742,24 @@
│ │ <version>4.0.0</version>
│ │ </dependency>
│ │ </dependencies>
│ │ <configuration>
│ │
<excludeFilterFile>${basedir}/spotbugs-exclude-filter.xml</excludeFilterFile>
│ │ </configuration>
│ │ </plugin>
│ │ + <plugin>
│ │ + <groupId>org.apache.felix</groupId>
│ │ + <artifactId>maven-bundle-plugin</artifactId>
│ │ + <configuration>
│ │ + <instructions>
│ │ + <_noextraheaders>true</_noextraheaders>
│ │ + <_removeheaders>Include-Resource</_removeheaders>
│ │ + </instructions>
│ │ + </configuration>
│ │ + </plugin>
│ │ </plugins>
│ │ </build>
│ │ <reporting>
│ │ <plugins>
│ │ <plugin>
│ │ <artifactId>maven-checkstyle-plugin</artifactId>
│ │ <version>${checkstyle.plugin.version}</version>
```
You can see that the headers `Bnd-LastModified`, `Include-Resource` and
`Tool` are removed (and that the suggested patch results in a changed
`pom.xml`, obviously).
Building version 3.10 with the backported patch results in two completely
identical files:
```
$ sha256sum commons-lang3-3.10_build3-patched.jar
commons-lang3-3.10_build4-patched.jar
8027ab78b1b8d4698975edf3d855d83e4c14e00e5ee6dcb891290b6c1bfd6d7d
commons-lang3-3.10_build3-patched.jar
8027ab78b1b8d4698975edf3d855d83e4c14e00e5ee6dcb891290b6c1bfd6d7d
commons-lang3-3.10_build4-patched.jar
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]