使用maven-release-plugin将maven发布到nexus 3.0.1失败了

时间:2016-08-25 16:09:44

标签: java maven maven-3 nexus maven-release-plugin

我正在使用nexus-3.0.1 OSS(默认设置)与maven 3.3.9进行发布,如link所述。

我的pom.xml如下所示: -

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.sonatype.blog</groupId>
    <artifactId>git-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>git-demo</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <distributionManagement>
        <repository>
            <id>nexusReleases</id>
            <name>Releases</name>
            <url>http://localhost:8081/repository/maven-releases/</url>
        </repository>

        <snapshotRepository>
            <id>nexusSnapshots</id>
            <name>Snapshots</name>
            <url>http://localhost:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
    <scm>
        <connection>scm:git:git@github.com:debraj-manna-jabong/git-demo.git</connection>
        <url>scm:git:git@github.com:debraj-manna-jabong/git-demo.git</url>
        <developerConnection>scm:git:git@github.com:debraj-manna-jabong/git-demo.git</developerConnection>
    </scm>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <tagNameFormat>v@{project.version}</tagNameFormat>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <releaseProfiles>releases</releaseProfiles>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.7</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <serverId>nexusSnapshots</serverId>
                    <nexusUrl>http://localhost:8081/</nexusUrl>
                    <skipStaging>true</skipStaging>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>releases</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.7</version>
                        <extensions>true</extensions>
                        <executions>
                            <execution>
                                <id>default-deploy</id>
                                <phase>deploy</phase>
                                <goals>
                                    <goal>deploy</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <serverId>nexusReleases</serverId>
                            <nexusUrl>http://localhost:8081/</nexusUrl>
                            <skipStaging>true</skipStaging>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

我的settings.xml如下所示: -

<?xml version="1.0" encoding="UTF-8" ?>
<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">

<servers>
   <server>
      <id>nexusReleases</id>
      <username>admin</username>
      <password>admin123</password>
   </server>
   <server>
      <id>nexusSnapshots</id>
      <username>admin</username>
      <password>admin123</password>
   </server>
</servers>
</settings>

但每当我执行mvn release:clean时,它都会失败并出现以下错误: -

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.1:clean (default-cli) on project git-demo: Execution default-cli of goal org.apache.maven.plugins:maven-release-plugin:2.4.1:clean failed: Plugin org.apache.maven.plugins:maven-release-plugin:2.4.1 or one of its dependencies could not be resolved: Could not transfer artifact org.codehaus.groovy:groovy-all:jar:1.7.6 from/to central (https://repo.maven.apache.org/maven2): GET request of: org/codehaus/groovy/groovy-all/1.7.6/groovy-all-1.7.6.jar from central failed: Connection reset -> [Help 1]

然而,一切正常,mvn clean deploy,我能够在nexus中看到快照仓库中的jar。

执行mvn release:clean时,下面是完整的maven输出: -

jabongs-MacBook-Pro-4:git-demo debraj$ mvn release:clean
[INFO] Scanning for projects...
[INFO] Inspecting build with total of 1 modules...
[INFO] Not installing Nexus Staging features:
[INFO]  * Preexisting staging related goal bindings found in 1 modules.
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-release-plugin/2.4.1/maven-release-plugin-2.4.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-release-plugin/2.4.1/maven-release-plugin-2.4.1.jar (50 KB at 17.9 KB/sec)
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building git-demo 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-release-plugin:2.4.1:clean (default-cli) @ git-demo ---
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.pom (2 KB at 2.8 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-tools/3.2/maven-plugin-tools-3.2.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-tools/3.2/maven-plugin-tools-3.2.pom (17 KB at 26.4 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/release/maven-release-manager/2.4.1/maven-release-manager-2.4.1.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/release/maven-release-manager/2.4.1/maven-release-manager-2.4.1.pom (10 KB at 19.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-invoker/2.1/maven-invoker-2.1.pom
Aug 25, 2016 9:16:47 PM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo.maven.apache.org:443: Connection reset
Aug 25, 2016 9:16:47 PM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.maven.apache.org:443
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-invoker/2.1/maven-invoker-2.1.pom (6 KB at 2.6 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/release/maven-release-manager/2.4.1/maven-release-manager-2.4.1.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-invoker/2.1/maven-invoker-2.1.jar
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy-all/1.7.6/groovy-all-1.7.6.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/release/maven-release-manager/2.4.1/maven-release-manager-2.4.1.jar (184 KB at 141.3 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar (15 KB at 9.6 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-invoker/2.1/maven-invoker-2.1.jar (29 KB at 18.1 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.089 s
[INFO] Finished at: 2016-08-25T21:16:55+05:30
[INFO] Final Memory: 12M/165M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.1:clean (default-cli) on project git-demo: Execution default-cli of goal org.apache.maven.plugins:maven-release-plugin:2.4.1:clean failed: Plugin org.apache.maven.plugins:maven-release-plugin:2.4.1 or one of its dependencies could not be resolved: Could not transfer artifact org.codehaus.groovy:groovy-all:jar:1.7.6 from/to central (https://repo.maven.apache.org/maven2): GET request of: org/codehaus/groovy/groovy-all/1.7.6/groovy-all-1.7.6.jar from central failed: Connection reset -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

有人能让我知道出了什么问题吗?

1 个答案:

答案 0 :(得分:1)

我能看到的关键信息是:

  

无法传输工件org.codehaus.groovy:groovy-all:jar:1.7.6&gt; from / to central(https://repo.maven.apache.org/maven2):GET请求:&gt; org / codehaus / groovy / groovy- all / 1.7.6 / groovy-all-1.7.6.jar from central&gt; failed:Connection reset

从maven中心下载此库看起来有些问题,我建议您确保可以访问网址https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy-all/1.7.6/groovy-all-1.7.6.jar

您可能还可以从配置settings.xml中受益,以利用Nexus来解决依赖关系:https://books.sonatype.com/nexus-book/3.0/reference/maven.html#maven-sect-single-group

最后,您的pom配置了nexus-staging-maven-plugin,这取决于仅在Nexus PRO中可用的Staging功能。您可以安全地删除该配置,但仍然可以部署到nexus

希望有帮助:)