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> </plugin> </plugins> ... </reporting> ... </project>
From now on whenever the site goal, a$ mvn site:site
, is executed, project Javadocs will be generated...