Maven Project Documentation
In this section, we will learn how to create Maven project documentation.
For example, if we have created a consumerBanking project in the C:/MVN directory, Maven uses the following command to quickly create a Java project:
mvn archetype:generate -DgroupId=com.companyname.bank -DartifactId=consumerBanking -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
Modify the pom.xml file by adding the following configuration (if not already present):
<project>
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.7</version>
</plugin>
</plugins>
</pluginManagement>
</build>
...
</project>
Otherwise, you may encounter the java.lang.NoClassDefFoundError: org/apache/maven/doxia/siterenderer/DocumentContent issue when running the mvn site
command, which is due to an outdated maven-site-plugin. Upgrading to version 3.3 or higher resolves this issue.
Open the consumerBanking folder and execute the following Maven command:
C:\MVN\consumerBanking> mvn site
Maven will start generating the documentation:
[INFO] Scanning for projects...
[INFO] -------------------------------------------------------------------
[INFO] Building consumerBanking
[INFO]task-segment: [site]
[INFO] -------------------------------------------------------------------
[INFO] [site:site {execution: default-site}]
[INFO] artifact org.apache.maven.skins:maven-default-skin:
checking for updates from central
[INFO] Generating "About" report.
[INFO] Generating "Issue Tracking" report.
[INFO] Generating "Project Team" report.
[INFO] Generating "Dependencies" report.
[INFO] Generating "Continuous Integration" report.
[INFO] Generating "Source Repository" report.
[INFO] Generating "Project License" report.
[INFO] Generating "Mailing Lists" report.
[INFO] Generating "Plugin Management" report.
[INFO] Generating "Project Summary" report.
[INFO] -------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] -------------------------------------------------------------------
[INFO] Total time: 16 seconds
[INFO] Finished at: Wed Jul 11 18:11:18 IST 2012
[INFO] Final Memory: 23M/148M
[INFO] -------------------------------------------------------------------
Open the **C:\MVN\consumerBanking\target\site** folder. Click on **index.html** to view the documentation.
Maven uses a document processing engine called [Doxia](http://maven.apache.org/doxia/index.html) to create documentation, which can read source code in multiple formats into a common document model. To document your project, you can write content in the following commonly used formats that Doxia can convert.
| Format Name | Description | Reference |
| --- | --- | --- |
| Apt | Plain text document format | [http://maven.apache.org/doxia/references/apt-format.html](http://maven.apache.org/doxia/references/apt-format.html) |
| Xdoc | A document format for Maven 1.x | [http://jakarta.apache.org/site/jakarta-site2.html](http://jakarta.apache.org/site/jakarta-site2.html) |
| FML | Suitable for FAQ documents | [http://maven.apache.org/doxia/references/fml-format.html](http://maven.apache.org/doxia/references/fml-format.html) |
| XHTML | Extensible HTML document | [http://en.wikipedia.org/wiki/XHTML](http://en.wikipedia.org/wiki/XHTML) |