Using a shaded jar as a shading dependency in the original project

My project has a dependency on another bank-shaded project. This other project uses a shadow plugin to move all classes in a package a.b.c

for some artifact A version 1

to shaded.a.b.c

.

My project also uses artifact A but version 2

. When I build my project, I see that the import statement for a.b.c.d

(which I expect to receive from artifact A version 2

and is not present in artifact A version 1

) in my project has changed to shaded.a.b.c.d

. I am not using shading in my original project, however I can see that the shading plugin in the dependency bar is causing the shading in my original project.

Is this the expected behavior? Is there a way that we can stop this transient shading?

Shadow plugin of another project:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.3</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <shadedArtifactAttached>false</shadedArtifactAttached>
        <outputDirectory>${project.build.directory}</outputDirectory>
        <createDependencyReducedPom>true</createDependencyReducedPom>
        <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
        <shadeSourcesContent>true</shadeSourcesContent>
        <relocations>
            <relocation>
                <pattern>a.b.c</pattern>
                <shadedPattern>shaded.a.b.c</shadedPattern>
            </relocation>
        </relocations>
    </configuration>
</plugin>

      

+3


source to share


1 answer


Disabled is artifact A

also defined as a dependency (not dependency management) in the parent pom of the project. The "other project" was built first with maven, which was shaded artifact A

, and this shaded artifact (still not sure why) was then used by all the other child project that came after this project.



Reconfigure dependencies to manage dependencies in the parent project and define the corresponding dependencies in the child project.

0


source







All Articles