gpt4 book ai didi

java - 使用 findBug 插件发现错误时如何使 Maven 构建失败

转载 作者:塔克拉玛干 更新时间:2023-11-01 23:04:36 24 4
gpt4 key购买 nike

我刚刚在我的项目 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com