使用maven-release-plugin的maven发布到nexus 3.0.1失败
maven release to nexus 3.0.1 using maven-release-plugin is failing
我正在使用 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
谁能告诉我出了什么问题?
我能看到的关键信息是:
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
看起来从 Maven Central 下载这个库有一些问题,我建议确保你可以到达 url 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
希望有所帮助:)
我正在使用 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
谁能告诉我出了什么问题?
我能看到的关键信息是:
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
看起来从 Maven Central 下载这个库有一些问题,我建议确保你可以到达 url 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
希望有所帮助:)