一年前发了maven release插件可以直接升级版本 deploy 相关的使用说明,最近再次使用,发现报错,定位问题后,发现是其中的一个jar的source包deploy两次, 首次成功后第二次失败, 而稳定版本重复部署nexus仓库会拒绝接收第二次部署,导致失败。
解决方案:
查询 : Maven deploy upload sources twice 相关方案,通过
mvn -Prelease-profile help:effective-pom
确定当前部署jar的pom,找到
maven-source-plugin
如下配置:
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
如果仅有上述配置,且maven版本在3.5及以下, 不会报错,
如果版本较高,则需要改成如下配置
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
即可。
如果存在多余的execution,则需要删除。
原因:
maven的source 插件中,默认包含 jar-no-fork, 如果指定为jar,则会同时执行jar-no-fork, 导致source执行两次,进而deploy两次,导致失败终止。
参考
Peter Lynch: Maven: How to prevent generate-sources phase executing twice
Apache Maven Source Plugin – source:jar-no-fork
[Solved] Maven maven-deploy-plugin always upload twice - Local Coder