Skip to content

Commit 4bb9065

Browse files
committed
avoid negative entry time: upgrade plexus-archiver
cherry-picked #320 benefit from codehaus-plexus/plexus-archiver#388
1 parent b169145 commit 4bb9065

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
@@ -85,7 +85,7 @@
8585
<dependency>
8686
<groupId>org.codehaus.plexus</groupId>
8787
<artifactId>plexus-archiver</artifactId>
88-
<version>4.10.1</version>
88+
<version>4.10.2</version>
8989
</dependency>
9090
<dependency>
9191
<groupId>org.codehaus.plexus</groupId>

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.util.jar.Manifest;
4242
import java.util.stream.Stream;
4343
import java.util.zip.ZipEntry;
44+
import java.util.zip.ZipFile;
4445

4546
import org.apache.maven.api.Dependency;
4647
import org.apache.maven.api.DependencyCoordinates;
@@ -1385,4 +1386,33 @@ public void setPath(Path path) {
13851386
this.path = path;
13861387
}
13871388
}
1389+
1390+
private long testReproducibleJarEntryTime(String name, String timestamp) throws Exception {
1391+
File jarFile = new File("target/test/dummy-" + name + ".jar");
1392+
1393+
MavenArchiver archiver = getMavenArchiver(getCleanJarArchiver(jarFile));
1394+
archiver.configureReproducibleBuild(timestamp);
1395+
archiver.createArchive(getDummySession(), getDummyProject(), new MavenArchiveConfiguration());
1396+
1397+
assertThat(jarFile).exists();
1398+
ZipFile zf = new ZipFile(jarFile);
1399+
ZipEntry ze = zf.getEntry("META-INF/MANIFEST.MF");
1400+
return ze.getTime();
1401+
}
1402+
1403+
/**
1404+
* before upgrading plexus archiver to 4.10.2 to benefit from https://github.com/codehaus-plexus/plexus-archiver/pull/388
1405+
* $ zipdetails target/test/dummy-1970.jar
1406+
* gives negative Extended Timestamp in Java, that is seen as some point in time in 2106 (zip spec is unsigned)
1407+
* 0027 Extra ID #0001 5455 'UT: Extended Timestamp'
1408+
* 0029 Length 0005
1409+
* 002B Flags '01 mod'
1410+
* 002C Mod Time FFFFF1FA 'Sun Feb 7 06:28:26 2106'
1411+
* @throws Exception
1412+
*/
1413+
@Test
1414+
void testReproducibleJar19700101() throws Exception {
1415+
long entryTime = testReproducibleJarEntryTime("1970", "10");
1416+
assertThat(entryTime).isGreaterThanOrEqualTo(0);
1417+
}
13881418
}

0 commit comments

Comments
 (0)