Maven在构建失败/FindBugs上执行目标 [英] Maven execute a goal on build fail / FindBugs

查看:143
本文介绍了Maven在构建失败/FindBugs上执行目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经集成了FindBugs插件,以防出现错误导致构建失败.
然后使用精彩的答案,我将FindBugs配置为生成html报告(很难读取xml版本).
问题是我将failOnError属性设置为true,这意味着在发生错误的情况下构建将失败.

I have integrated FindBugs plugin to fail the build in case of bugs.
Then using that brilliant answer I configured FindBugs to generate html reports (xml version is barely readable).
The problem is that I have failOnError property set to true, which means that the build would fail in case of bug.

 .....
 <configuration>
        .....
        <failOnError>true</failOnError>
 </configuration>

然后将不会生成html报告.

And then no html report would be generated.

我阅读了有关 Maven构建生命周期的信息,并且没有诸如失败时执行"之类的内容(例如finally Java中的代码块).那么,有没有可能的解决方法? 难道它不是开箱即用的Maven功能吗?

I read about Maven build lifecycle and there is no such thing as "Execute on fail" (like finally block in Java). So, are there any possible workarounds? And shouldn't it be out-of the box Maven feature?

推荐答案

特别感谢 @SpaceTrucker 的解决方法

Special thanks to @SpaceTrucker for workaround suggestion. Here is the configuration I ended up with:

<plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>findbugs-maven-plugin</artifactId>
   <version>3.0.4</version>
   <configuration>
       <effort>Max</effort>
       <threshold>Low</threshold>
       <findbugsXmlOutputDirectory>${project.build.directory}/findbugs</findbugsXmlOutputDirectory>
   </configuration>
   <executions>
       <execution>
           <id>noFailOnError</id>
           <phase>verify</phase>
           <goals>
               <goal>check</goal>
           </goals>
           <configuration>
               <failOnError>false</failOnError>
           </configuration>
       </execution>
       <execution>
           <id>failOnError</id>
           <phase>install</phase>
           <goals>
               <goal>check</goal>
           </goals>
           <configuration>
               <failOnError>true</failOnError>
           </configuration>
       </execution>
   </executions>
</plugin> 

解决方案是在verifyinstall阶段中使用不同的配置. 请注意,根据该答案(到html)的转换是在verify阶段执行的.

The solution is to use different configurations in verify and install phases. Note, that according to that answer transformation (to html) is executed in verifyphase.

问题已提交提交用于html报告生成.

Issue was submitted for html report generation.

只需运行mvn findbugs:gui

这篇关于Maven在构建失败/FindBugs上执行目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆