[MWAR-446] Add compressLibs option to store dependency JARs in STORED mode - #640
Open
elharo wants to merge 2 commits into
Open
[MWAR-446] Add compressLibs option to store dependency JARs in STORED mode#640elharo wants to merge 2 commits into
elharo wants to merge 2 commits into
Conversation
elharo
commented
Jul 26, 2026
| private boolean recompressZippedFiles; | ||
|
|
||
| /** | ||
| * Whether dependency libraries (i.e. JAR files in {@code WEB-INF/lib/}) should be compressed (DEFLATED) when |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new compressLibs configuration knob to the Maven WAR Plugin to optionally store WEB-INF/lib dependency JARs using STORED (no compression) to avoid redundant compression overhead, along with an integration test to validate mixed STORED/DEFLATED output.
Changes:
- Introduce
compressLibsparameter (defaulttrue) to control compression of dependency JARs underWEB-INF/lib/. - Add a
WarArchiversubclass that conditionally disables compression for library entries while keeping other WAR entries compressed. - Add IT
MWAR-446verifyingWEB-INF/lib/*.jarare STORED and a normal resource is DEFLATED.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/org/apache/maven/plugins/war/WarMojo.java | Chooses a custom archiver when compressLibs=false and overrides zip behavior for WEB-INF/lib/. |
| src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java | Adds the compressLibs parameter and accessor. |
| src/it/MWAR-446/pom.xml | New integration test project enabling compressLibs=false. |
| src/it/MWAR-446/verify.groovy | Verifies STORED vs DEFLATED methods inside the produced WAR. |
| src/it/MWAR-446/src/main/webapp/index.html | Simple resource to assert DEFLATED behavior remains for non-lib entries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
389
to
+395
| public WarArchiver getWarArchiver() { | ||
| try { | ||
| return (WarArchiver) getArchiverManager().getArchiver("war"); | ||
| if (isCompressLibs()) { | ||
| return (WarArchiver) getArchiverManager().getArchiver("war"); | ||
| } else { | ||
| return new UncompressedLibsWarArchiver(); | ||
| } |
| String symlinkDestination, | ||
| boolean addInParallel) | ||
| throws IOException, ArchiverException { | ||
| if (vPath.startsWith("WEB-INF/lib/") && !vPath.endsWith("/")) { |
elharo
force-pushed
the
MWAR-446-compress-libs
branch
from
July 26, 2026 19:27
a1579bc to
0e9945b
Compare
… mode Add a new compressLibs parameter (default: true) that allows storing dependency library JARs in WEB-INF/lib/ using STORED compression mode instead of DEFLATED. This improves servlet container startup time since already-compressed JARs don't need to be decompressed during WAR extraction, with negligible impact on overall WAR file size. Implements: apache#526
elharo
force-pushed
the
MWAR-446-compress-libs
branch
from
July 26, 2026 19:29
0e9945b to
4d38e06
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #526
Add a new
compressLibsparameter (default:true) to the maven-war-plugin. When set tofalse, dependency library JARs inWEB-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
UncompressedLibsWarArchiversubclass ofWarArchiverthat overrideszipFile()to temporarily disable compression for entries underWEB-INF/lib/, while all other entries (classes, resources, web.xml, etc.) continue to be compressed normally.Usage:
Changes:
AbstractWarMojo.java: AddedcompressLibsparameter with getterWarMojo.java: AddedUncompressedLibsWarArchiverinner class;getWarArchiver()returns it whencompressLibs=falseMWAR-446verifying JARs are STORED and other entries are DEFLATED