我在一个大型项目中使用 Maven 和 FindBugs。如果 FindBugs 产生任何结果,我想导致 Maven 构建失败high优先级错误。可以在 pom.xml 中设置一个简单的参数来失败errors但我需要它在高优先级警告上失败。任何建议都会很大!
我怀疑您已经知道该插件可用的 findbugs:check 目标。
将阈值配置项设置为“高”应将目标限制为仅在高优先级问题上失败。
这是 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 配置为在自动化测试之前运行。
触发构建失败的示例:
[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 http://mojo.codehaus.org/findbugs-maven-plugin/check-mojo.html对于您可以包含的其他配置选项。您可能希望包含 xml 报告,以便 CI 服务器可以使用 xmlOutput 配置捕获它以轻松报告故障。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)