我正在使用nexus-3.0.1 OSS
(使用默認設置)和maven 3.3.9
來執行此link中提到的發佈。使用maven-release-plugin失敗的maven發佈到nexus 3.0.1
我的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:[email protected]:debraj-manna-jabong/git-demo.git</connection>
<url>scm:git:[email protected]:debraj-manna-jabong/git-demo.git</url>
<developerConnection>scm:git:[email protected]: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>[email protected]{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
: -
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
有人可以讓我知道了什麼錯誤?
是的,這是一個網絡問題。我對你答案的最後部分有疑問。我添加了' true skipStaging>'。不應該跳過舞臺? –
tuk
除非你有Nexus PRO,否則根本沒有必要配置這個插件,因爲OSS版本沒有與它通信的Staging API。 – TheKaptain
雖然Nexus Staging插件添加了一些部署功能,即使您不使用Nexus Pro也是如此。你必須使用Nexus。但是,我認爲,它會允許像構建多個工件那樣的東西,然後只有在所有構建都正確的情況下才發佈它們。可能有更多的功能。 –