日期:2014-05-16  浏览次数:20384 次

在jenkins中使用findbugs并自定义错误类型

1.项目使用mvn管理。

mvn archetype:create ? -DgroupId=com.cx ?-DartifactId=child1 ?-DarchetypeArtifactId=maven-archetype-quickstart?

?

2.在maven的pom文件中增加构建插件maven-site-plugin和报表插件findbugs-maven-plugin

?

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

? xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

? <modelVersion>4.0.0</modelVersion>

?

? <groupId>cx</groupId>

? <artifactId>findbugstest</artifactId>

? <version>1.0-SNAPSHOT</version>

? <packaging>jar</packaging>

?

? <name>findbugstest</name>

? <url>http://maven.apache.org</url>

?

? <properties>

? ? <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

? </properties>

?

? <dependencies>

? ? <dependency>

? ? ? <groupId>junit</groupId>

? ? ? <artifactId>junit</artifactId>

? ? ? <version>3.8.1</version>

? ? ? <scope>test</scope>

? ? </dependency>

? </dependencies>

??

? <build>

? ? <plugins>

? ? ? ? <plugin>

? ? ? ? <groupId>org.apache.maven.plugins</groupId>

? ? ? ? <artifactId>maven-site-plugin</artifactId>

? ? ? ? <configuration>

? ? ? ? ? <port>7002</port>

? ? ? ? ? <tempWebappDirectory>target/site/tempdir</tempWebappDirectory>

? ? ? ? </configuration>

? ? ? </plugin>

? ? </plugins>

? </build>

??

? ??

? <reporting>

??

? ? <plugins>

? ? ? <!--

? ? ? <plugin>

? ? ? ? <groupId>org.apache.maven.plugins</groupId>

? ? ? ? <artifactId>maven-javadoc-plugin</artifactId>

? ? ? ? <configuration>

? ? ? ? ? <docencoding>${file.encoding}</docencoding>

? ? ? ? ? <charset>${file.encoding}</charset>

? ? ? ? ? <encoding>${file.encoding}</encoding>

? ? ? ? </configuration>

? ? ? </plugin> ?

? ? ? ? ? ? --> ?

? ? ?<plugin>

? ? ? ?<groupId>org.codehaus.mojo</groupId>

? ? ? ?<artifactId>findbugs-maven-plugin</artifactId>

? ? ? ?<version>2.5.3</version>

? ? ? ?<!--?

<FindBugsFilter>

- <Match>

? <Bug pattern="URF_UNREAD_FIELD,UUF_UNUSED_FIELD,DLS_DEAD_LOCAL_STORE,UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD,RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE,URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD,RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE" />?

? </Match>

? </FindBugsFilter>

? ?-->

? ?

?

? ? ? ?<configuration>

? ? ? ? ? ?<!--?

? ? ? ? ? ?<omitVisitors>FindDeadLocalStores,UnreadFields</omitVisitors>

? ? ? ? ? ? -->

? ? ? ? ? ?<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>

? ? ? ? ? <findbugsXmlOutput>true</findbugsXmlOutput>

? ? ? ? ? <findbugsXmlWithMessages>true</findbugsXmlWithMessages>

? ? ? ? ? <xmlOutput>true</xmlOutput>

? ? ?<xmlOutputDirectory>target/site</xmlOutputDirectory>

? ? ? ?</configuration>

? ? </plugin> ? ? ? ? ? ? ? ??

? ? <