Maven发布插件失败:源工件被部署两次 [英] Maven release plugin fails : source artifacts getting deployed twice

查看:616
本文介绍了Maven发布插件失败:源工件被部署两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用hudson上的maven发布插件并尝试自动执行发布过程。
发布:准备工作正常。当我们尝试执行release:perform时,它会失败,因为它会尝试将源工件两次上传到存储库。

We are using the maven release plugin on hudson and trying to automate the release process. The release:prepare works fine. When we try to do the release:perform , it fails because it tries to upload a source artifact twice to the repository.

我尝试过的事情,


  1. 从超级pom中移除包含maven源插件的配置文件(不起作用)

  2. 指定目标在hudson上发布为-P!attach-source release:准备发布:执行。我认为这将排除源插件被执行。 (没有用)。

  3. 尝试将插件阶段指定为超级pom中某些不存在的阶段。(无法正常工作)

  4. 尝试指定插件配置,forReleaseProfile为false。 (猜猜是什么?也没用?)

  1. removing the profile which does include the maven source plugin from the super pom ( did not work)
  2. specifying the goals on hudson for release as -P!attach-source release:prepare release:perform. Which I thought will exclude the source plugin from getting executed. (did not work).
  3. tried specifying the plugin phase to some non existent phase in the super pom.(Did not work)
  4. tried specifying the plugin configuration, forReleaseProfile as false. ( guess what?? Did not work too)

它仍然吐出这个错误。

[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

对此有任何帮助将非常感激。

Any help regarding this will be really appreciated.

推荐答案

尝试运行 mvn -Prelease-profile help:effective-pom
你会发现你有两个执行部分 maven-source-plugin

输出将是看起来像这样:

The output will look something like this:


    <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 并确保使用idattach-sources以使其与发布配置文件相同。然后将合并这些部分。

To fix this problem, find everywhere you have used maven-source-plugin and make sure that you use the "id" attach-sources so that it is the same as the release profile. Then these sections will be merged.

最佳实践说,要获得一致性,您需要在build> pluginManagement和 NOT中的项目的根POM中配置它在你的孩子poms。在子pom中你只需要在build> plugins中指定你想要使用maven-source-plugin,但你不提供执行。

Best practice says that to get consistency you need to configure this in the root POM of your project in build > pluginManagement and NOT in your child poms. In the child pom you just specify in build > plugins that you want to use maven-source-plugin but you provide no executions.

在房间里pom.xml:

In the room 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>

在子项pom.xml中:

In the child pom.xml:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-source-plugin</artifactId>
    </plugin>
  </plugins>
</build>

这篇关于Maven发布插件失败:源工件被部署两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆