Error during deployment of artifacts to Nexus from Eclipse

荒凉一梦 提交于 2019-12-24 08:26:11

问题


Installed Nexus on our server and set up a snapshot and a releases repositories.

Altered my pom.xml file of the top project in my sub-module maven project, added these lines:

  <distributionManagement>
    <snapshotRepository>
        <id>Snapshots</id>
        <url>http://maven:8081/nexus/content/repositories/Snapshots</url>
    </snapshotRepository>
    <repository>
        <id>Releases</id>
        <url>http://maven:8081/nexus/content/repositories/Releases</url>
    </repository>
  </distributionManagement>

I've added a settings.xml to .m2 directory with the following contents:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <!--
  <localRepository/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  -->
  <servers>

    <server>
      <id>Snapshots</id>
      <username>user</username>
      <password>pass</password>

      <privateKey>${user.home}/.ssh/id_dsa</privateKey>
      <passphrase>some_passphrase</passphrase>

      <filePermissions>664</filePermissions>
      <directoryPermissions>775</directoryPermissions>
      <configuration></configuration>

    </server>

  </servers>
  <!--
  <mirrors/>
  <proxies/>
  <profiles/>
  <activeProfiles/>
  -->
</settings>

When I run maven with deploy goal from eclipse on my top project, maven starts to build and syncing (uploading) to the snapshots repo. The top project gets uploaded but after the first sub module is built and started to sync I keep getting:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project <my sub module project>: Failed to deploy artifacts: Could not transfer artifact <group id>:<artifact id>:xml:0.0.1-20130318.160312-21 from/to Snapshots (http://maven:8081/nexus/content/repositories/Snapshots): Remotely Closed [id: 0x017ae341, /192.168.10.237:58758 :> maven/192.168.10.36:8081]

The weird thing is that if I browse my repo from Nexus interface the sub project is there with xml's and jar's etc. Problem though is that because of the error maven stops and all my other sub projects isn't deployed.

Anyone know how to resolve this?

UPDATE: If I create a single maven project with distributionManagement-tag I can deploy without problems to Nexus. But when having multi maven project I get the error. I tried to add distributionManagement to child-pom to but I get the same error.

How should the poms look like en deploying to a repository regarding distributionManagement tag ?


回答1:


After some hours investigation I found my problem. I have a section in my parent pom.xml that adds a features.xml to parent repo.

<build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-resources-plugin</artifactId>
              <version>${maven-resources-plugin.version}</version>
              <executions>
                 <execution>
                    <id>filter</id>
                    <phase>generate-resources</phase>
                    <goals>
                      <goal>resources</goal>
                    </goals>
                 </execution>
              </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>${build-helper-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>target/classes/features.xml</file>
                                    <type>xml</type>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
         </plugins>
   </build>

This one caused the "Remotely closed" issue.



来源:https://stackoverflow.com/questions/15493954/error-during-deployment-of-artifacts-to-nexus-from-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!