一、maven findbugs插件集成
首先修改工程的pom.xml文件,添加findbugs-maven-plugin插件,如下:
- <project>
- ...
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>2.5.1/version>
- <configuration>
- <xmlOutput>true</xmlOutput>
- <effort>Max</effort>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
- ...
- </project>
- mvn findbugs:help 查看findbugs插件的帮助
- mvn findbugs:check 检查代码是否通过findbugs检查,如果没有通过检查,检查会失败,但检查不会生成结果报表
- mvn findbugs:findbugs 检查代码是否通过findbugs检查,如果没有通过检查,检查不会失败,会生成结果报表保存在target/findbugsXml.xml文件中
- mvn findbugs:gui 检查代码并启动gui界面来查看结果
- <configuration>
- <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
- <includeFilterFile>findbugs-include.xml</includeFilterFile>
- </configuration>
二、maven的测试覆盖率插件集成
首先修改工程的pom.xml文件,添加cobertura-maven-plugin插件,如下:
- <project>
- ...
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.5.1</version>
- </plugin>
- </plugins>
- </reporting>
- ...
- </project>
- <project>
- ...
- <pluginRepositories>
- <pluginRepository>
- <id>Codehaus repository</id>
- <url>http://repository.codehaus.org/</url>
- </pluginRepository>
- </pluginRepositories>
- ...
- </project>
- mvn cobertura:help 查看cobertura插件的帮助
- mvn cobertura:clean 清空cobertura插件运行结果
- mvn cobertura:check 运行cobertura的检查任务
- mvn cobertura:cobertura 运行cobertura的检查任务并生成报表,报表生成在target/site/cobertura目录下
- cobertura:dump-datafile Cobertura Datafile Dump Mojo
- mvn cobertura:instrument Instrument the compiled classes