Aggregating Javadocs For Multi-Projects

For example, consider the following directory structure:

  1. Project
  2. |-- pom.xml
  3. |-- Module1
  4. | `-- pom.xml
  5. |-- Module2
  6. | `-- pom.xml
  7. `-- Module3
  8. `-- pom.xml
  9.  

Using The <aggregate/> Parameter (deprecated)

Note: <aggregate/> parameter is deprecated since 2.5. Please use the aggregate goal instead of.

The <aggregate/> parameter can be used to generate javadocs for multi-module projects. It gives the option to generate one javadoc report for the entire project (all modules) or generate one javadoc report for each module.

When you execute javadoc:javadoc from Project directory with aggregate set to true, a javadoc report will be created in the target directory of Project with all the javadocs of Project's modules included. If aggregate is set to false (default), a javadoc report for Module1 will be generated in the target directory of Module1, a javadoc report for Module2 will be generated in the target directory of Module2, and a javadoc report for Module3 will be generated in the target directory of Module3.

  1. <project>
  2. ...
  3. <reporting> (or <build>)
  4. <plugins>
  5. <plugin>
  6. <groupId>org.apache.maven.plugins</groupId>
  7. <artifactId>maven-javadoc-plugin</artifactId>
  8. <version>2.10.4</version>
  9. <configuration>
  10. ...
  11. <aggregate>true</aggregate>
  12. ...
  13. </configuration>
  14. </plugin>
  15. </plugins>
  16. ...
  17. </reporting> (or </build>)
  18. ...
  19. </project>

Using The aggregate Goals

The <aggregate/> parameter doesn't include generate source directories defined using the build-helper:add-source. In this case, you need to use the aggregate goal and test-aggregate goals. You could define these goals in the <build/> element (using the <execution/> tag) or <reporting/> element (using the <reportSet/> tag) as shown below. For more information, refer to the Selective Javadocs Reports page.

  1. <project>
  2. ...
  3. <build>
  4. <plugins>
  5. <plugin>
  6. <groupId>org.apache.maven.plugins</groupId>
  7. <artifactId>maven-javadoc-plugin</artifactId>
  8. <version>2.10.4</version>
  9. <configuration>
  10. <!-- Default configuration for all reports -->
  11. ...
  12. </configuration>
  13. <executions>
  14. <execution>
  15. <id>aggregate</id>
  16. <goals>
  17. <goal>aggregate</goal>
  18. </goals>
  19. <phase>site</phase>
  20. <configuration>
  21. <!-- Specific configuration for the aggregate report -->
  22. ...
  23. </configuration>
  24. </execution>
  25. ...
  26. </executions>
  27. </plugin>
  28. ...
  29. </plugins>
  30. </build>
  31. ...
  32. </project>
  1. <project>
  2. ...
  3. <reporting>
  4. <plugins>
  5. <plugin>
  6. <groupId>org.apache.maven.plugins</groupId>
  7. <artifactId>maven-javadoc-plugin</artifactId>
  8. <version>2.10.4</version>
  9. <configuration>
  10. <!-- Default configuration for all reports -->
  11. ...
  12. </configuration>
  13. <reportSets>
  14. <reportSet>
  15. <id>non-aggregate</id>
  16. <configuration>
  17. <!-- Specific configuration for the non aggregate report -->
  18. ...
  19. </configuration>
  20. <reports>
  21. <report>javadoc</report>
  22. </reports>
  23. </reportSet>
  24. <reportSet>
  25. <id>aggregate</id>
  26. <configuration>
  27. <!-- Specific configuration for the aggregate report -->
  28. ...
  29. </configuration>
  30. <reports>
  31. <report>aggregate</report>
  32. </reports>
  33. </reportSet>
  34. ...
  35. </reportSets>
  36. </plugin>
  37. ...
  38. </plugins>
  39. </reporting>
  40. ...
  41. </project>

The Javadoc plugin contains several aggregate goals to be use with an aggregator project. Here is the full list of all aggregate goals: