Maven + FindBugs-在高优先级警告时失败 [英] Maven + FindBugs - fail on high-priority warning

查看:211
本文介绍了Maven + FindBugs-在高优先级警告时失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个大型项目上使用Maven和FindBugs.如果FindBugs产生任何 high 优先级错误,我想使Maven构建失败.可以在pom.xml中设置一个简单的参数,以使其在 errors 上失败,但是我需要在高优先级警告时使它失败.任何建议都是巨大的!

I am using Maven and FindBugs on a large project. I would like to cause a maven build to fail if FindBugs yields any high priority errors. A simple parameter can be set within a pom.xml to fail on errors but I need it to fail on high priority warnings. Any suggestions would be huge!

推荐答案

我怀疑您已经知道该插件可用的findbugs:check目标. 将阈值配置项设置为高"应该将目标限制为仅在高优先级"问题上失败.

I suspect you are already aware of the findbugs:check goal available for the plugin. Setting the threshold configuration item to High should limit the goal to failing only on High priority issues.

这是pom.xml的示例配置片段

Here is an example configuration snippet for your pom.xml

<build>
...
<plugins>
...
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>findbugs-maven-plugin</artifactId>
  <version>2.4.0</version>
  <executions>
    <execution>
      <id>failing-on-high</id>
      <phase>process-test-resources</phase>
      <goals>
        <goal>check</goal>
      </goals>
      <configuration>
        <threshold>High</threshold>
        <onlyAnalyze>com.example.-</onlyAnalyze>
      </configuration>
    </execution>
  </executions>
</plugin>
...
</plugins>
...
</build>

在此代码段中,我仅对以'com.example'开头的软件包进行了分析,并将阈值设置为高",并配置了findbugs:check在自动化测试之前运行.

In this snippet, I have limited analysis to packages beginning with 'com.example' and set the threshold to High, and configured the findbugs:check to run before the automated tests.

触发构建失败的示例:

[INFO] --- findbugs-maven-plugin:2.4.0:findbugs (findbugs) @ channels ---
[INFO] Fork Value is true
     [java] Warnings generated: 29
[INFO] Done FindBugs Analysis....
[INFO] 
[INFO] <<< findbugs-maven-plugin:2.4.0:check (failing-on-high) @ channels <<<
[INFO] 
[INFO] --- findbugs-maven-plugin:2.4.0:check (failing-on-high) @ pricing ---
[INFO] BugInstance size is 29
[INFO] Error size is 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

另请参见: http://mojo.codehaus.org/findbugs -maven-plugin/check-mojo.html 以获得您可以包括的其他配置选项.您可能希望包括xml报告,以便CI服务器可以使用xmlOutput配置捕获它以便轻松报告故障.

See also: http://mojo.codehaus.org/findbugs-maven-plugin/check-mojo.html for other configuration options you can include. You will probably want to include the xml report so that your CI server can capture it for reporting the failures easily, using the xmlOutput configuration.

这篇关于Maven + FindBugs-在高优先级警告时失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆