搭建CruiseControl2.8.2+maven2.1+cobertura+checkstyle+findbug持续集成环境
上一篇 / 下一篇 2009-06-05 22:51:00 / 个人分类:java性能监控与调优
参考:
http://rdc.taobao.com/blog/qa/?p=1822
http://rdc.taobao.com/blog/qa/?p=669
http://emma.sourceforge.net/maven-emma-plugin/goals.html
http://foxgem.javaeye.com/blog/24620
下载:CruiseControl-
第一步先配置pom.xml
依照maven权威指南 http://www.sonatype.com/books/maven-book/reference_zh/web.html 下载第五章样例simple-webapp
参考http://mojo.codehaus.org/cobertura-maven-plugin/usage.html 配置cobertura及jetty, checkstyle, pmd, findbug等相关的 pom.xml.配置完成需要单独测试pom.xml是否正确.
Pom.xml内容:
<project xmlns="http://maven.apache.org/POM/
xsi:schemaLocation="http://maven.apache.org/POM/
<modelVersion>
<groupId>org.sonatype.mavenbook.ch05</groupId>
<artifactId>simple-webapp</artifactId>
<version>1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Chapter 5 Simple Web Application Project</name>
<url>http://sonatype.com/book</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.4_spec</artifactId>
<version>
</dependency>
</dependencies>
<!--
<parent>
<artifactId>parent</artifactId>
<groupId>org.sonatype.mavenbook.ch05</groupId>
<version>1-SNAPSHOT</version>
</parent>
-->
<build>
<finalName>simple-webapp</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>project</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>examples</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<stopKey>foo</stopKey>
<stopPort>9999</stopPort>
</configuration>
<!--
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution> <id>stop-jetty</id>
<phase>post-integration-test</phase> <goals> <goal>stop</goal>
</goals> </execution>
</executions>
-->
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<check>
<branchRate>85</branchRate>
<lineRate>85</lineRate>
<haltOnFailure>true</haltOnFailure>
<totalBranchRate>85</totalBranchRate>
<totalLineRate>85</totalLineRate>
<packageLineRate>85</packageLineRate>
<packageBranchRate>85</packageBranchRate>
<regexes>
<regex>
<pattern>com.example.boringcode.*</pattern>
<branchRate>40</branchRate>
<lineRate>30</lineRate>
</regex>
</regexes>
</check>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<enableRulesSummary>false</enableRulesSummary>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.3</version>
<configuration>
<linkXref>true</linkXref>
<sourceEncoding>utf-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<targetJdk>1.5</targetJdk>
<excludes>
<exclude>**/*Bean.java</exclude>
<exclude>**/generated/*.java</exclude>
</excludes>
<excludeRoots>
<excludeRoot>target/generated-sources/stubs</excludeRoot>
</excludeRoots>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<findbugsXmlOutput>true</findbugsXmlOutput>
<!-- Optional directory to put findbugs xml report -->
<findbugsXmlOutputDirectory>target</findbugsXmlOutputDirectory>
<!--
<includeFilterFile>lib-filter.xml</includeFilterFile>
-->
</configuration>
</plugin>
</plugins>
</reporting>
</project>
然后maven编译生成site报告: D:\project\mvn-examples-1.0\ch05-simple-web\simple-webapp>mvn clean -Dmaven.compile.debug site jetty:run
报告在: D:\project\mvn-examples-1.0\ch05-simple-web\simple-webapp\target\site\cobertura
TAG: