3

My project has a dependency on another project's shaded jar. This other project is using shade plugin to relocate all classes in package a.b.c for some artifact A version 1 to shaded.a.b.c.

My project also uses this artifact A but version 2. When I build my project, I see the import statement for a.b.c.d (which I expect to come from artifact A version 2 and is not present in artifact A version 1) in my project have been to changed to shaded.a.b.c.d. I am not using shading in my original project, however I see the shading plugin in dependency jar is causing the shading in my original project.

Is this expected behaviour? Is there a way through which we can stop this transitive shading?

Shade plugin of other 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>
Naved Alam
  • 827
  • 9
  • 25

1 Answers1

0

Turns out artifact A was also defined as dependency (not dependency management) in project parent pom. The 'other project' was getting build first by maven which was shading artifact A and this shaded artifact (still dont know why) was then used by all other child project which came after this project.

Moving the dependencies to dependency management in parent project and defining respective dependencies in child project fixed it.

Naved Alam
  • 827
  • 9
  • 25