Прикрепление javadocs к развертыванию Maven

Описание

Я хотел бы автоматически генерировать и развертывать в нексусе Javadocs моих проектов одновременно с самой библиотекой mvn clean deploy,

Первая попытка

Пример, который я нашел, генерирует Javadoc во время фазы по умолчанию (пакет) с этим извлечением POM:

<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
------------------------------------------------------------------------

РЕЛИЗ: передислокация не разрешена

--- 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]

Как я могу сделать это без необходимости создания определенного профиля сборки?

Thks.

1 ответ

Мне не удалось изменить порядок выполнения плагина развертывания по умолчанию после плагина 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)
Другие вопросы по тегам