I have just added maven find bug plugin in my project pom:
<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>
for reporting I have added below:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.4</version>
</plugin>
Now when i run maven using install it gives me warnings below:
> [INFO] --- findbugs-maven-plugin:3.0.4:findbugs (default) @
> MovesouqBackend --- [INFO] Fork Value is true
> [java] Warnings generated: 12 [INFO] Done FindBugs Analysis....
It shows there are 12 bugs as warning and build successful.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] --------------------------------------------------------------
----------
I want to make build fail when there is any warning found against findbug plugin and I want to show this warning as error. I have gone through plugin documentation but there is nothing about it. Please help.
FindBugs is a static code analysis tool which identifies problems found from Java code. We can integrate FindBugs into our build process by using the FindBugs Maven plugin. This blog post identifies four typical use cases and describes how we can configure the FindBugs Maven plugin to support each use case.
Generate FindBugs Report As Part of the Project Reports To generate the FindBugs report as part of the Project Reports, add the FindBugs plugin in the <reporting> section of your pom. xml. Then, execute the site plugin to generate the report.
The report will be generated in the folder target/site in the project directory under the name findbugs. html. You can also run the mvn findbugs:gui command to launch the GUI interface to browse the generated reports for the current project.
PMD looks at the source code to find possible bugs, unused code, suboptimal code, complicated expressions, and duplicated code. FindBugs looks at the generated byte code to find possible errors.
Edit your configuration as:
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>findbugs</goal>
</goals>
<configuration>
<failOnError>true</failOnError>
<threshold>High</threshold>
</configuration>
</execution>
</executions>
Hope it helps you!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With