In this section, we focus on how to create Maven project documents.
For example, we create a consumerBanking project under the C:/MVN directory, and 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 to add the following configuration (if not available):
<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>
不然运行mvn site 命令时出现 **java.lang.NoClassDefFoundError:
org/apache/maven/doxia/siterenderer/DocumentContent** 的问题,
这是由于 maven-site-plugin 版本过低,升级到 3.3+ 即可。
Open the consumerBanking folder and execute the following mvn command.
C:\MVN\consumerBanking> mvn site
Maven begins to generate 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] -------------------------------------------------------------------

打开 C:MVNconsumerBankingtargetsite 文件夹。点击 index.html 就可以看到文档了。

Maven uses a file named Doxia Document processing engine to create documents, which can read various formats of source code into a common document model. To document your project, you can write the content in the following common formats that can be converted by Doxia.
Format name | Description | Referenc |
|---|---|---|
Apt | Plain text document format | http://maven.apache.o rg/doxia/references/a pt-format.html |
Xdoc | A document format for Maven 1.x | http://jakarta.apache .org/site/jakarta-sit e2.html |
FML | FAQ documentation is applicable | http://maven.apache.o rg/doxia/references/f ml-format.html |
XHTML | Extensible HTML documents | http://en.wikipedia.o rg/wiki/XHTML |