Maven JavaDoc插件3.1.0无法生成聚合JavaDoc

时间:2019-06-12 23:03:42

标签: java maven pom.xml javadoc maven-javadoc-plugin

我有一个多模块项目,我想为其生成汇总的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的{​​{1}}目录,但看不到target/site/目录。

有趣的是,如果我切换到apidocs的{​​{1}}版本,则会成功生成聚集的javadocs。

我知道在3.1.0中生成3.0.1报告的方式与documented here有所不同,并且我使用了相同的报告设置。

此外,针对两个插件版本均正确生成了各个模块的javadocs。

其他详细信息:

  • JDK 8
  • maven-javadoc-plugin版本3.7.1

1 个答案:

答案 0 :(得分:0)

我终于找到了导致此问题的原因。我怀疑,原因是在maven-javadoc-plugin版本3.1.0中,有一个修补程序可以修复Support aggregated reports at each level in the multi-module hierarchy

此修复程序使用聚合器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>
相关问题