I want to deploy sources and javadocs with my snapshots. This means that I want to automize the following command:
我想在快照中部署源和javadocs。这意味着我要自动执行以下命令:
mvn clean source:jar javadoc:jar deploy
Just to execute:
执行:
mvn clean deploy
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.
我知道源/javadoc插件可以与发布插件的执行同步,但我不知道如何将其连接到快照发布。
3 个解决方案
#1
71
<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>
See Sonatype's OSS parent POM for a complete example.
有关完整的示例,请参见Sonatype的OSS父POM。
#2
44
Just to add an alternative that doesn't require you to muck with plugin configuration:
只需添加一个替代方案,不需要你与插件配置搞混:
mvn -DperformRelease=true [goals]
Credit goes to mcbeelen from http://sea36.blogspot.com/2009/02/attaching-javadocs-and-sources-to-maven.html?showComment=1314177874102#c6853460758692768998
从http://sea36.blogspot.com/2009/02/attaching-javadoc -sources-to-maven.html?
#3
20
The article referred to by Dan also mentions another approach that works without modifying poms AND won't go away anytime soon:
Dan提到的这篇文章也提到了另一种不用修改pom的方法,而且不会很快消失:
mvn clean javadoc:jar source:jar install
mvn clean javadoc:jar源代码:jar安装
Which works fine with Maven 3+, along with...
这对Maven 3+和…
mvn clean javadoc:jar source:jar deploy
mvn clean javadoc:jar源:jar部署。
Which I have tested from Jenkins deploying to Nexus.
这是我从Jenkins部署到Nexus的测试。
This approach was nice because I only had to modify some Jenkins jobs and didn't need to mess with my poms.
这种方法很好,因为我只需要修改一些Jenkins作业,不需要打乱我的pom。
#1
71
<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>
See Sonatype's OSS parent POM for a complete example.
有关完整的示例,请参见Sonatype的OSS父POM。
#2
44
Just to add an alternative that doesn't require you to muck with plugin configuration:
只需添加一个替代方案,不需要你与插件配置搞混:
mvn -DperformRelease=true [goals]
Credit goes to mcbeelen from http://sea36.blogspot.com/2009/02/attaching-javadocs-and-sources-to-maven.html?showComment=1314177874102#c6853460758692768998
从http://sea36.blogspot.com/2009/02/attaching-javadoc -sources-to-maven.html?
#3
20
The article referred to by Dan also mentions another approach that works without modifying poms AND won't go away anytime soon:
Dan提到的这篇文章也提到了另一种不用修改pom的方法,而且不会很快消失:
mvn clean javadoc:jar source:jar install
mvn clean javadoc:jar源代码:jar安装
Which works fine with Maven 3+, along with...
这对Maven 3+和…
mvn clean javadoc:jar source:jar deploy
mvn clean javadoc:jar源:jar部署。
Which I have tested from Jenkins deploying to Nexus.
这是我从Jenkins部署到Nexus的测试。
This approach was nice because I only had to modify some Jenkins jobs and didn't need to mess with my poms.
这种方法很好,因为我只需要修改一些Jenkins作业,不需要打乱我的pom。