Skip to content

[MEAR-305] Fix skipClassPathModification setting Class-Path empty - #539

Closed
elharo wants to merge 5 commits into
apache:masterfrom
elharo:fix/skipClassPathModification
Closed

[MEAR-305] Fix skipClassPathModification setting Class-Path empty#539
elharo wants to merge 5 commits into
apache:masterfrom
elharo:fix/skipClassPathModification

Conversation

@elharo

@elharo elharo commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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

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
@elharo
elharo requested a review from Copilot July 28, 2026 17:37
@elharo elharo changed the title MEAR-305: Fix skipClassPathModification setting Class-Path empty [MEAR-305] Fix skipClassPathModification setting Class-Path empty Jul 28, 2026
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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-Path mutation logic in EarMojo#changeManifestClasspath behind !skipClassPathModification.
  • Update integration tests to assert unchanged/original Class-Path entries 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
elharo marked this pull request as draft July 28, 2026 20:31
@elharo

elharo commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Closed in favor of #541 which fixes the remaining issue with manifest persistence.

@elharo elharo closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MEAR-305] skipClassPathModification sets Class-Path empty

2 participants