Java – The Maven javadoc plugin 3.1.0 does not generate aggregated javadocs

The Maven javadoc plugin 3.1.0 does not generate aggregated javadocs… here is a solution to the problem.

The Maven javadoc plugin 3.1.0 does not generate aggregated javadocs

I

have a multi-module project for which I want to generate aggregated javadoc reports. I’m using maven-javadoc-plugin version 3.1.0. This is the reporting section of the pom.xml file:

<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>

I’m using the mvn site:site site:stage target to generate javadoc reports. When I run this command, I expect to see the apidocs directory containing index.html under target/site/, but I don’t see the apidocs directory.

Interestingly, if I switch to version 3.0.1 of maven-javadoc-plugin, the aggregate javadoc builds successfully.

I learned that in 3.1.0 there was a change in how aggregate reports are generated documented here I used the same report settings.

In addition, Javadoc for each module was generated correctly for both versions of the plugin.

Other details:

  • JDK 8
  • maven-site-plugin version 3.7.1

Solution

I finally found the cause of this issue. I suspect the reason is that in maven-javadoc-plugin version 3.1.0, there is a patch to fix Support aggregated reports at each level in the multi-module hierarchy .

This fix uses the path defined in the aggregator POM.xml to determine the canGenerateReport() result.

After investigating the modules defined in my aggregator pom.xml, I found that my modules are defined as:

<modules>
    <module>./path/to/module1</module>
    <module>./path/to/module2</module>
    <module>./path/to/module3</module>
</modules>

There is ./ in the path, causing canGenerateReport() to return false. Removing ./ solved the problem.

After fixing, my module definition looks like this:

<modules>
    <module>path/to/module1</module>
    <module>path/to/module2</module>
    <module>path/to/module3</module>
</modules>

Related Problems and Solutions