--- 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 14:33:49.541982462 +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); } } --- apache-ant-1.10.14/src/main/org/apache/tools/ant/taskdefs/Zip.java 2024-07-16 13:38:38.343095619 +0200 +++ apache-ant-1.10.14/src/main/org/apache/tools/ant/taskdefs/Zip.java 2024-07-16 14:33:59.575332992 +0200 @@ -1669,6 +1669,13 @@ extra); } + private long currentTimeMillisOrSourceDateEpoch() { + if ( System.getenv("SOURCE_DATE_EPOCH") != null ) { + return 1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")); + } + return System.currentTimeMillis(); + } + /** * Add a directory to the zip stream. * @param dir the directory to add to the archive @@ -1708,7 +1715,7 @@ } else if (dir != null && dir.isExists()) { ze.setTime(dir.getLastModified() + millisToAdd); } else { - ze.setTime(System.currentTimeMillis() + millisToAdd); + ze.setTime(currentTimeMillisOrSourceDateEpoch() + millisToAdd); } ze.setSize(0); ze.setMethod(ZipEntry.STORED);