Generating Javadocs in Maven
Maven comes out with one of the cool features which does the generation of the javadocs for a project. As every developer knows that it is vital to have the code documentation of our project and this feature of maven helps to accomplish the same.
Maven uses the maven-javadoc plugin to generate the javadocs of a project. This plugin internally uses JDK\bin\javadoce.exe command to generate javadocs. When the project is deployed using mvn install
command, it generates the javadocs for the project.
Maven: Configuring Javadocs Plugin
The javadoc plugin can be configure for any project in pom.xml as shown below:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Maven: Generating Javadocs
After adding the above mentioned plugin in your project's pom.xml, all you have to do is, open the command prompt, go to the project directory, For eg. D:\Java\workspace\JavaSamples and run the command maven install
.
The generated javadocs can be found in the project's location : D:\Java\workspace\JavaSamples\target\apidocs.