Maven强大的报表功能

众所周知,Maven的强大功能来源于它的强大的插件体系,而它的报表功能更是依赖于它的插件体系。下面,我们就看看报表有多么强大。

首先,我们随意创建一个Maven项目,使用向导式指令,根据提示,:

mvn archetype:generate

运行过程中的关键数据:

Define value for groupId: : com.mycompany.myapp 
Define value for artifactId: : myapp 
Define value for version: 1.0-SNAPSHOT: : 1.0 
Define value for package: com.mycompany.myapp: : 
Confirm properties configuration: 
groupId: com.mycompany.myapp 
artifactId: myapp 
version: 1.0 
package: com.mycompany.myapp 

创建项目之后,

cd myapp

 查看目录结构

tree /f

 运行结构如下:

│  pom.xml
│
└─src
    ├─main
    │  └─java
    │      └─com
    │          └─mycompany
    │              └─myapp
    │                      App.java
    │
    └─test
        └─java
            └─com
                └─mycompany
                    └─myapp
                            AppTest.java

用你最喜欢的编辑器,编辑pom.xml

增加项目团队成员(姓名、Email、角色、所属组织等): 

<developers>
	<developer>
		<id>aaronjiu</id>
		<name>Aaron Jiu</name>
		<email>[email protected]</email>
		<roles>
			<role>Project Manager</role>
			<role>Architect</role>
			<role>Developer</role>
		</roles>
		<organization>Mycompany.com</organization>
		<timezone>+8</timezone>
	</developer>
</developers> 

如果你的团队使用了邮件列表

<mailingLists>
	<mailingList>
		<name>My App project mailing list</name>
		<subscribe>[email protected]</subscribe>
		<unsubscribe>[email protected]</unsubscribe>
		<post>[email protected]</post>
		<archive>http://mail-archives.mycompany.com/modmbox/dev/</archive>
	</mailingList>
</mailingLists>

 代码库

<scm>
	<connection>scm:svn:http://svn.mycompany.com/myapp/</connection>
	<developerConnection>scm:svn:http://svn.mycompany.com/myapp/</developerConnection>
	<url>http://svn.mycompany.com/viewcvs.cgi/myapp/</url>
</scm>

 如果使用了持续集成,那么,添加

<ciManagement>
	<system>Continuum</system>
	<url>http://integrationserver.mycompany.com/continuum</url>
	<notifiers>
		<notifier>
			<type>mail</type>
			<address>[email protected]</address>
		</notifier>
	</notifiers>
</ciManagement>

问题追踪

<issueManagement>
	<system>Bugzilla</system>
	<url>https://bugzilla.mycompany.com/</url>
</issueManagement> 

软件所使用协议

<licenses>
	<license>
		<name>Apache 2</name>
		<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
		<distribution>repo</distribution>
		<comments>A business-friendly OSS license</comments>
	</license>
</licenses>

添加报表:

  • Javadocs
    <reporting>
    	<plugins>
    		<plugin>
    			<artifactId>maven-javadoc-plugin</artifactId>
    		</plugin>
    	</plugins>
    </reporting> 
  • JXR:它将会生成源代码的一个有索引和交叉查考的HTML版本
    <reporting>
    	<plugins>			
    		<plugin>
    			<groupId>org.codehaus.mojo</groupId>
    			<artifactId>jxr-maven-plugin</artifactId>
    		</plugin>
    	</plugins>
    </reporting> 
  • 单元测试报表
    <reporting>
    	<plugins>			
    		<plugin>
    			<groupId>org.codehaus.mojo</groupId>
    			<artifactId>surefire-report-maven-plugin</artifactId>
    		</plugin>
    	</plugins>
    </reporting> 
  • 测试覆盖率报表
    <reporting>
    	<plugins>			
    		<plugin>
    			<groupId>com.atlassian.maven.plugins</groupId>
    			<artifactId>maven-clover2-plugin</artifactId>
    			<version>2.3.2</version>
    			<configuration />
    		</plugin>
    	</plugins>
    </reporting> 
  • Changlog报表
    <reporting>
    	<plugins>			
    		<plugin>
    			<groupId>org.codehaus.mojo</groupId>
    			<artifactId>changelog-maven-plugin</artifactId>
    		</plugin>
    	</plugins>
    </reporting> 
     
  • PMD:代码Review报表
    <reporting>
    	<plugins>			
    		<plugin>
    			<groupId>org.apache.maven.plugins</groupId>
    			<artifactId>maven-pmd-plugin</artifactId>
    			<configuration>
    				<targetjdk>1.5</targetjdk>
    				<rulesets>
    					<ruleset>/rulesets/basic.xml</ruleset>
    					<ruleset>/rulesets/controversial.xml</ruleset>
    				</rulesets>
    				<format>xml</format>
    				<linkXref>true</linkXref>
    				<sourceEncoding>utf-8</sourceEncoding>
    				<minimumTokens>100</minimumTokens>
    			</configuration>
    		</plugin>
    	</plugins>
    </reporting>
  • FindBugs:
    <reporting>
    	<plugins>
    		<plugin>
    			<artifactId>maven-findbugs-plugin</artifactId>
    		</plugin>
    	</plugins>
    </reporting>
    
    未完,待续

猜你喜欢

转载自tonglin.iteye.com/blog/419224