简体   繁体   English

mvn package verify 导致 maven-shade-plugin 执行两次

[英]mvn package verify causes the maven-shade-plugin to execute twice

I use the maven-shade-plugin to relocate a dependency in order to avoid classpath conflicts in my project.我使用maven-shade-plugin重新定位依赖项,以避免项目中的类路径冲突。 It all works well when running "mvn install", but when I run "mvn install" TWO times, it will fail the second time.运行“mvn install”时一切正常,但是当我运行“mvn install”两次时,第二次会失败。 I get errors like:我收到如下错误:

Error creating shaded jar: duplicate entry: META-INF/...创建阴影 jar 时出错:重复条目:META-INF/...

This is due to the having this transformer:这是由于具有此变压器:

<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"/>

Not sure why it fails.不知道为什么会失败。 It could be a bug.这可能是一个错误。 Anyway, I can't run the plugin twice without cleaning up in-between.无论如何,如果不进行中间清理,我就无法运行该插件两次。

Now the greater problem is that during our CI build, we run "mvn package verify" .现在更大的问题是,在我们的 CI 构建期间,我们运行“mvn package verify” This causes the Shade plugin to run twice in the build.这会导致 Shade 插件在构建中运行两次 And of course, the second time it fails.当然,第二次失败了。

I've looked at the effective pom and didn't see anything unusual.我查看了有效的 pom 并没有发现任何异常。 The plugin is not repeated twice.该插件不会重复两次。

Is there some way I could perhaps exclude the plugin from running during the verify phase?有什么方法可以在验证阶段排除插件运行?

It is not sensible to run mvn package verify .运行mvn package verify是不明智的。

Just run mvn verify and you'll be fine.只需运行mvn verify就可以了。

verify already includes package . verify已经包含package

I solved the issue.我解决了这个问题。 Looks like the maven-source-plugin was interfering with the shade plugin.看起来maven-source-plugin干扰了阴影插件。 I was using the source plugin to provide the source code of the relocated packages.我正在使用源插件来提供重定位包的源代码。 The goal "aggregate" was somehow causing the build to fail.目标“聚合”以某种方式导致构建失败。 After removing the aggregate goal, I don't have the issue anymore删除总目标后,我不再有问题了

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

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