我正在尝试覆盖maven的部署插件,并在我的某些项目中获得以下错误,而不是其他项目:
Execution default-deploy of goal org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy failed: Cannot add two different pieces of metadata for:
这是我的插件定义:
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<pomFile>target/modified-pom-replacePomPlaceholder/modified-pom/pom.xml</pomFile>
</configuration>
</execution>
</executions>
</plugin>
也尝试了同样的效果:
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<pomFile>target/modified-pom-replacePomPlaceholder/modified-pom/pom.xml</pomFile>
</configuration>
</plugin>
有时候为什么会失败?
答案 0 :(得分:3)
请勿覆盖&#39; default-deploy&#39;。取消激活并编写自己的:
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
<execution>
<id>my-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
...
</execution>
答案 1 :(得分:0)
也许有点晚了,但这是我的假设:
运行带有调试输出的maven,例如 mvn clean deploy -X ,然后检查调试输出,尤其是以下两行:
[DEBUG] (f) pomFile = /home/rotscher/projects/localswap/localswap-web/target/pom.xml
[DEBUG] (f) project = MavenProject: ch.rotscher.localswap:localswap-web:1 @ /home/rotscher/projects/localswap/localswap-web/target/pom.xml
路径应该是等于(根据java.io.File.equals)。 所以,我猜你的解决方案可能是用 $ {basedir} 配置 pomFile 的路径:
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<pomFile>${basedir}/target/modified-pom-replacePomPlaceholder/modified-pom/pom.xml</pomFile>
</configuration>
</plugin>