You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2025/12/19 19:05:56 UTC
(maven-archiver) branch timestamp-1970 updated (336488b -> ff5f654)
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a change to branch timestamp-1970
in repository https://gitbox.apache.org/repos/asf/maven-archiver.git
discard 336488b Add more timestamp tests
omit ee200f1 Bump Maven to 3.9.12
add b716b9a Bump Maven to 3.9.12
new ff5f654 Add more timestamp tests
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (336488b)
\
N -- N -- N refs/heads/timestamp-1970 (ff5f654)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
(maven-archiver) 01/01: Add more timestamp tests
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch timestamp-1970
in repository https://gitbox.apache.org/repos/asf/maven-archiver.git
commit ff5f654659d8cd6735acd4940c4a8257b19bbf3a
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Wed Sep 24 13:38:24 2025 +0200
Add more timestamp tests
---
.../apache/maven/archiver/MavenArchiverTest.java | 51 ++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java b/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
index b018c68..9e06e2e 100644
--- a/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
+++ b/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
@@ -46,6 +46,8 @@ import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
@@ -70,6 +72,9 @@ import static org.apache.maven.archiver.MavenArchiver.parseBuildOutputTimestamp;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.codehaus.plexus.archiver.util.Streams.bufferedOutputStream;
+import static org.codehaus.plexus.archiver.util.Streams.fileOutputStream;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -1466,4 +1471,50 @@ class MavenArchiverTest {
long entryTime = testReproducibleJarEntryTime("1970", "10");
assertThat(entryTime).isGreaterThanOrEqualTo(0);
}
+
+ private void checkJar(String name, String timestamp) throws Exception {
+ File jarFile = new File("target/test/dummy-" + name + ".jar");
+ JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
+
+ MavenArchiver archiver = getMavenArchiver(jarArchiver);
+ archiver.configureReproducibleBuild(timestamp);
+
+ MavenSession session = getDummySession();
+ MavenProject project = getDummyProject();
+
+ archiver.createArchive(session, project, new MavenArchiveConfiguration());
+ assertThat(jarFile).exists();
+ }
+
+ @Test
+ void checkJar() throws Exception {
+ checkJar("1970", "10");
+ checkJar("1970-0h0m10", "1970-01-01T00:00:10Z");
+ checkJar("1970-2h", "1970-01-01T02:00:00Z");
+ checkJar("1970-1h59", "1970-01-01T01:59:00Z");
+ checkJar("1970-1h", "1970-01-01T01:00:00Z");
+ checkJar("1970-0h59", "1970-01-01T00:59:00Z");
+ checkJar("2000", "2000-01-01T00:00:00Z");
+ }
+
+ @Test
+ void testCompress() throws Exception {
+ File zipFile = new File("target/test/dummy.zip");
+ ZipArchiveOutputStream zipArchiveOutputStream =
+ new ZipArchiveOutputStream(bufferedOutputStream(fileOutputStream(zipFile, "zip")));
+ zipArchiveOutputStream.setEncoding("UTF-8");
+ zipArchiveOutputStream.setCreateUnicodeExtraFields(ZipArchiveOutputStream.UnicodeExtraFieldPolicy.NEVER);
+ zipArchiveOutputStream.setMethod(ZipArchiveOutputStream.DEFLATED);
+
+ ZipArchiveEntry ze = new ZipArchiveEntry("f.txt");
+ ze.setTime(0);
+
+ zipArchiveOutputStream.putArchiveEntry(ze);
+ zipArchiveOutputStream.write(1);
+ zipArchiveOutputStream.closeArchiveEntry();
+
+ zipArchiveOutputStream.close();
+
+ assertTrue(zipFile.delete());
+ }
}