[MEAR-305] Fix skipClassPathModification setting Class-Path empty - #539
Closed
elharo wants to merge 5 commits into
Closed
[MEAR-305] Fix skipClassPathModification setting Class-Path empty#539elharo wants to merge 5 commits into
elharo wants to merge 5 commits into
Conversation
When skipClassPathModification is true, the plugin should leave module manifests completely untouched. Previously, existing Class-Path entries were still updated/removed and the modified manifest was written back, potentially setting Class-Path to empty. Now all Class-Path modification logic is wrapped in a check for skipClassPathModification. Fixes apache#180
Restore v3.1.0 behavior where changeManifestClasspath is only invoked when skinnyWars or skinnyModules is active. Previously, the guard condition allowed modules with null libDir (like EJB modules) to proceed even without any skinny feature enabled, causing unnecessary Class-Path modification and potentially removing EJB client JARs from WAR modules. The guard now requires skinnyModules or (skinnyWars AND (WebModule or null-libDir module)) to proceed. Fixes apache#179
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adjusts the EAR plugin behavior so skipClassPathModification=true prevents unintended Class-Path updates (including being rewritten as empty), aligning with MEAR-305 / #180.
Changes:
- Wrap
Class-Pathmutation logic inEarMojo#changeManifestClasspathbehind!skipClassPathModification. - Update integration tests to assert unchanged/original
Class-Pathentries when skipping modification. - Update IT verification expectations for the skinny-wars JavaEE5 scenario.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/main/java/org/apache/maven/plugins/ear/EarMojo.java | Gates Class-Path mutation/removal logic when skipClassPathModification is enabled. |
| src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java | Updates expected classpath entries in IT testProject090 to reflect “no modification” behavior. |
| src/it/skinny-wars-javaee5/verify.bsh | Updates expected Class-Path element string to match the new “do not rewrite” behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+779
to
808
| if (!skipClassPathModification) { | ||
| final boolean forceClassPathModification = | ||
| javaEEVersion.lt(JavaEEVersion.FIVE) || defaultLibBundleDir == null; | ||
| final boolean classPathExtension = !skipClassPathModification || forceClassPathModification; | ||
| for (EarModule otherModule : getModules()) { | ||
| if (module.equals(otherModule)) { | ||
| continue; | ||
| } | ||
| final int moduleClassPathIndex = findModuleInClassPathElements(classPathElements, otherModule); | ||
| if (moduleClassPathIndex != -1) { | ||
| if (otherModule.isClassPathItem()) { | ||
| classPathElements.set(moduleClassPathIndex, otherModule.getUri()); | ||
| } else { | ||
| classPathElements.remove(moduleClassPathIndex); | ||
| } | ||
| } else if (otherModule.isClassPathItem() && classPathExtension) { | ||
| classPathElements.add(otherModule.getUri()); | ||
| } | ||
| } else if (otherModule.isClassPathItem() && classPathExtension) { | ||
| classPathElements.add(otherModule.getUri()); | ||
| } | ||
| } | ||
|
|
||
| // Remove provided modules from classpath | ||
| for (EarModule otherModule : getProvidedEarModules()) { | ||
| final int moduleClassPathIndex = findModuleInClassPathElements(classPathElements, otherModule); | ||
| if (moduleClassPathIndex != -1) { | ||
| classPathElements.remove(moduleClassPathIndex); | ||
| // Remove provided modules from classpath | ||
| for (EarModule otherModule : getProvidedEarModules()) { | ||
| final int moduleClassPathIndex = findModuleInClassPathElements(classPathElements, otherModule); | ||
| if (moduleClassPathIndex != -1) { | ||
| classPathElements.remove(moduleClassPathIndex); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (!skipClassPathModification || !classPathElements.isEmpty() || classPathExists) { | ||
| classPath.setValue(StringUtils.join(classPathElements.iterator(), " ")); | ||
| mf.getMainSection().addConfiguredAttribute(classPath); |
Comment on lines
+780
to
+782
| final boolean forceClassPathModification = | ||
| javaEEVersion.lt(JavaEEVersion.FIVE) || defaultLibBundleDir == null; | ||
| final boolean classPathExtension = !skipClassPathModification || forceClassPathModification; |
elharo
marked this pull request as draft
July 28, 2026 20:31
Contributor
Author
|
Closed in favor of #541 which fixes the remaining issue with manifest persistence. |
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.
When skipClassPathModification is true, the plugin should leave module manifests completely untouched. Previously, existing Class-Path entries were still updated/removed and the modified manifest was written back, potentially setting Class-Path to empty. Now all Class-Path modification logic is wrapped in a check for skipClassPathModification.
Fixes #180