Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSHADE-419] Add an integration test #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gnodet
Copy link
Contributor

@gnodet gnodet commented Oct 22, 2022

JIRA issue: https://issues.apache.org/jira/browse/MSHADE-419

Shade plugin causes pom to be created without compile dependencies

IT extracted from #149

===============

The problem was introduced by MSHADE-321 in 3.3.0 because before, the createDependencyReducedPom method was only ever called when shadedArtifactAttached is false.

The createDependencyReducedPom method not only writes the dependency reduced pom file but also modifies the current project to use it as replacement for its original pom.
This has an effect on all maven build logic being executed afterwards.

Thus, in multi module builds, when a module attaches a shaded jar, its non-shaded artifact no longer contains transitive dependencies when used from other modules, even though the pom in its jar still declares them.

…om when shadedArtifactAttached

The problem was introduced by MSHADE-321 in 3.3.0 because before,
the `createDependencyReducedPom` method was only ever called when
`shadedArtifactAttached` is false.

The `createDependencyReducedPom` method not only writes the dependency
reduced pom file but also modifies the current project to use it as
replacement for its original pom.
This has an effect on all maven build logic being executed afterwards.

Thus, in multi module builds, when a module attaches a shaded jar, its
non-shaded artifact no longer contains transitive dependencies when used
from other modules, even though the pom in its jar still declares them.

# Conflicts:
#	src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
@gnodet gnodet changed the title [MSHADE-419] Add an IT for MSHADE-419 [MSHADE-419] Add an integration test Feb 16, 2023
}

JarFile jarFile = null
try
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can use try with resources here

String jarPomPath = "META-INF/maven/org.apache.maven.its.shade.cdrp-mm/mshade-419-impl/pom.xml"
String apiDependencyString = "<artifactId>mshade-419-api</artifactId>"

String mainPomFileContent = FileUtils.fileRead( new File( basedir, "impl/pom.xml" ), "UTF-8" )
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use the Apache Commons IO version instead?

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.

3 participants