如何在所有模块构建完成后执行 Maven 插件
具体来说,我正在尝试运行 maven-javadoc-plugin,但是每当我更改父/聚合器 pom 和所有子项上的版本号时,第一次运行构建都会失败,因为 javadoc 首先运行并且找不到任何新版本从模块中打包,因为它们尚未构建。
我通常最终不得不为一个构建注释掉 javadoc,然后在新版本的 nexus 中提供可用包后将其添加回来。然而,这可能意味着我一直在一个构建的旧源 jar 上构建 javadoc。
我读过关于将另一个模块放入其中的建议,该模块依赖于其他模块,但我认为我无法获得一个模块来为对等模块构建 javadoc。将它放在父级中会为所有模块构建所有 javadoc,我只需要它稍后发生。谢谢。这是我的 javadoc 插件配置。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<inherited>false</inherited>
<executions>
<execution>
<id>generate-javadoc</id>
<phase>package</phase>
<goals>
<goal>aggregate</goal>
</goals>
<configuration>
<aggregate>true</aggregate>
<links>
<link>http://java.sun.com/javase/6/docs/api</link>
<link>http://java.sun.com/javaee/5/docs/api</link>
</links>
<maxmemory>512</maxmemory>
<doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
<docletArtifact>
<groupId>org.umlgraph</groupId>
<artifactId>doclet</artifactId>
<version>5.2</version>
</docletArtifact>
<additionalparam>
-inferrel -inferdep -outputencoding utf8 -hide
java.* -collpackages
java.util.*
-qualify -postfixpackage
-nodefontsize 9 -nodefontpackagesize 7
</additionalparam>
</configuration>
</execution>
</executions>
</plugin>
Specifically I am trying to run maven-javadoc-plugin but whenever I change the version numbers on the parent/aggregator pom and all of the children, the first time I run the build it fails because javadoc runs first and can't find any of the new version packages from the modules because they haven't been built yet.
I usually end up having to comment javadoc out for one build and then add it back in once the packages are available in nexus for the new version. However, this likely means that I've been building javadoc on one build old source jars all the time.
I've read suggestions of putting another module in that depends on the other ones but I don't think i can get a module to build the javadoc for peer modules. Having it in the parent builds all of the javadoc for all of the modules, I just need it to happen later. Thanks. Here's my javadoc plugin config.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<inherited>false</inherited>
<executions>
<execution>
<id>generate-javadoc</id>
<phase>package</phase>
<goals>
<goal>aggregate</goal>
</goals>
<configuration>
<aggregate>true</aggregate>
<links>
<link>http://java.sun.com/javase/6/docs/api</link>
<link>http://java.sun.com/javaee/5/docs/api</link>
</links>
<maxmemory>512</maxmemory>
<doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
<docletArtifact>
<groupId>org.umlgraph</groupId>
<artifactId>doclet</artifactId>
<version>5.2</version>
</docletArtifact>
<additionalparam>
-inferrel -inferdep -outputencoding utf8 -hide
java.* -collpackages
java.util.*
-qualify -postfixpackage
-nodefontsize 9 -nodefontpackagesize 7
</additionalparam>
</configuration>
</execution>
</executions>
</plugin>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决这个问题的一种方法是在正常的 Maven 生命周期阶段不调用 javadoc 插件;相反,单独运行它。
具体来说,从上面的
plugin
定义中删除
标签。从父级运行
mvn install javadoc:javadoc
。这将构建并安装所有模块和父模块,然后在它们上运行 javadoc。
One way to get around this problem is not to invoke javadoc plugin in the normal maven lifecycle phase; instead run it separately.
To be specific, remove
<phase>
tag from the aboveplugin
definition.Run
mvn install javadoc:javadoc
from parent.This will build and install all the modules and the parent and then run javadoc on them.
您的 javadoc 插件声明是否位于 pom.xml 的
部分中?您应该考虑将其移至
部分,请参阅此 链接。Is your javadoc plugin declaration in the
<build>
part of your pom. You should consider moving it to the<reporting>
part see this link.