Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

findbugs maven plugin site vs check

I'm just trying to wrap my head around a couple of things.

If I have this in my masterpom:

<reporting>
 <plugins>
  <plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>findbugs-maven-plugin</artifactId>
   <version>2.5.2</version>
   <configuration>
      <failOnError>false</failOnError>
      <threshold>High</threshold>
      <effort>Default</effort>
      <xmlOutput>true</xmlOutput>
      <skip>${skipFindBugs}</skip>
      <xmlOutputDirectory>target/reports/findbugs</xmlOutputDirectory>
      <excludeFilterFile>
          src/main/resources/findbugs-exclude-filters.xml
      </excludeFilterFile>
   </configuration>
  </plugin>
 </plugins>
</reporting>

My findbugs-exclude-filters.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
     <Match>
        <Bug category="I18N" />
     </Match>
</FindBugsFilter>

QUESTIONS

Why does clean verify site report 2 warnings, but clean verify findbugs:check return 14 bugs? I don't understand what the difference is.

Why does my site report warn about I18N:DM_DEFAULT_ENCODING

like image 878
Snekse Avatar asked Nov 14 '25 12:11

Snekse


1 Answers

The findbugs-maven-plugin plugin needs to be configured in BOTH the <reporting><plugins/></reporting> and <build><plugins/></build> section. Have experimented with this all sorts of ways and the only way I have been able to get it to work is to duplicate findbugs-maven-plugin configuration.

So try adding something like the following in your pom.xml:

<build>
 <plugins>
  <plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>findbugs-maven-plugin</artifactId>
   <version>2.5.2</version>
   <configuration>
      <failOnError>false</failOnError>
      <threshold>High</threshold>
      <effort>Default</effort>
      <xmlOutput>true</xmlOutput>
      <skip>${skipFindBugs}</skip>
      <xmlOutputDirectory>target/reports/findbugs</xmlOutputDirectory>
      <excludeFilterFile>
          src/main/resources/findbugs-exclude-filters.xml
      </excludeFilterFile>
   </configuration>
  </plugin>
 </plugins>
</build>

Note that it's a cut and paste of what you posted inside of the <reporting/> block. I have not tested the above. I'm just trying to give you a general idea here.

The Reporting section of the POM Reference states that:

And the subtler difference is that a plugin configuration under the reporting element works as build plugin configuration, although the opposite is not true (a build plugin configuration does not affect a reporting plugin).

I have been able to make this work with Maven 3.0.5. I have not tried it on 3.1.0 yet.

like image 147
pedrohdz Avatar answered Nov 17 '25 09:11

pedrohdz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!