Generating documentation automatically

Both Ant and Maven use the Javadoc tool to automatically generate documentation. If you are using Ant, simply navigate to a project's root directory and enter the following command:

$ ant javadoc
Buildfile: build.xml
javadoc:
[javadoc] Generating Javadoc
[javadoc] Javadoc execution
[javadoc] Loading source file /home/packt/...
[javadoc] Constructing Javadoc information...

For Maven you first have to add the javadoc plugin. To do this, edit the pom.xml file and add the following lines at the corresponding location:

<project> ... <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.8</version> <configuration> ... </configuration> ...

Get Sonar Code Quality Testing Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.