【发布时间】:2023-04-06 18:02:01
【问题描述】:
这应该很容易,但我遇到了来自 maven-install 插件的奇怪行为。
我需要将一些常见的依赖重新打包到我的项目中以避免依赖冲突。为此,我使用了配置了重定位的 shade 插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>do_shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<shadedArtifactAttached>false</shadedArtifactAttached>
<createSourcesJar>true</createSourcesJar>
<relocations>
<relocation>
<pattern>com.google.common</pattern>
<shadedPattern>com.myproject.google.common</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons</pattern>
<shadedPattern>com.myproject.commons</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
shade 插件正确地完成了它的工作,并产生了阴影工件 com.myproject-myproject-.jar 和减少了依赖的 pom 文件。 但随后安装插件安装了原始工件(没有依赖项)而不是阴影部分。
此外,在安装插件问题之前,我的 CI 服务器 (jenkins) 构建了项目并正确发布了阴影工件和依赖关系减少 pom 到 nexus 存储库 (!!)。所以现在我从nexus下载工件,我的本地存储库中有正确的jar,但是如果我使用安装插件,jar就不会好。
有没有人遇到过类似的问题?有谁知道怎么解决??
【问题讨论】:
标签: maven maven-shade-plugin maven-install-plugin