我在我的项目 pom.xml 中配置了 findbugs(和 checkstyle):
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<xmlOutput>true</xmlOutput>
<threshold>Normal</threshold>
<effort>Max</effort>
<debug>false</debug>
<excludeFilterFile>${basedir}/src/test/config/findbugs-exclude.xml</excludeFilterFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.4</version>
<configuration>
<suppressionsLocation>${basedir}/src/test/config/checkstyle-surpressions.xml</suppressionsLocation>
<testFailureIgnore>false</testFailureIgnore>
</configuration>
</plugin>
<!--.......-->
</plugins>
这就像一个魅力。'mvn site' 生成正确使用指定 excludeFileterFile 的 finbugs 报告。
问题是当我尝试使用声纳插件时。('mvn sonar:sonar') 声纳不使用上面指定的排除过滤器。(但它会正确使用 checkstyle 抑制文件)。
运行“mvn sonar:sonar”时来自控制台的信息:
警告:备用用户设置文件:C:\Users\rgi.m2\settings.xml 无效。使用默认路径。
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
....
[INFO] [findbugs:findbugs {execution: default-cli}]
[INFO] Using source root:
[INFO] <...edit...>\target\classes
[INFO] Using test source root:
[INFO] <...edit...>\target\test-classes
[INFO] Using maximum effort.
[INFO] Adding Source Directory: <...edit...>\src\main\java
[INFO] Using low threshold.
[INFO] Using FindBugs Version: 1.3.8
[INFO] Using low threshold.
[INFO] Using low threshold.
[INFO] Using the xdoc format
[INFO] Using maximum effort.
[INFO] Using low threshold.
[INFO] Using low threshold.
[INFO] Debugging is Off
[INFO] Using bug include filter <...edit...>\target\sonar\findbugs-include.xml
[INFO] Using bug exclude filter <...edit...>\target\sonar\findbugs-exclude.xml
[INFO] Printing Errors
.....
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
以及 target/sonar 目录中的 sonar-pom.xml:
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.2</version>
<dependencies>
<dependency>
<groupId>org.codehaus.sonar.runtime.rules-extensions</groupId>
<artifactId>parent</artifactId>
<version>20100210071723</version>
<type>pom</type>
</dependency>
</dependencies>
<configuration>
<suppressionsLocation>{...edit...}/src/test/config/checkstyle-surpressions.xml</suppressionsLocation>
<testFailureIgnore>false</testFailureIgnore>
<outputFileFormat>xml</outputFileFormat>
<consoleOutput>false</consoleOutput>
<enableRSS>false</enableRSS>
<skip>false</skip>
<failsOnError>false</failsOnError>
<configLocation>{...edit...}\target\sonar\checkstyle.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.0.1</version>
<configuration>
<xmlOutput>true</xmlOutput>
<threshold>Low</threshold>
<effort>Max</effort>
<debug>false</debug>
<excludeFilterFile>{...edit...}\target\sonar\findbugs-exclude.xml</excludeFilterFile>
<classFilesDirectory>{...edit...}\target\classes</classFilesDirectory>
<skip>false</skip>
<includeFilterFile>{...edit...}\target\sonar\findbugs-include.xml</includeFilterFile>
</configuration>
</plugin>
请注意,sonar-pom.xml 中的 checkstyle 是指项目配置中的文件,但 findbugs exclude 文件是来自 sonar 的虚拟空文件。
任何人都知道如何让声纳使用项目 pom.xml 中定义的 finbugs 排除文件?
提前谢谢
/罗伊