描述
我想通过一个mvn clean deploy
.
第一次尝试
我找到的示例在默认阶段(包)使用此 POM 提取生成 javadoc:
<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
这对我来说并不完美,因为即使是简单的mvn clean install
.
当前状态
我的想法是在执行中指定部署阶段:
<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>deploy</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
但问题是部署是在生成 javadocs 之前完成的,所以 nexus 只接收库......
如果我强制 deploy:deploy 阶段在 javadoc 阶段之后执行,我有 2 个 deploy 阶段,第一个只发送 lib,第二个可以发送 lib+javadoc,因为 lib 已经发送。
<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>deploy</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- explicitly define maven-deploy-plugin after other to force exec order -->
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
构建的摘录(SNAPSHOT Vs RELEASE):
(...)
--- maven-deploy-plugin:2.7:deploy (default-deploy) @ lib ---
Downloading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml
Downloaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml (758 B at 5.2 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.jar
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.jar (4 KB at 24.0 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.pom
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.pom (10 KB at 135.3 KB/sec)
Downloading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml
Downloaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml (482 B at 27.7 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml (758 B at 13.2 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml (482 B at 10.0 KB/sec)
(...)
--- maven-javadoc-plugin:2.9.1:jar (attach-javadocs) @ lib ---
Loading source files for package lib...
(...)
SNAPSHOT:上传2次快照没问题
--- maven-deploy-plugin:2.7:deploy (deploy) @ lib ---
Downloading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml
Downloaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml (758 B at 37.0 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.jar
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.jar (4 KB at 68.6 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.pom
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.pom (10 KB at 177.1 KB/sec)
Downloading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml
Downloaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml (482 B at 33.6 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml (758 B at 11.2 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml (482 B at 13.8 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3-javadoc.jar
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3-javadoc.jar (35 KB at 581.3 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml (2 KB at 28.9 KB/sec)
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 7.342 s
Finished at: 2014-08-04T10:54:10+01:00
Final Memory: 36M/449M
------------------------------------------------------------------------
RELEASE : 不允许重新部署
--- maven-deploy-plugin:2.7:deploy (deploy) @ lib ---
Uploading: Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4/lib-1.4.jar
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4/lib-1.4.pom
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 4.403 s
Finished at: 2014-08-01T15:25:11+01:00
Final Memory: 24M/437M
------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (deploy) on project lib: Failed to deploy artifacts: Could not transfer artifact poc.release:lib:jar:1.4 from/to poc-repo (http://poc-nexus/content/repositories/poc-repo/): Failed to transfer file: http://poc-nexus/1.4/lib-1.4.jar. Return code is: 400, ReasonPhrase: Bad Request. -> [Help 1]
我怎样才能做到这一点而不必创建特定的构建配置文件?
谢谢。