众所周知,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>aaronjiu_00@mycompany.com</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>dev-subscribe@mycompany.com</subscribe>
<unsubscribe>dev-unsubscribe@mycompany.com</unsubscribe>
<post>dev@mycompany.com</post>
<archive>http://mail-archives.mycompany.com/modmbox/dev/</archive>
</mailingList>
</mailingLists>
<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>
如果使用了持续集成,那么,添加
<ciManagement>
<system>Continuum</system>
<url>http://integrationserver.mycompany.com/continuum</url>
<notifiers>
<notifier>
<type>mail</type>
<address>aaronjiu@mycompany.com</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>
未完,待续
在
Maven
的pom.
xml
文件中,Build相关配置包含两个部分,一个是,另一个是,前文中我们已经介绍了,这里我们介绍reporting>。
reporting>中的配置作用于
Maven
的site阶段,用于生成
报表
。reporting>中也可以配置插件,并通过一个的为该插件配置参数。注意,对于同时出现在build>和reporting>中的插件,reporting>中对该插件的配置也能够在构建
1: 版本号
maven
版本类型: 参考: https://blog.csdn.net/athanasy1/article/details/100620517
maven
版本类型通常分为: snapshots Release
一般来说snapshots版本代表正在开发中的版本,
release代表比较稳定的发布版本.
<groupId>com.demo</groupId>
<artifactId>demo</artifactId>
MAVEN
2的配置文件有两个settings.
xml
和pom.
xml
settings.
xml
:保存的是本地所有项目所共享的全局配置信息,默认在
maven
安装目录的conf目录下,如果没有安装
maven
而是用的m2eclipse插件,那么也可以把这个配置文件放在.m2目录下pom.
xml
:描述项目的配置文件,放在每个项目的根目录下settings.
xml
localRepository:本地仓库位置,默认在.m2/repository/,可以人为更改offline:离线开关,是否每次构建都从远程仓库下载,默认f
<plugin>
<groupId>org.
apache
.
maven
.plugins</groupId>
<artifactId>
maven
-surefire-report-plugin</artifactId>
<version>3.0.0-M5</versi
ureport最新源码可以到https://github.com/youseries/ureport上下载一、首先创建一个标准的
maven
项目,在pom.
xml
文件中添加UReport2依赖,如下所示:<!--制表插件ureport-->
<dependency>
<groupId>com.bstek.ureport</groupId>
现在我来开发一个report plugin,我希望我的report plugin输出的hello world能够被集成到mvn site产生的站点中。
1.用向导创建一个report plugin工程:
mvn archetype:create -DgroupId=org.freebird -DartifactId=myreport -DarchetypeArtifactId=
maven
-ar...
Adding this element to the POM structure without breaking backward compatibility can only happen in
new-----project----
maven
project----接下来要选这个,其他的后面都会出现找不到jar包的问题,或者没有办法运行jetty总之麻烦不断!(这几天正在学ureport正好趁记得就写了,后面会再补上dorado7的部分)
在得到的project中,要在webapp下新建WEB_INF文件夹,之后按照教程新建文件并配置。我的项目名为test02:配置成功,运行jetty