SHA256
1
0
forked from pool/ant
ant/reproducible-jar-mtime.patch

44 lines
1.7 KiB
Diff

--- apache-ant-1.10.14/src/main/org/apache/tools/ant/taskdefs/Jar.java 2024-07-16 13:38:38.336428941 +0200
+++ apache-ant-1.10.14/src/main/org/apache/tools/ant/taskdefs/Jar.java 2024-07-16 13:48:05.794045414 +0200
@@ -450,6 +450,13 @@
serviceList.add(service);
}
+ private long currentTimeMillisOrSourceDateEpoch() {
+ if ( System.getenv("SOURCE_DATE_EPOCH") != null ) {
+ return 1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH"));
+ }
+ return System.currentTimeMillis();
+ }
+
/**
* Write SPI Information to JAR
*/
@@ -459,7 +466,7 @@
//stolen from writeManifest
super.zipFile(is, zOut,
"META-INF/services/" + service.getType(),
- System.currentTimeMillis(), null,
+ currentTimeMillisOrSourceDateEpoch(), null,
ZipFileSet.DEFAULT_FILE_MODE);
}
}
@@ -579,7 +586,7 @@
new ByteArrayInputStream(baos.toByteArray());
try {
super.zipFile(bais, zOut, MANIFEST_NAME,
- System.currentTimeMillis(), null,
+ currentTimeMillisOrSourceDateEpoch(), null,
ZipFileSet.DEFAULT_FILE_MODE);
} finally {
// not really required
@@ -656,7 +663,7 @@
writer.close();
try (ByteArrayInputStream bais =
new ByteArrayInputStream(baos.toByteArray())) {
- super.zipFile(bais, zOut, INDEX_NAME, System.currentTimeMillis(),
+ super.zipFile(bais, zOut, INDEX_NAME, currentTimeMillisOrSourceDateEpoch(),
null, ZipFileSet.DEFAULT_FILE_MODE);
}
}