You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "elharo (via GitHub)" <gi...@apache.org> on 2026/07/26 19:22:27 UTC
[PR] [MWAR-446] Add compressLibs option to store dependency JARs in STORED mode [maven-war-plugin]
elharo opened a new pull request, #640:
URL: https://github.com/apache/maven-war-plugin/pull/640
Fixes #526
Add a new `compressLibs` parameter (default: `true`) to the maven-war-plugin. When set to `false`, dependency library JARs in `WEB-INF/lib/` are stored in the WAR archive using STORED mode (no compression) instead of DEFLATED mode.
**Why:** JAR files are already compressed internally. Re-compressing them when adding to a WAR provides negligible size reduction but adds CPU overhead during both WAR creation and servlet container startup (the JARs must be decompressed before they can be loaded). Storing them in STORED mode eliminates this redundant compression.
**Implementation:** Creates an `UncompressedLibsWarArchiver` subclass of `WarArchiver` that overrides `zipFile()` to temporarily disable compression for entries under `WEB-INF/lib/`, while all other entries (classes, resources, web.xml, etc.) continue to be compressed normally.
**Usage:**
```xml
<configuration>
<compressLibs>false</compressLibs>
</configuration>
```
**Changes:**
- `AbstractWarMojo.java`: Added `compressLibs` parameter with getter
- `WarMojo.java`: Added `UncompressedLibsWarArchiver` inner class; `getWarArchiver()` returns it when `compressLibs=false`
- Integration test `MWAR-446` verifying JARs are STORED and other entries are DEFLATED
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MWAR-446] Add compressLibs option to store dependency JARs in STORED mode [maven-war-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #640:
URL: https://github.com/apache/maven-war-plugin/pull/640#discussion_r3653242803
##########
src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java:
##########
@@ -311,6 +311,18 @@ public abstract class AbstractWarMojo extends AbstractMojo {
@Parameter(defaultValue = "true")
private boolean recompressZippedFiles;
+ /**
+ * Whether dependency libraries (i.e. JAR files in {@code WEB-INF/lib/}) should be compressed (DEFLATED) when
Review Comment:
remove i.e.,
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MWAR-446] Add compressLibs option to store dependency JARs in STORED mode [maven-war-plugin]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #640:
URL: https://github.com/apache/maven-war-plugin/pull/640#discussion_r3653245655
##########
src/main/java/org/apache/maven/plugins/war/WarMojo.java:
##########
@@ -386,12 +388,53 @@ public void setWarName(String warName) {
public WarArchiver getWarArchiver() {
try {
- return (WarArchiver) getArchiverManager().getArchiver("war");
+ if (isCompressLibs()) {
+ return (WarArchiver) getArchiverManager().getArchiver("war");
+ } else {
+ return new UncompressedLibsWarArchiver();
+ }
Review Comment:
When compressLibs=false, getWarArchiver() bypasses ArchiverManager and instantiates WarArchiver directly (new UncompressedLibsWarArchiver()). In this plugin, archivers are normally obtained from ArchiverManager (e.g. AbstractWarMojo looks up the JarArchiver via archiverManager.getArchiver("jar")), which ensures the container-configured archiver instance (logger, Plexus/Sisu component setup, defaults) is used. Creating the archiver with `new` risks missing that setup and behaving differently from the standard WAR archiver.
##########
src/main/java/org/apache/maven/plugins/war/WarMojo.java:
##########
@@ -386,12 +388,53 @@ public void setWarName(String warName) {
public WarArchiver getWarArchiver() {
try {
- return (WarArchiver) getArchiverManager().getArchiver("war");
+ if (isCompressLibs()) {
+ return (WarArchiver) getArchiverManager().getArchiver("war");
+ } else {
+ return new UncompressedLibsWarArchiver();
+ }
} catch (NoSuchArchiverException e) {
throw new IllegalStateException("Cannot find war archiver", e);
}
}
+ /**
+ * A {@link WarArchiver} subclass that stores dependency library JARs ({@code WEB-INF/lib/*.jar})
+ * in STORED mode (uncompressed) instead of DEFLATED mode, while still compressing all other entries.
+ * This improves servlet container startup time since the already-compressed JARs are not
+ * decompressed and recompressed during WAR creation and extraction.
+ */
+ private static class UncompressedLibsWarArchiver extends WarArchiver {
+
+ UncompressedLibsWarArchiver() {
+ super();
+ }
+
+ @Override
+ protected void zipFile(
+ InputStreamSupplier in,
+ ConcurrentJarCreator zOut,
+ String vPath,
+ long lastModified,
+ File fromArchive,
+ int mode,
+ String symlinkDestination,
+ boolean addInParallel)
+ throws IOException, ArchiverException {
+ if (vPath.startsWith("WEB-INF/lib/") && !vPath.endsWith("/")) {
Review Comment:
The override disables compression for *any* non-directory entry under WEB-INF/lib/, but the parameter/Javadoc describe affecting dependency JARs (WEB-INF/lib/*.jar). As written, additional resources placed under WEB-INF/lib/ (e.g., native libraries or metadata files) would also be forced to STORED, which is a behavior change beyond the documented scope.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org