我刚刚在我的项目 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个bug警告,构建成功。
[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>
希望对你有帮助!
关于java - 使用 findBug 插件发现错误时如何使 Maven 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42440948/