3

我正在尝试覆盖 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>

知道为什么有时会失败吗?

4

2 回答 2

3

不要覆盖“默认部署”。停用它并编写自己的:

<execution>
  <id>default-deploy</id>
  <phase>none</phase>
</execution>
<execution>
  <id>my-deploy</id>
  <phase>deploy</phase>
  <goals>
    <goal>deploy</goal>
  </goals>
  ...
</execution>
于 2014-12-08T15:20:40.980 回答
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>
于 2013-09-24T21:21:00.300 回答