From 2124ea40011690d2b9b8950f393b1cf05e9f19e5 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Wed, 20 Aug 2025 19:55:50 +0200 Subject: [PATCH 01/14] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index ac3389b5..ef80f4d6 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ plexus-archiver - 4.10.1 + 4.10.2-SNAPSHOT Plexus Archiver Component https://codehaus-plexus.github.io/plexus-archiver/ @@ -30,7 +30,7 @@ scm:git:https://github.com/codehaus-plexus/plexus-archiver.git scm:git:https://github.com/codehaus-plexus/plexus-archiver.git - plexus-archiver-4.10.1 + HEAD https://github.com/codehaus-plexus/plexus-archiver/tree/${project.scm.tag}/ @@ -47,7 +47,7 @@ 1.7.36 0.9.0.M4 - 2025-08-20T17:55:16Z + 2025-08-20T17:55:50Z From c3c0bae358806cafcc6f52129a07caa9691eff3f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Sep 2025 23:01:18 +0000 Subject: [PATCH 02/14] Bump org.assertj:assertj-core from 3.27.4 to 3.27.5 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.27.4 to 3.27.5. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.27.4...assertj-build-3.27.5) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-version: 3.27.5 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ef80f4d6..526c4538 100644 --- a/pom.xml +++ b/pom.xml @@ -140,7 +140,7 @@ org.assertj assertj-core - 3.27.4 + 3.27.5 test From d88dfdcaa41704a7a3b2fcab4247d51f8ca6cbc2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 23:03:10 +0000 Subject: [PATCH 03/14] Bump org.assertj:assertj-core from 3.27.5 to 3.27.6 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.27.5 to 3.27.6. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.27.5...assertj-build-3.27.6) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-version: 3.27.6 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 526c4538..19882ec0 100644 --- a/pom.xml +++ b/pom.xml @@ -140,7 +140,7 @@ org.assertj assertj-core - 3.27.5 + 3.27.6 test From 29404bd2043dc70d37e117acb6703cb3f02d3762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sat, 27 Sep 2025 02:03:17 +0200 Subject: [PATCH 04/14] check minimum timestamp: avoid negative Zip 5455 Extended Timestamp --- .../codehaus/plexus/archiver/zip/AbstractZipArchiver.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java b/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java index 0b4bdb5e..dccb7edc 100755 --- a/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java +++ b/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java @@ -698,7 +698,14 @@ protected FileTime normalizeLastModifiedTime(FileTime lastModifiedTime) { */ private static long dosToJavaTime(long dosTime) { Calendar cal = Calendar.getInstance(TimeZone.getDefault(), Locale.ROOT); + if (dosTime < MIN_DOS_JAVA_TIME) { + dosTime = MIN_DOS_JAVA_TIME; + } cal.setTimeInMillis(dosTime); return dosTime - (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)); } + + // minimum DOS time that will give a positive Java time, whatever the current TZ is: + // biggest TZ offset is for Etc/GMT-14 https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + private static final long MIN_DOS_JAVA_TIME = 1000 * 14 * 3600; } From e99ec39ea03b5831c83b5c2a64c0531726000242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Wed, 1 Oct 2025 00:11:28 +0200 Subject: [PATCH 05/14] [maven-release-plugin] prepare release plexus-archiver-4.10.2 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 19882ec0..e459e9ea 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ plexus-archiver - 4.10.2-SNAPSHOT + 4.10.2 Plexus Archiver Component https://codehaus-plexus.github.io/plexus-archiver/ @@ -30,7 +30,7 @@ scm:git:https://github.com/codehaus-plexus/plexus-archiver.git scm:git:https://github.com/codehaus-plexus/plexus-archiver.git - HEAD + plexus-archiver-4.10.2 https://github.com/codehaus-plexus/plexus-archiver/tree/${project.scm.tag}/ @@ -47,7 +47,7 @@ 1.7.36 0.9.0.M4 - 2025-08-20T17:55:50Z + 2025-09-30T22:11:17Z From 89bcc54575cd911c25440ee03d4005bf6580858a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Wed, 1 Oct 2025 00:11:30 +0200 Subject: [PATCH 06/14] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index e459e9ea..24d7c35c 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ plexus-archiver - 4.10.2 + 4.10.3-SNAPSHOT Plexus Archiver Component https://codehaus-plexus.github.io/plexus-archiver/ @@ -30,7 +30,7 @@ scm:git:https://github.com/codehaus-plexus/plexus-archiver.git scm:git:https://github.com/codehaus-plexus/plexus-archiver.git - plexus-archiver-4.10.2 + HEAD https://github.com/codehaus-plexus/plexus-archiver/tree/${project.scm.tag}/ @@ -47,7 +47,7 @@ 1.7.36 0.9.0.M4 - 2025-09-30T22:11:17Z + 2025-09-30T22:11:30Z From c099a553f1e66db2605a875dc73bc055ace5adf6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 23:01:20 +0000 Subject: [PATCH 07/14] Bump com.github.luben:zstd-jni from 1.5.7-4 to 1.5.7-5 Bumps [com.github.luben:zstd-jni](https://github.com/luben/zstd-jni) from 1.5.7-4 to 1.5.7-5. - [Commits](https://github.com/luben/zstd-jni/compare/v1.5.7-4...v1.5.7-5) --- updated-dependencies: - dependency-name: com.github.luben:zstd-jni dependency-version: 1.5.7-5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 24d7c35c..a492a1de 100644 --- a/pom.xml +++ b/pom.xml @@ -98,7 +98,7 @@ com.github.luben zstd-jni - 1.5.7-4 + 1.5.7-5 runtime From 59f88006a9257cddd99998f5a16f990d00a1fbaf Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Oct 2025 00:21:50 +0200 Subject: [PATCH 08/14] Reduce heap usage in Zip archiver to prevent OutOfMemoryError in CI builds (#390) * Reduce heap usage threshold from 100MB to 10MB in ConcurrentJarCreator The previous threshold of 100000000 (100MB) divided by number of threads was causing OutOfMemoryError issues when creating zip archives, particularly in environments with limited heap space like CI systems. The ByteArrayOutputStream used internally can grow up to 2x the threshold before switching to disk-based storage, leading to excessive memory consumption. Reducing to 10000000 (10MB) reduces memory pressure while still maintaining reasonable performance. For typical builds with 4 threads, this means: - Before: 25MB per stream (potentially 50MB+ with buffer doubling) - After: 2.5MB per stream (potentially 5MB+ with buffer doubling) This change addresses the heap space errors reported in apache/maven CI builds. Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com> * Add maximum buffer size cap to ByteArrayOutputStream Cap individual buffer allocations to 16MB to prevent excessive memory usage. The previous implementation allowed buffers to double indefinitely, which could lead to very large single allocations (32MB, 64MB, 128MB, etc.) that contribute to heap exhaustion. With this cap, when more than 16MB of data needs to be stored, the ByteArrayOutputStream will create multiple 16MB buffers instead of one giant buffer. This spreads the memory allocation across multiple smaller chunks and prevents heap fragmentation issues. Combined with the reduced threshold in ConcurrentJarCreator, this provides defense-in-depth against OutOfMemoryError during zip archive creation. Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com> --- .../plexus/archiver/zip/ByteArrayOutputStream.java | 9 +++++++++ .../plexus/archiver/zip/ConcurrentJarCreator.java | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/codehaus/plexus/archiver/zip/ByteArrayOutputStream.java b/src/main/java/org/codehaus/plexus/archiver/zip/ByteArrayOutputStream.java index 41a26f0c..7a6bc952 100644 --- a/src/main/java/org/codehaus/plexus/archiver/zip/ByteArrayOutputStream.java +++ b/src/main/java/org/codehaus/plexus/archiver/zip/ByteArrayOutputStream.java @@ -57,6 +57,12 @@ public class ByteArrayOutputStream extends OutputStream { */ private static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; + /** + * Maximum size of a single buffer (16MB) to prevent excessive memory allocation. + * When buffers need to grow beyond this size, additional buffers are created instead. + */ + private static final int MAX_BUFFER_SIZE = 16 * 1024 * 1024; + /** * The list of buffers, which grows and never reduces. */ @@ -136,6 +142,9 @@ private void needNewBuffer(final int newcount) { filledBufferSum += currentBuffer.length; } + // Cap the buffer size to prevent excessive memory allocation + newBufferSize = Math.min(newBufferSize, MAX_BUFFER_SIZE); + currentBufferIndex++; currentBuffer = new byte[newBufferSize]; buffers.add(currentBuffer); diff --git a/src/main/java/org/codehaus/plexus/archiver/zip/ConcurrentJarCreator.java b/src/main/java/org/codehaus/plexus/archiver/zip/ConcurrentJarCreator.java index e431efe7..18c6ae09 100644 --- a/src/main/java/org/codehaus/plexus/archiver/zip/ConcurrentJarCreator.java +++ b/src/main/java/org/codehaus/plexus/archiver/zip/ConcurrentJarCreator.java @@ -112,7 +112,7 @@ public ConcurrentJarCreator(int nThreads) throws IOException { */ public ConcurrentJarCreator(boolean compressAddedZips, int nThreads) throws IOException { this.compressAddedZips = compressAddedZips; - ScatterGatherBackingStoreSupplier defaultSupplier = new DeferredSupplier(100000000 / nThreads); + ScatterGatherBackingStoreSupplier defaultSupplier = new DeferredSupplier(10000000 / nThreads); metaInfDir = createDeferred(defaultSupplier); manifest = createDeferred(defaultSupplier); directories = createDeferred(defaultSupplier); From a99931bfb2bbd8cbd7d62220a5d12b0fd9b32321 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Oct 2025 11:25:07 +0200 Subject: [PATCH 09/14] Fix AbstractArchiver.getFiles() to return forward slashes for ZIP-based archivers (#392) * Override getFiles() in AbstractZipArchiver to normalize paths to forward slashes Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com> --- .../plexus/archiver/AbstractArchiver.java | 17 +++++++++ .../codehaus/plexus/archiver/Archiver.java | 10 ++++++ .../archiver/zip/AbstractZipArchiver.java | 25 +++++++++++++ .../plexus/archiver/zip/ZipArchiverTest.java | 35 +++++++++++++++++++ 4 files changed, 87 insertions(+) diff --git a/src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java b/src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java index 673eda8a..734e1cd5 100755 --- a/src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java +++ b/src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java @@ -616,6 +616,23 @@ private static void closeQuietlyIfCloseable(Object resource) { } } + /** + * Returns a map of the files that have been added to the archive. + *

+ * Note: The entry names in the map use platform-specific path separators + * (e.g., backslashes on Windows, forward slashes on Unix). For ZIP archivers, + * the actual archive entries will use forward slashes as required by the ZIP + * specification, but this map returns names as they were added. + *

+ *

+ * For ZIP-based archivers (ZipArchiver, JarArchiver, etc.), use the overridden + * implementation which normalizes paths to forward slashes to match the actual + * ZIP entry names. + *

+ * + * @return A map where keys are entry names and values are the corresponding ArchiveEntry objects. + * @deprecated Use {@link #getResources()} instead. + */ @Override @Deprecated public Map getFiles() { diff --git a/src/main/java/org/codehaus/plexus/archiver/Archiver.java b/src/main/java/org/codehaus/plexus/archiver/Archiver.java index 578a668d..7ff08ae5 100644 --- a/src/main/java/org/codehaus/plexus/archiver/Archiver.java +++ b/src/main/java/org/codehaus/plexus/archiver/Archiver.java @@ -260,6 +260,16 @@ void addArchivedFileSet(@Nonnull File archiveFile, String prefix, String[] inclu ResourceIterator getResources() throws ArchiverException; /** + * Returns a map of the files that have been added to the archive. + *

+ * Note: The entry names in the map may use platform-specific path separators + * in the base implementation. However, archive format-specific implementations + * (such as ZIP-based archivers) should normalize paths according to their format + * requirements. For example, ZIP archivers normalize to forward slashes as required + * by the ZIP file specification. + *

+ * + * @return A map where keys are entry names and values are the corresponding ArchiveEntry objects. * @deprecated Use {@link #getResources()} */ @Deprecated diff --git a/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java b/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java index dccb7edc..04e56c21 100755 --- a/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java +++ b/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java @@ -27,8 +27,10 @@ import java.nio.file.attribute.FileTime; import java.util.Calendar; import java.util.Deque; +import java.util.HashMap; import java.util.Hashtable; import java.util.Locale; +import java.util.Map; import java.util.TimeZone; import java.util.concurrent.ExecutionException; import java.util.zip.CRC32; @@ -564,6 +566,29 @@ protected boolean createEmptyZip(File zipFile) throws ArchiverException { return true; } + /** + * Returns a map of the files that have been added to the archive. + * This method is overridden to normalize path separators to forward slashes, + * as required by the ZIP file format specification. + * + * @return A map where keys are entry names with forward slashes as separators, + * and values are the corresponding ArchiveEntry objects. + * @deprecated Use {@link #getResources()} instead. + */ + @Override + @Deprecated + public Map getFiles() { + Map files = super.getFiles(); + Map normalizedFiles = new HashMap<>(); + + for (Map.Entry entry : files.entrySet()) { + String normalizedPath = entry.getKey().replace(File.separatorChar, '/'); + normalizedFiles.put(normalizedPath, entry.getValue()); + } + + return normalizedFiles; + } + /** * Do any clean up necessary to allow this instance to be used again. *

diff --git a/src/test/java/org/codehaus/plexus/archiver/zip/ZipArchiverTest.java b/src/test/java/org/codehaus/plexus/archiver/zip/ZipArchiverTest.java index 4323aad7..68f8b2ad 100644 --- a/src/test/java/org/codehaus/plexus/archiver/zip/ZipArchiverTest.java +++ b/src/test/java/org/codehaus/plexus/archiver/zip/ZipArchiverTest.java @@ -52,6 +52,7 @@ import org.apache.commons.compress.archivers.zip.ZipExtraField; import org.apache.commons.compress.archivers.zip.ZipFile; import org.apache.commons.io.input.BoundedInputStream; +import org.codehaus.plexus.archiver.ArchiveEntry; import org.codehaus.plexus.archiver.Archiver; import org.codehaus.plexus.archiver.ArchiverException; import org.codehaus.plexus.archiver.BasePlexusArchiverTest; @@ -857,4 +858,38 @@ private long toLocalTimeZone(long timestamp) { return 0L; } } + + /** + * Test that getFiles() returns entry names with forward slashes (not platform-specific separators) + * as required by the ZIP file specification. + */ + @Test + void testGetFilesReturnsForwardSlashes() throws Exception { + File zipFile = getTestFile("target/output/test-getfiles-slashes.zip"); + ZipArchiver archiver = getZipArchiver(zipFile); + + // Add files with nested directory structure + File pomFile = new File("pom.xml"); + archiver.addFile(pomFile, "dir1/dir2/pom.xml"); + archiver.addFile(pomFile, "another/nested/path/file.xml"); + + // Get the files map BEFORE creating the archive + Map files = archiver.getFiles(); + + // Verify all entry names use forward slashes + for (String entryName : files.keySet()) { + assertFalse(entryName.contains("\\"), "Entry name should not contain backslashes, but got: " + entryName); + assertTrue( + entryName.contains("/") || !entryName.contains(File.separator), + "Entry name should use forward slashes as separator: " + entryName); + } + + // Verify specific entries exist with correct format + assertTrue(files.containsKey("dir1/dir2/pom.xml"), "Should contain dir1/dir2/pom.xml"); + assertTrue(files.containsKey("another/nested/path/file.xml"), "Should contain another/nested/path/file.xml"); + + // Create the archive to ensure it's valid + archiver.createArchive(); + assertTrue(zipFile.exists()); + } } From 6a621319c4d93a803c2211de60571ba79ef99058 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 5 Oct 2025 13:59:06 +0000 Subject: [PATCH 10/14] Fix handling of zip entries with unspecified modification time (-1) --- .../archiver/zip/AbstractZipUnArchiver.java | 8 +++-- .../archiver/zip/ZipUnArchiverTest.java | 32 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipUnArchiver.java b/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipUnArchiver.java index c2f3f550..0ecf65fe 100644 --- a/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipUnArchiver.java +++ b/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipUnArchiver.java @@ -117,7 +117,7 @@ public InputStream getContents() throws IOException { @Override public long getLastModified() { final long l = zipEntry.getTime(); - return l == 0 ? PlexusIoResource.UNKNOWN_MODIFICATION_DATE : l; + return l <= 0 ? PlexusIoResource.UNKNOWN_MODIFICATION_DATE : l; } @Override @@ -174,12 +174,16 @@ protected void execute(final String path, final File outputDirectory) throws Arc .setInputStream(in) .setMaxCount(remainingSpace + 1) .get(); + long time = ze.getTime(); + if (time <= 0) { + time = PlexusIoResource.UNKNOWN_MODIFICATION_DATE; + } extractFile( getSourceFile(), outputDirectory, bis, ze.getName(), - new Date(ze.getTime()), + new Date(time), ze.isDirectory(), ze.getUnixMode() != 0 ? ze.getUnixMode() : null, resolveSymlink(zipFile, ze), diff --git a/src/test/java/org/codehaus/plexus/archiver/zip/ZipUnArchiverTest.java b/src/test/java/org/codehaus/plexus/archiver/zip/ZipUnArchiverTest.java index 222661a0..e86953d0 100644 --- a/src/test/java/org/codehaus/plexus/archiver/zip/ZipUnArchiverTest.java +++ b/src/test/java/org/codehaus/plexus/archiver/zip/ZipUnArchiverTest.java @@ -263,4 +263,36 @@ private ZipArchiver getZipArchiver(File destFile) { zipArchiver.setDestFile(destFile); return zipArchiver; } + + @Test + void testZipWithNegativeModificationTime() throws Exception { + // Create a zip file with an entry that has -1 modification time + File zipFile = new File("target/output/zip-with-negative-time.zip"); + zipFile.getParentFile().mkdirs(); + + // Create a simple zip file using Apache Commons Compress + try (org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream zos = + new org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream(zipFile)) { + org.apache.commons.compress.archivers.zip.ZipArchiveEntry entry = + new org.apache.commons.compress.archivers.zip.ZipArchiveEntry("test-file.txt"); + // Set modification time to -1 to simulate unspecified modification time + entry.setTime(-1); + zos.putArchiveEntry(entry); + zos.write("Test content".getBytes()); + zos.closeArchiveEntry(); + } + + // Now try to extract it - this should not throw an IllegalArgumentException + File outputDirectory = new File("target/output/zip-negative-time-extract"); + FileUtils.deleteDirectory(outputDirectory); + outputDirectory.mkdirs(); + + ZipUnArchiver zu = getZipUnArchiver(zipFile); + zu.extract("", outputDirectory); + + // Verify the file was extracted + File extractedFile = new File(outputDirectory, "test-file.txt"); + assertTrue(extractedFile.exists()); + assertEquals("Test content", new String(java.nio.file.Files.readAllBytes(extractedFile.toPath()))); + } } From c9d01eb9d7432f9cf66e0c57ae7f91c468922294 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Wed, 8 Oct 2025 17:36:06 +0200 Subject: [PATCH 11/14] Update plexus-io to 3.5.2 and downgrade plexus-utils to 3.6.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index a492a1de..cb60fc6f 100644 --- a/pom.xml +++ b/pom.xml @@ -61,12 +61,12 @@ org.codehaus.plexus plexus-utils - 4.0.2 + 3.6.0 org.codehaus.plexus plexus-io - 3.5.1 + 3.5.2 @@ -134,7 +134,7 @@ com.google.inject guice - 6.0.0 + 5.1.0 test From 05bfae834cb637a20672a11ec77421f4c110de62 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Wed, 8 Oct 2025 17:41:14 +0200 Subject: [PATCH 12/14] Convert apt to markdown with doxia-converter --- src/site/apt/index.apt | 70 -------------------------------------- src/site/markdown/index.md | 10 ++++++ 2 files changed, 10 insertions(+), 70 deletions(-) delete mode 100644 src/site/apt/index.apt create mode 100644 src/site/markdown/index.md diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt deleted file mode 100644 index 071b5fab..00000000 --- a/src/site/apt/index.apt +++ /dev/null @@ -1,70 +0,0 @@ - ----- - Plexus Archiver - ----- - Hervé Boutemy - ----- - 2018-05-08 - ----- - -Plexus Archiver - - Collection of Plexus components to create archives or extract archives to a directory - with a unified {{{./apidocs/index.html?org/codehaus/plexus/archiver/Archiver.html}<<>>}}/{{{./apidocs/index.html?org/codehaus/plexus/archiver/UnArchiver.html}<<>>}} - API whatever the archive format is. - -*------------------+-----------------+ -|| Interface || Components for supported formats (as Plexus role hint) -*------------------+-----------------+ -| {{{./apidocs/index.html?org/codehaus/plexus/archiver/Archiver.html}<<>>}} | -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/bzip2/BZip2Archiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/dir/DirectoryArchiver.html}<<

>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/ear/EarArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/gzip/GZipArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/jar/JarArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/jar/JarToolModularJarArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/rar/RarArchiver.html}<<>>}} (notice produces a <<>>), -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/snappy/SnappyArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarBZip2Archiver.html}<<>>}} -| | ({{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TBZ2Archiver.html}<<>>}}), -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarGZipArchiver.html}<<>>}} -| | ({{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TGZArchiver.html}<<>>}}), -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarSnappyArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarZstdArchiver.html}<<>>}} -| | ({{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TZstdArchiver.html}<<>>}}), -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarXZArchiver.html}<<>>}} -| | ({{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TXZArchiver.html}<<>>}}), -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/war/WarArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/xz/XZArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/zip/ZipArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/zstd/ZstdArchiver.html}<<>>}} -| | -*------------------+-----------------+ -| {{{./apidocs/index.html?org/codehaus/plexus/archiver/UnArchiver.html}<<>>}} | -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/bzip2/BZip2UnArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/gzip/GZipUnArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/snappy/SnappyUnArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarUnArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarBZip2Archiver.html}<<>>}} -| | ({{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TBZ2Archiver.html}<<>>}}), -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarGZipUnArchiver.html}<<>>}} -| | ({{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TGZUnArchiver.html}<<>>}}), -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarSnappyUnArchiver.html}<<>>}} -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarZstdUnArchiver.html}<<>>}} -| | ({{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TZstdUnArchiver.html}<<>>}}), -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarXZUnArchiver.html}<<>>}} -| | ({{{./apidocs/index.html?org/codehaus/plexus/archiver/tar/TXZUnArchiver.html}<<>>}}), -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/xz/XZUnArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/zip/ZipUnArchiver.html}<<>>}} -| | (also available as {{{./apidocs/index.html?org/codehaus/plexus/archiver/car/CarUnArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/ear/EarUnArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/esb/EsbUnArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/jar/JarUnArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/nar/NarUnArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/par/ParUnArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/rar/RarUnArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/sar/SarUnArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/swc/SwcUnArchiver.html}<<>>}}, -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/war/WarUnArchiver.html}<<>>}}), -| | {{{./apidocs/index.html?org/codehaus/plexus/archiver/zstd/ZstdUnArchiver.html}<<>>}} -*------------------+-----------------+ diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md new file mode 100644 index 00000000..1df0d9d8 --- /dev/null +++ b/src/site/markdown/index.md @@ -0,0 +1,10 @@ +# Plexus Archiver + +Collection of Plexus components to create archives or extract archives to a directory with a unified [`Archiver`](./apidocs/index.html?org/codehaus/plexus/archiver/Archiver.html)/[`UnArchiver`](./apidocs/index.html?org/codehaus/plexus/archiver/UnArchiver.html) API whatever the archive format is. + +| Interface | Components for supported formats (as Plexus role hint) | +|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [`Archiver`](./apidocs/index.html?org/codehaus/plexus/archiver/Archiver.html) | [`bzip2`](./apidocs/index.html?org/codehaus/plexus/archiver/bzip2/BZip2Archiver.html), [`dir`](./apidocs/index.html?org/codehaus/plexus/archiver/dir/DirectoryArchiver.html), [`ear`](./apidocs/index.html?org/codehaus/plexus/archiver/ear/EarArchiver.html), [`gzip`](./apidocs/index.html?org/codehaus/plexus/archiver/gzip/GZipArchiver.html), [`jar`](./apidocs/index.html?org/codehaus/plexus/archiver/jar/JarArchiver.html), [`mjar`](./apidocs/index.html?org/codehaus/plexus/archiver/jar/JarToolModularJarArchiver.html), [`rar`](./apidocs/index.html?org/codehaus/plexus/archiver/rar/RarArchiver.html) \(notice produces a `jar`\), [`snappy`](./apidocs/index.html?org/codehaus/plexus/archiver/snappy/SnappyArchiver.html), [`tar`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarArchiver.html), [`tar.bz2`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarBZip2Archiver.html) \([`tbz2`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TBZ2Archiver.html)\), [`tar.gz`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarGZipArchiver.html) \([`tgz`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TGZArchiver.html)\), [`tar.snappy`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarSnappyArchiver.html), [`tar.zst`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarZstdArchiver.html) \([`tzst`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TZstdArchiver.html)\), [`tar.xz`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarXZArchiver.html) \([`txz`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TXZArchiver.html)\), [`war`](./apidocs/index.html?org/codehaus/plexus/archiver/war/WarArchiver.html), [`xz`](./apidocs/index.html?org/codehaus/plexus/archiver/xz/XZArchiver.html), [`zip`](./apidocs/index.html?org/codehaus/plexus/archiver/zip/ZipArchiver.html), [`zst`](./apidocs/index.html?org/codehaus/plexus/archiver/zstd/ZstdArchiver.html) | +| | | +| [`UnArchiver`](./apidocs/index.html?org/codehaus/plexus/archiver/UnArchiver.html) | [`bzip2`](./apidocs/index.html?org/codehaus/plexus/archiver/bzip2/BZip2UnArchiver.html), [`gzip`](./apidocs/index.html?org/codehaus/plexus/archiver/gzip/GZipUnArchiver.html), [`snappy`](./apidocs/index.html?org/codehaus/plexus/archiver/snappy/SnappyUnArchiver.html), [`tar`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarUnArchiver.html), [`tar.bz2`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarBZip2Archiver.html) \([`tbz2`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TBZ2Archiver.html)\), [`tar.gz`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarGZipUnArchiver.html) \([`tgz`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TGZUnArchiver.html)\), [`tar.snappy`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarSnappyUnArchiver.html) [`tar.zst`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarZstdUnArchiver.html) \([`tzst`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TZstdUnArchiver.html)\), [`tar.xz`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarXZUnArchiver.html) \([`txz`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TXZUnArchiver.html)\), [`xz`](./apidocs/index.html?org/codehaus/plexus/archiver/xz/XZUnArchiver.html), [`zip`](./apidocs/index.html?org/codehaus/plexus/archiver/zip/ZipUnArchiver.html) \(also available as [`car`](./apidocs/index.html?org/codehaus/plexus/archiver/car/CarUnArchiver.html), [`ear`](./apidocs/index.html?org/codehaus/plexus/archiver/ear/EarUnArchiver.html), [`esb`](./apidocs/index.html?org/codehaus/plexus/archiver/esb/EsbUnArchiver.html), [`jar`](./apidocs/index.html?org/codehaus/plexus/archiver/jar/JarUnArchiver.html), [`nar`](./apidocs/index.html?org/codehaus/plexus/archiver/nar/NarUnArchiver.html), [`par`](./apidocs/index.html?org/codehaus/plexus/archiver/par/ParUnArchiver.html), [`rar`](./apidocs/index.html?org/codehaus/plexus/archiver/rar/RarUnArchiver.html), [`sar`](./apidocs/index.html?org/codehaus/plexus/archiver/sar/SarUnArchiver.html), [`swc`](./apidocs/index.html?org/codehaus/plexus/archiver/swc/SwcUnArchiver.html), [`war`](./apidocs/index.html?org/codehaus/plexus/archiver/war/WarUnArchiver.html)\), [`zst`](./apidocs/index.html?org/codehaus/plexus/archiver/zstd/ZstdUnArchiver.html) | + From b73b1aeae24dd54cf957e0ed22f7f4f514967b3a Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Wed, 8 Oct 2025 17:46:35 +0200 Subject: [PATCH 13/14] Add comparison to Commons Compress in README Co-authored-by: Copilot <198982749+copilot@users.noreply.github.com> --- src/site/markdown/index.md | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index 1df0d9d8..e846c78c 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -8,3 +8,55 @@ Collection of Plexus components to create archives or extract archives to a dire | | | | [`UnArchiver`](./apidocs/index.html?org/codehaus/plexus/archiver/UnArchiver.html) | [`bzip2`](./apidocs/index.html?org/codehaus/plexus/archiver/bzip2/BZip2UnArchiver.html), [`gzip`](./apidocs/index.html?org/codehaus/plexus/archiver/gzip/GZipUnArchiver.html), [`snappy`](./apidocs/index.html?org/codehaus/plexus/archiver/snappy/SnappyUnArchiver.html), [`tar`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarUnArchiver.html), [`tar.bz2`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarBZip2Archiver.html) \([`tbz2`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TBZ2Archiver.html)\), [`tar.gz`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarGZipUnArchiver.html) \([`tgz`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TGZUnArchiver.html)\), [`tar.snappy`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarSnappyUnArchiver.html) [`tar.zst`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarZstdUnArchiver.html) \([`tzst`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TZstdUnArchiver.html)\), [`tar.xz`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TarXZUnArchiver.html) \([`txz`](./apidocs/index.html?org/codehaus/plexus/archiver/tar/TXZUnArchiver.html)\), [`xz`](./apidocs/index.html?org/codehaus/plexus/archiver/xz/XZUnArchiver.html), [`zip`](./apidocs/index.html?org/codehaus/plexus/archiver/zip/ZipUnArchiver.html) \(also available as [`car`](./apidocs/index.html?org/codehaus/plexus/archiver/car/CarUnArchiver.html), [`ear`](./apidocs/index.html?org/codehaus/plexus/archiver/ear/EarUnArchiver.html), [`esb`](./apidocs/index.html?org/codehaus/plexus/archiver/esb/EsbUnArchiver.html), [`jar`](./apidocs/index.html?org/codehaus/plexus/archiver/jar/JarUnArchiver.html), [`nar`](./apidocs/index.html?org/codehaus/plexus/archiver/nar/NarUnArchiver.html), [`par`](./apidocs/index.html?org/codehaus/plexus/archiver/par/ParUnArchiver.html), [`rar`](./apidocs/index.html?org/codehaus/plexus/archiver/rar/RarUnArchiver.html), [`sar`](./apidocs/index.html?org/codehaus/plexus/archiver/sar/SarUnArchiver.html), [`swc`](./apidocs/index.html?org/codehaus/plexus/archiver/swc/SwcUnArchiver.html), [`war`](./apidocs/index.html?org/codehaus/plexus/archiver/war/WarUnArchiver.html)\), [`zst`](./apidocs/index.html?org/codehaus/plexus/archiver/zstd/ZstdUnArchiver.html) | +## What is Plexus Archiver? + +Plexus Archiver is a high-level Java API for creating and extracting archives (ZIP, JAR, TAR, etc.). It provides a simple, unified interface for working with various archive formats, abstracting away the low-level details of archive manipulation. + +## Comparison to Apache Commons Compress + +Plexus Archiver builds on top of [Apache Commons Compress](https://commons.apache.org/proper/commons-compress/) (since version 2.5) and provides additional capabilities: + +### Apache Commons Compress + +Commons Compress is a low-level library that provides: +- Direct access to archive formats and compression algorithms +- Fine-grained control over archive entries and their attributes +- Support for a wide range of archive formats (ZIP, TAR, AR, CPIO, etc.) +- Streaming API for memory-efficient processing + +### Plexus Archiver + +Plexus Archiver is a higher-level abstraction layer that adds: + +**Simplified API**: Easy-to-use builder-style interface for common archiving tasks without dealing with low-level stream handling. + +**Advanced Features**: +- File selectors and filtering capabilities +- Automatic handling of file permissions and attributes +- Built-in support for directory scanning with includes/excludes patterns +- Reproducible builds support (configurable timestamps and ordering) +- Duplicate handling strategies +- File mappers for transforming entry names during archiving/unarchiving +- Protection against ZIP bombs (configurable output size limits) + +**Build Tool Integration**: Designed for integration with build tools like Maven, with support for: +- Modular JAR creation (Java 9+ modules) +- Manifest generation and customization +- Archive finalizers for post-processing + +**Dependency Injection Ready**: Includes JSR-330 annotations for easy integration with dependency injection frameworks. + +### When to Use Which? + +**Use Apache Commons Compress when:** +- You need fine-grained control over archive format details +- You're working with streaming data or large archives +- You need to support specialized or uncommon archive formats +- Memory efficiency is critical + +**Use Plexus Archiver when:** +- You want a simple, declarative API for common archiving tasks +- You're building a Maven plugin or similar build tool +- You need reproducible builds with consistent archive ordering +- You want built-in file filtering and selection capabilities +- You need to create modular JARs or other specialized Java archives From d706569ca79546900c7bab635dafe1b29576b539 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Wed, 8 Oct 2025 17:59:18 +0200 Subject: [PATCH 14/14] [maven-release-plugin] prepare release plexus-archiver-4.10.3 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index cb60fc6f..c7133956 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ plexus-archiver - 4.10.3-SNAPSHOT + 4.10.3 Plexus Archiver Component https://codehaus-plexus.github.io/plexus-archiver/ @@ -30,7 +30,7 @@ scm:git:https://github.com/codehaus-plexus/plexus-archiver.git scm:git:https://github.com/codehaus-plexus/plexus-archiver.git - HEAD + plexus-archiver-4.10.3 https://github.com/codehaus-plexus/plexus-archiver/tree/${project.scm.tag}/ @@ -47,7 +47,7 @@ 1.7.36 0.9.0.M4 - 2025-09-30T22:11:30Z + 2025-10-08T15:58:51Z