如何使用源和JavaDoc部署SNAPSHOT?
问题描述:
我想用快照部署源代码和javadoc。这意味着我想自动化以下命令:
I want to deploy sources and javadocs with my snapshots. This means that I want to automize the following command:
mvn clean source:jar javadoc:jar deploy
执行:
mvn clean deploy
我不希望在 install 阶段(即本地构建)。
I don't want to have javadoc/sources generation executed during the install
phase (i.e. local builds).
我知道源/ javadoc插件可以与发布插件,但我无法弄清楚如何将它连接到快照发布。
I know that source/javadoc plugins can be synchronized with the execution of the release
plugin but I can't figure out how to wire it to the snapshots releases.
答
<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<phase>deploy</phase>
<goals><goal>jar-no-fork</goal></goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>deploy</phase>
<goals><goal>jar</goal></goals>
</execution>
</executions>
</plugin>
<plugin>
<!-- explicitly define maven-deploy-plugin after other to force exec order -->
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals><goal>deploy</goal></goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
参见 Sonatype的OSS父POM 以获得完整的示例。
See Sonatype's OSS parent POM for a complete example.