Sunday, August 26, 2012

Create Javadocs for a Multi-Module Maven Project

In this tutorial, I show how to create Javadocs for a multi-module Maven project. Creation of Javadocs requires the use of the Maven maven-javadoc-plugin plugin and running "mvn javadoc:aggregate" on the parent pom.xml. For the sake of this tutorial, I'm taking some excerpts from one of my current Open Source Projects - XChange.

Relevant Links

XChange on Github - To see an actual working example
Javadocs for XChange on xeiam.com - To see what the generated Javadocs look like.

How To

Step 1: Add the following to the parent pom.xml file:

<build>
  <pluginmanagement>
    <plugin>
      <groupid>org.apache.maven.plugins</groupId>
      <artifactid>maven-javadoc-plugin</artifactId>
      <version>2.8.1</version>
    </plugin>
  </pluginManagement>
  <plugins>
    <plugin>
      <groupid>org.apache.maven.plugins</groupId>
      <artifactid>maven-javadoc-plugin</artifactId>
    </plugin>
  </plugins>
</build>
Step 2: Run the following mvn command:

mvn javadoc:aggregate

Piece of Cake!!!

See also: Maven Project Compiles in Eclipse but Maven Build Fails
See also: Using Maven Offline
See also: Hello World - Maven, M2Eclipse and Eclipse

No comments: