2017-02-24 84 views
3

发现的bug我刚才说的Maven发现错误插件在我的项目POM:如何让Maven构建失败时使用findBug插件

<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> 

现在,当我使用安装运行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,但没有关于它。 请帮忙。

回答

3

编辑您的配置为:

<executions> 
    <execution> 
    <phase>package</phase> 
     <goals> 
     <goal>findbugs</goal> 
     </goals> 
     <configuration> 
     <failOnError>true</failOnError> 
     <threshold>High</threshold> 
     </configuration> 
    </execution> 
</executions> 

希望它可以帮助你!

+0

不。当我试图 failOError和阈值时,它给了我BUILD BUILD SUCCESS。你试过了吗? –

+1

工作。当目标更改为时检查

相关问题