Van*_*ran 58 java nexus maven maven-release-plugin
我们正在使用hudson上的maven发布插件并尝试自动执行发布过程.发布:准备工作正常.当我们尝试执行release:perform时,它会失败,因为它会尝试将源工件两次上传到存储库.
我试过的东西,
它仍然吐出这个错误.
[INFO] [DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[INFO] [DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[INFO] [DEBUG] Checking for pre-existing User-Agent configuration.
[INFO] [DEBUG] Adding User-Agent configuration.
[INFO] [DEBUG] not adding permissions to wagon connection
[INFO] Uploading: http://xx.xx.xx.xx:8081/nexus/content/repositories/releases//com/yyy/xxx/hhh/hhh-hhh/1.9.40/hhh-hhh-1.9.40-sources.jar
[INFO] 57K uploaded (xxx-xxx-1.9.40-sources.jar)
[INFO] [DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[INFO] [DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[INFO] [DEBUG] Checking for pre-existing User-Agent configuration.
[INFO] [DEBUG] Adding User-Agent configuration.
[INFO] [DEBUG] not adding permissions to wagon connection
[INFO] Uploading: http://xx.xxx.xx.xx:8081/nexus/content/repositories/releases//com/xxx/xxxx/xxx/xxx-xxx/1.9.40/xxx-xxx-1.9.40-sources.jar
[INFO] [DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] BUILD ERROR
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Error deploying artifact: Authorization failed: Access denied to: http://xx.xxx.xx.xx:8081/nexus/content/repositories/releases/com/xxx/xxx/xxx/xxx-config/1.9.40/xxx-xxx-1.9.40-sources.jar
Run Code Online (Sandbox Code Playgroud)
任何有关这方面的帮助将非常感谢.
Bae*_*Bae 68
试试跑步mvn -Prelease-profile help:effective-pom.你会发现你有两个执行部分maven-source-plugin
输出看起来像这样:
Run Code Online (Sandbox Code Playgroud)<plugin> <artifactId>maven-source-plugin</artifactId> <version>2.0.4</version> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> <execution> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin>
要解决此问题,请查找您使用过的所有位置maven-source-plugin,并确保使用"id"attach-sources以使其与发布配置文件相同.然后这些部分将合并.
最佳实践说,为了获得一致性,您需要在build> pluginManagement中的项目的根POM中配置它,而不是在您的子poms中.在子pom中,您只需在build> plugins中指定要使用maven-source-plugin,但不提供执行.
在房间pom.xml:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<!-- This id must match the -Prelease-profile id value or else sources will be "uploaded" twice, which causes Nexus to fail -->
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Run Code Online (Sandbox Code Playgroud)
在子pom.xml中:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
chr*_*own 26
我知道这个问题已经过时了,但谷歌今天打了#1,所以我会添加适合最近版本的maven 3的答案.
症状是在使用某些版本的maven 3进行发布构建时,源和javadoc jar被部署两次.如果您使用maven将工件部署到Sonatype Nexus存储库,该存储库仅允许上传一次发布工件(是完全合理的行为),当第二次上传尝试被拒绝时,构建失败.哎呀!
Maven版本3.2.3至3.3.9有错误 - 请参阅https://issues.apache.org/jira/browse/MNG-5868和https://issues.apache.org/jira/browse/MNG-5939.这些版本在执行发布时会生成并部署两次源和javadoc jar.
如果我正确地阅读了Maven问题跟踪器,那么在撰写本文时,这些错误都没有安排进行修复(烧毁的3.4.0版本可能会影响这些).
我的简单解决方法是回到Maven版本3.2.1,而不是对我的pom进行复杂的调整.
刚刚遇到同样的问题,我分析了一下.mvn release:perform评估release.properties文件,然后检出临时目录中的标记并调用类似的东西
/usr/bin/mvn -D maven.repo.local=... -s /tmp/release-settings5747060794.xml
-D performRelease=true -P set-envs,maven,set-envs deploy
Run Code Online (Sandbox Code Playgroud)
我试图重现这一点 - 手动检查生成的标签release:prepare并调用它:
mvn -D performRelease=true -P set-envs,maven,set-envs deploy
Run Code Online (Sandbox Code Playgroud)
我得到了相同的结果:它试图上传-sources.jar两次.
正如注释中的qualidafial所指出的那样,设置performRelease=false会忽略同一文件的两个附件之一.
我真的不知道部署插件(或任何其他插件)如何使用此属性.
我们可以将此参数作为配置提供给maven-relase-plugin:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<useReleaseProfile>false</useReleaseProfile>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
我现在将<useReleaseProfile>false</useReleaseProfile>行添加到所有POM中,看起来现在发布没有错误消息.
我一直在努力解决这个问题,终于能够在我们的基础设施中解决它。这里的答案对我没有帮助,因为我们没有多次执行源插件目标,而且配置对我们来说似乎很好。
我们错过的是将源插件的执行绑定到一个阶段。扩展 Bae 的示例,包括<phase>install</phase>执行的行为我们解决了问题:
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>install</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我怀疑的解决办法在于这个答案在这里; 不同的插件似乎正在调用 jar 目标/附加源执行。通过将我们的执行绑定到某个阶段,我们强制我们的插件只在这个阶段运行。
这发生在我跑步时
mvn install deploy
Run Code Online (Sandbox Code Playgroud)
我通过运行避免了这个问题
mvn deploy
Run Code Online (Sandbox Code Playgroud)
(这意味着安装)。在我的例子中,只有一个工件被尝试上传两次,这是一个次要工件(maven-jar-plugin 设置为除了由 default-jar 执行构建的 jar 之外,还构建一个辅助 jar)。
| 归档时间: |
|
| 查看次数: |
28296 次 |
| 最近记录: |