最简单的站点
- 通过【maven-site-plugin】生成
- Pom配置
Maven3:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-site-pluginartifactId>
<version>3.3version>
plugin>
plugins>
pluginManagement>
注意:如果报缺少
java.lang.NoClassDefFoundError: org/sonatype/aether/graph/DependencyFilter
则把maven-site-plugin从3.0升级到3.3+
mvn site
项目报告插件
JavaDoc
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-javadoc-pluginartifactId>
<version>2.7version>
plugin>
plugins>
reporting>
Source Xref
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-jxr-pluginartifactId>
<version>2.2version>
plugin>
plugins>
reporting>
- 如果想在聚合模块整合所有的源码,则需添加格外的aggregate配置
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-jxr-pluginartifactId>
<version>2.2version>
plugin>
plugins>
reporting>
CheckStyle
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-checkstyle-pluginartifactId>
<version>2.5version>
<configuration>
<configLocation>config/maven_checks.xmlconfigLocation>
configuration>
plugin>
plugins>
reporting>
- 有以下四种编码规则
- config/sun_checks.xml sun定义的编码规范(默认值)
- config/sun_checks.xml Maven社区定义的编码规范
- config/turbine_checks.xml Turbine定义的编码规范
4. config/avalon_checks.xml Avalon定义的编码规范
PMD
- 一款强大的Java源代码分析工具,能够寻找代码中的问题,包括潜在的Bug,无用代码,可优化代码,重复代码以及过于复杂的表达式。
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-pmd-pluginartifactId>
<version>2.5version>
plugin>
plugins>
reporting>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-pmd-pluginartifactId>
<version>2.5version>
<configuration>
<aggregate>trueaggregate>
configuration>
plugin>
plugins>
reporting>
ChangeLog
- 基于版本控制系统中就近的变更记录生成三份变更报告,分别是:
- Change Log 基于提交的变更报告,包括每次提交的日期,文件,作者,注释等信息
- Developer Activity 基于作者的变更报告
1. File Activity 基于文件的变更报告
<scm>
<connection>scm:svn:http://192.168.1.103/app/trunkconnection> --表示只读的scm地址
<developerConnection>scm:svn:https://192.168.1.103/app/trunkdeveloperConnection>--表示一个可写的scm地址
<url>http://192.168.1.103/account/trunkurl>--表示可在浏览器访问的url地址
scm>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-changelog-pluginartifactId>
<version>2.2version>
<configuration>
<type>rangetype>
<range>60range>
configuration>
plugin>
plugins>
reporting>
Cobertura
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>cobertura-maven-pluginartifactId>
<version>2.4version>
plugin>
plugins>
reporting>
部署站点
DAV
...
app-site
dav:https://www.baidu.com/sites/app
...
- 如果需要认证,则在【setting.xml】配置server
<servers>
<server>
<id>app-siteid>
<username>demousername>
<password>demopassword>
server>
servers>
FTP
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-site-pluginartifactId>
<version>3.3version>
plugin>
plugins>
<extensions>
<extension>
<groupId>org.apache.maven.wagongroupId>
<artifactId>wagon-ftpartifactId>
<version>1.0-beta-6version>
extension>
extensions>
build>
<distributionManagement>
<site>
<id>app-siteid>
<url>ftp:https://www.baidu.com/sites/appurl>
site>
distributionManagement>
...
project>
SCP
...
...
app-site
scp:https://www.baidu.com/sites/app
...
- 注意:与dav和ftp不同的是,scp协议通常使用密钥进行认证,因此在【setting.xml】配置认证信息时,有可能需要【passphrase】和【privateKey】,如下
<servers>
<server>
<id>app-siteid>
<passphrase>demopassphrase>
<privateKey>demoprivateKey>
server>
servers>
- 布置完后,只需要输入以下命令就能够让Maven部署站点:
mvn clean site-deploy