java-使用findBug插件发现错误时如何使Maven构建失败
作者:互联网
我刚刚在项目pom中添加了maven find bug插件:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.4</version>
<configuration>
<xmlOutput>true</xmlOutput>
<!-- Optional directory to put findbugs xdoc xml report -->
<xmlOutputDirectory>target/site</xmlOutputDirectory>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>findbugs</goal>
</goals>
</execution>
</executions>
</plugin>
为了报告,我在下面添加了:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.4</version>
</plugin>
现在,当我使用install运行maven时,会在以下警告我:
> [INFO] --- findbugs-maven-plugin:3.0.4:findbugs (default) @
> MovesouqBackend --- [INFO] Fork Value is true
> [java] Warnings generated: 12 [INFO] Done FindBugs Analysis....
它显示有12个错误作为警告并成功建立.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] --------------------------------------------------------------
----------
当发现针对findbug插件的任何警告时,我想使构建失败,并且我希望将此警告显示为错误.
我已经通过插件documentation了,但是没有任何事情.
请帮忙.
解决方法:
将您的配置编辑为:
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>findbugs</goal>
</goals>
<configuration>
<failOnError>true</failOnError>
<threshold>High</threshold>
</configuration>
</execution>
</executions>
希望对您有帮助!
标签:maven,maven-plugin,maven-3,findbugs,java 来源: https://codeday.me/bug/20191026/1934799.html