Skip to content

[MSHADE-419] Restore project.getFile() after dependency-reduced POM creation when shadedArtifactAttached=true - #828

Open
elharo wants to merge 1 commit into
apache:masterfrom
elharo:fix-MSHADE-419
Open

[MSHADE-419] Restore project.getFile() after dependency-reduced POM creation when shadedArtifactAttached=true#828
elharo wants to merge 1 commit into
apache:masterfrom
elharo:fix-MSHADE-419

Conversation

@elharo

@elharo elharo commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Problem

When shadedArtifactAttached=true, the original (non-shaded) artifact remains the main artifact of the project. The POM used for this main artifact comes from project.getFile(). After createDependencyReducedPom() calls project.setFile(dependencyReducedPomLocation), project.getFile() points to the dependency-reduced POM instead of the original pom.xml.

This causes maven-install-plugin and maven-deploy-plugin to use the dependency-reduced POM (which has compile dependencies removed) as the project's POM. Downstream projects depending on the library lose transitive compile dependencies.

Introduced/changed by MSHADE-321 (commit 6ea8543). The issue manifests specifically when:

  • shadedArtifactAttached=true (so the original artifact is retained)
  • createDependencyReducedPom=true (default)
  • Compile dependencies exist that get shaded and removed from the DRP

Fix

Save project.getFile() before calling createDependencyReducedPom() and restore it afterward in ShadeMojo.execute(). This ensures project.getFile() continues to point to the original pom.xml, so install/deploy use the correct POM with all compile dependencies.

Integration Test

MSHADE-419_attachedDepPom: Configures shade with shadedArtifactAttached=true and dependencyReducedPomLocation in target/, then verifies via maven-help-plugin:evaluate that ${project.file} still points to the original pom.xml after shading.

  • Without fix: test fails (project.file is dependency-reduced-pom.xml)
  • With fix: test passes (project.file is pom.xml)

All 72 unit tests pass.

Fixes #711

…reation

When shadedArtifactAttached=true, the original artifact remains the main
artifact and its POM comes from project.getFile(). If project.getFile()
points to the dependency-reduced POM (which has compile dependencies
removed), then install/deploy will use the reduced POM instead of the
original one, causing downstream projects to lose transitive compile
dependencies.

Save and restore the original project file around DRP creation to ensure
the correct POM is used for the main artifact.

Includes integration test MSHADE-419_attachedDepPom that verifies
project.file still points to the original pom.xml after shading with
shadedArtifactAttached=true.
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.

[MSHADE-419] Shade plugin causes pom to be created without compile dependencies

1 participant