2

描述

我想通过一个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]

我怎样才能做到这一点而不必创建特定的构建配置文件?

谢谢。

4

1 回答 1

2

我无法在 javadoc 插件之后重新排序部署插件的默认执行。但是,您可以跳过默认执行,这很有用,因为非默认执行尊重 POM 中的顺序。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.10.3</version>
    <executions> 
        <execution> 
            <id>release</id>
            <phase>deploy</phase>
            <goals>
                <goal>jar</goal>
            </goals> 
        </execution> 
    </executions> 
</plugin>
<plugin> 
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-deploy-plugin</artifactId> 
    <version>2.8.2</version>
    <executions> 
        <execution> 
            <id>default-deploy</id>
            <phase>deploy</phase>
            <goals>
                <goal>deploy</goal>
            </goals>
            <configuration>
                <skip>true</skip>
            </configuration> 
        </execution> 
        <execution> 
            <id>release</id>
            <phase>deploy</phase>
            <goals>
                <goal>deploy</goal>
            </goals> 
        </execution> 
    </executions> 
</plugin>

构建的提取:

[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ AutoridadCertificanteHiba ---
[INFO] Skipping artifact deployment
[INFO] 
[INFO] --- maven-javadoc-plugin:2.10.3:jar (release) @ AutoridadCertificanteHiba ---
[INFO] 
[INFO] Building jar: /home/daniel/svnroot/firmaDigitalChrome/AutoridadCertificanteHiba/target/checkout/target/AutoridadCertificanteHiba-1.0.2-javadoc.jar
[INFO] 
[INFO] --- maven-deploy-plugin:2.8.2:deploy (release) @ AutoridadCertificanteHiba ---
Uploading: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/1.0.2/AutoridadCertificanteHiba-1.0.2.jar               
Uploaded: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/1.0.2/AutoridadCertificanteHiba-1.0.2.jar (45 KB at 27.8 KB/sec)
Uploading: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/1.0.2/AutoridadCertificanteHiba-1.0.2.pom               
Uploaded: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/1.0.2/AutoridadCertificanteHiba-1.0.2.pom (13 KB at 18.4 KB/sec)
Downloading: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/maven-metadata.xml                
Downloaded: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/maven-metadata.xml (379 B at 2.3 KB/sec)
Uploading: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/maven-metadata.xml                
Uploaded: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/maven-metadata.xml (409 B at 1.2 KB/sec)
Uploading: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/1.0.2/AutoridadCertificanteHiba-1.0.2-javadoc.jar               
Uploaded: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/1.0.2/AutoridadCertificanteHiba-1.0.2-javadoc.jar (46 KB at 36.1 KB/sec)
于 2016-03-23T18:09:53.840 回答