繁体   English   中英

使用着色jar作为依赖项导致原始项目中的着色

[英]Using shaded jar as dependency causing shading in original project

我的项目依赖于另一个项目的阴影jar。 另一个项目是使用shade插件将包abc所有类重新定位到一些artifact A version 1shaded.abc

我的项目也使用此artifact A but version 2 当我构建我的项目时,我看到我的项目中的abcd的import语句(我希望它来自artifact A version 2并且在artifact A version 1不存在)已经改为shaded.abcd 我在原始项目中没有使用着色,但是我看到依赖jar中的着色插件导致了原始项目中的着色。

这是预期的行为吗? 有没有办法阻止这种传递着色?

其他项目的Shade插件:

<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>

结果artifact A也被定义为项目父pom中的依赖关系(而不是依赖关系管理)。 “其他项目”首先由maven构建,这是阴影artifact A然后这个阴影工件(仍然不知道为什么)被这个项目之后的所有其他子项目使用。

将依赖项移动到父项目中的依赖项管理,并在子项目中定义相应的依赖项来修复它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM