Skip to content

Commit 669cf65

Browse files
authored
Merge pull request #461 from BrandonSchmitt/improvement/FELIX-6814-reproducible
[FELIX-6814] Improve Reproducible Build Support
2 parents 60dc7d4 + 2a8237c commit 669cf65

File tree

5 files changed

+37
-3
lines changed

5 files changed

+37
-3
lines changed

tools/maven-bundle-plugin/src/it/reproducible-manifest/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ under the License.
2626
<!-- default packaging: jar -->
2727

2828
<properties>
29-
<project.build.outputTimestamp>1</project.build.outputTimestamp>
29+
<project.build.outputTimestamp>2000-01-01T00:00:00Z</project.build.outputTimestamp>
3030
</properties>
3131

3232
<dependencies>

tools/maven-bundle-plugin/src/it/reproducible-manifest/verify.groovy

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
* under the License.
1818
*/
1919

20+
import java.time.LocalDateTime
21+
import java.time.ZoneId
22+
import java.util.zip.ZipEntry
23+
import java.util.zip.ZipFile
24+
25+
2026
String manifest = new File( basedir, "target/classes/META-INF/MANIFEST.MF" ).text;
2127

2228
assert !manifest.contains( "Build-Jdk:" )
@@ -25,3 +31,14 @@ assert manifest.contains( "Build-Jdk-Spec:" )
2531
assert !manifest.contains( "Build-By:" )
2632

2733
assert !manifest.contains( "Bnd-LastModified:" )
34+
35+
36+
Enumeration<? extends ZipEntry> bundleEntries = new ZipFile(new File( basedir, "target/reproducible-1-SNAPSHOT.jar" )).entries()
37+
38+
// ZipEntry::getTime() interprets the time information in the local timezone.
39+
long expectedTime = LocalDateTime.of(2000, 1, 1, 0, 0, 0).atZone(ZoneId.systemDefault()).toEpochSecond() * 1000
40+
41+
while(bundleEntries.hasMoreElements()) {
42+
ZipEntry entry = bundleEntries.nextElement()
43+
assert entry.getTime() == expectedTime
44+
}

tools/maven-bundle-plugin/src/it/reproducible/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ under the License.
2525
<version>1-SNAPSHOT</version>
2626
<packaging>bundle</packaging>
2727
<properties>
28-
<project.build.outputTimestamp>1</project.build.outputTimestamp>
28+
<project.build.outputTimestamp>946684800</project.build.outputTimestamp>
2929
</properties>
3030
<dependencies>
3131
<dependency>

tools/maven-bundle-plugin/src/it/reproducible/verify.groovy

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
* under the License.
1818
*/
1919

20+
import java.time.LocalDateTime
21+
import java.time.ZoneId
22+
import java.util.zip.ZipEntry
23+
import java.util.zip.ZipFile
24+
25+
2026
String manifest = new File( basedir, "target/classes/META-INF/MANIFEST.MF" ).text;
2127

2228
assert !manifest.contains( "Build-Jdk:" )
@@ -25,3 +31,14 @@ assert manifest.contains( "Build-Jdk-Spec:" )
2531
assert !manifest.contains( "Build-By:" )
2632

2733
assert !manifest.contains( "Bnd-LastModified:" )
34+
35+
36+
Enumeration<? extends ZipEntry> bundleEntries = new ZipFile(new File( basedir, "target/reproducible-1-SNAPSHOT.jar" )).entries()
37+
38+
// ZipEntry::getTime() interprets the time information in the local timezone.
39+
long expectedTime = LocalDateTime.of(2000, 1, 1, 0, 0, 0).atZone(ZoneId.systemDefault()).toEpochSecond() * 1000
40+
41+
while(bundleEntries.hasMoreElements()) {
42+
ZipEntry entry = bundleEntries.nextElement()
43+
assert entry.getTime() == expectedTime
44+
}

tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ protected Builder getOSGiBuilder( MavenProject currentProject, Map<String, Strin
553553

554554
if ( new MavenArchiver().parseOutputTimestamp( outputTimestamp ) != null )
555555
{
556-
properties.put( Constants.REPRODUCIBLE, "true" );
556+
properties.put( Constants.REPRODUCIBLE, outputTimestamp );
557557
}
558558

559559
// process overrides from project

0 commit comments

Comments
 (0)