Skip to content

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

Open
elharo wants to merge 5 commits into
masterfrom
fix/skipClassPathModification
Open

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

Conversation

@elharo

@elharo elharo commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Changes

When skipClassPathModification=true:

  • Skip modifying classpath entries in the manifest
  • BUT still write the original manifest file unchanged (not skip writing entirely)

This ensures manifests are left completely untouched when skipping.
Fixes #180

elharo and others added 5 commits July 28, 2026 17:32
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
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 #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 manifest handling when skipClassPathModification=true so Class-Path entries aren’t modified while still ensuring a manifest is written out, addressing the “empty Class-Path” regression referenced in #180.

Changes:

  • Update manifest Class-Path handling to skip classpath edits when skipClassPathModification is enabled, while still writing the manifest.
  • Update integration tests/expectations for Class-Path elements in affected IT scenarios.
  • Adjust expected Class-Path entries for skinny-wars javaee5 verification.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/main/java/org/apache/maven/plugins/ear/EarMojo.java Adjusts logic for when manifest classpath is modified and ensures manifest gets written even when skipping modification.
src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java Updates expected Class-Path entries in ITs to match the new behavior/inputs.
src/it/skinny-wars-javaee5/verify.bsh Updates expected manifest Class-Path element for a skinny-wars IT verification.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 667 to 670
final String moduleLibDir = module.getLibDir();
if (!((moduleLibDir == null) || skinnyModules || (skinnyWars && module instanceof WebModule))) {
if (!(skinnyModules || (skinnyWars && (module instanceof WebModule || moduleLibDir == null)))) {
return;
}
Comment on lines 716 to 720
if (classPath != null) {
classPathExists = true;
classPathElements.addAll(Arrays.asList(classPath.getValue().split(" ")));
} else {
classPathExists = false;
classPath = new Attribute("Class-Path", "");
}
Comment on lines +805 to +816
// Write the manifest to disk, preserve timestamp
FileTime lastModifiedTime = Files.getLastModifiedTime(manifestFile);
try (BufferedWriter writer = Files.newBufferedWriter(
manifestFile,
StandardCharsets.UTF_8,
StandardOpenOption.WRITE,
StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING)) {
mf.write(writer);
}
Files.setLastModifiedTime(manifestFile, lastModifiedTime);
removeFromOutdatedResources(manifestFile, outdatedResources);
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