Skip to content

Commit 2459e19

Browse files
committed
avoid negative entry time: upgrade plexus-archiver
benefit from codehaus-plexus/plexus-archiver#388
1 parent 88d241c commit 2459e19

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<dependency>
7777
<groupId>org.codehaus.plexus</groupId>
7878
<artifactId>plexus-archiver</artifactId>
79-
<version>4.10.1</version>
79+
<version>4.10.2</version>
8080
</dependency>
8181
<dependency>
8282
<groupId>org.codehaus.plexus</groupId>

src/test/java/org/apache/maven/archiver/MavenArchiverTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import java.util.jar.Manifest;
4545
import java.util.stream.Stream;
4646
import java.util.zip.ZipEntry;
47+
import java.util.zip.ZipFile;
4748

4849
import org.apache.maven.artifact.Artifact;
4950
import org.apache.maven.artifact.handler.ArtifactHandler;
@@ -1436,4 +1437,33 @@ void testThrownParseOutputTimestampInstant(String outputTimestamp) {
14361437
void testShortOffset(String value, long expected) {
14371438
assertThat(parseBuildOutputTimestamp(value)).contains(Instant.ofEpochSecond(expected));
14381439
}
1440+
1441+
private long testReproducibleJarEntryTime(String name, String timestamp) throws Exception {
1442+
File jarFile = new File("target/test/dummy-" + name + ".jar");
1443+
1444+
MavenArchiver archiver = getMavenArchiver(getCleanJarArchiver(jarFile));
1445+
archiver.configureReproducibleBuild(timestamp);
1446+
archiver.createArchive(getDummySession(), getDummyProject(), new MavenArchiveConfiguration());
1447+
1448+
assertThat(jarFile).exists();
1449+
ZipFile zf = new ZipFile(jarFile);
1450+
ZipEntry ze = zf.getEntry("META-INF/MANIFEST.MF");
1451+
return ze.getTime();
1452+
}
1453+
1454+
/**
1455+
* before upgrading plexus archiver to 4.10.2 to benefit from https://github.com/codehaus-plexus/plexus-archiver/pull/388
1456+
* $ zipdetails target/test/dummy-1970.jar
1457+
* gives negative Extended Timestamp in Java, that is seen as some point in time in 2106 (zip spec is unsigned)
1458+
* 0027 Extra ID #0001 5455 'UT: Extended Timestamp'
1459+
* 0029 Length 0005
1460+
* 002B Flags '01 mod'
1461+
* 002C Mod Time FFFFF1FA 'Sun Feb 7 06:28:26 2106'
1462+
* @throws Exception
1463+
*/
1464+
@Test
1465+
void testReproducibleJar19700101() throws Exception {
1466+
long entryTime = testReproducibleJarEntryTime("1970", "10");
1467+
assertThat(entryTime).isGreaterThanOrEqualTo(0);
1468+
}
14391469
}

0 commit comments

Comments
 (0)