>我有一个多模块项目,我想为它生成聚合的javadoc报告。我使用的是maven-javadoc-plugin
版本3.1.0。这是pom.xml文件的报告部分:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<reportSets>
<reportSet>
<id>non-aggregate</id>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
<reportSet>
<id>aggregate</id>
<inherited>false</inherited>
<reports>
<report>aggregate</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
我正在使用mvn site:site site:stage
目标来生成javadoc报告。当我运行此命令时,我希望看到apidocs
目录包含index.html
target/site/
但我看不到apidocs
目录。
有趣的是,如果我切换到3.0.1
版本的maven-javadoc-plugin
,聚合javadocs会成功生成。
我知道在 3.1.0 中生成报告aggregate
的方式发生了变化,如此处所述,并且我使用了相同的报告设置。
此外,为插件的两个版本正确生成了各个模块的 javadoc。
其他细节:
- JDK 8
-
maven-site-plugin
版本 3.7.1
我终于找到了导致此问题的原因。我怀疑原因是在maven-javadoc-plugin
3.1.0 版本中,有一个补丁可以修复多模块层次结构中每个级别的支持聚合报告。
此修复使用聚合器pom.xml
中定义的路径来确定 canGenerateReport(( 的结果。
在调查了我的聚合器pom.xml
中定义的模块后,我发现我的模块被定义为:
<modules>
<module>./path/to/module1</module>
<module>./path/to/module2</module>
<module>./path/to/module3</module>
</modules>
这条路./
了,导致canGenerateReport()
返回false
。删除./
解决了问题。
修复后,我的模块定义如下所示:
<modules>
<module>path/to/module1</module>
<module>path/to/module2</module>
<module>path/to/module3</module>
</modules>