Stormcloud
Stormcloud

Reputation: 2307

How to generate a html report for findbugs with Maven 3.x

Has anybody managed to configure the findbugs Maven 3.x plugin to produce both an xml and html report? (I want the xml one for Jenkins and the html one for checking prior to a commit)

I've seen a lot of documentation on the web on setting this up, but most of it appears to be for Maven 2.x, which I know is configured differently (annoyingly the 2.x configuration is silently ignored by 3.x). I'm new to Maven, so I'm not sure if I'm doing something wrong or I'm following old instructions.

My pom contains the following:

</build>
    </plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>2.3.3</version>
            <configuration>
                <!-- findbugs:help -Ddetail=true  for outputDirectory:
                     Location where generated html will be created. 
                 -->
                <outputDirectory>${project.build.directory}/findbugs</outputDirectory>

                <xmlOutput>true</xmlOutput>
                <findbugsXmlWithMessages>true</findbugsXmlWithMessages>
                <xmlOutputDirectory>target/findbugs</xmlOutputDirectory>
                <failOnError>false</failOnError>
            </configuration>
        </plugin>
    </plugins>
</build>

Upvotes: 13

Views: 26316

Answers (2)

Corubba
Corubba

Reputation: 2243

The Findbugs-Plugin should be in the reportPlugins-Part of the maven-site-plugin.

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-site-plugin</artifactId>
      <configuration>
        <reportPlugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
          </plugin>
        </reportPlugins>
      </configuration>
    </plugin>
  </plugins>
</build>

And additionally, findbugs-report is only generated when the source is compiled before running mvn site. When generate the site, i use mvn test site so findbugs generate the report.

Upvotes: 22

rozky
rozky

Reputation: 2697

Check my answer for similar question where I suggest to use XSLT transformations shipped with Findbugs to generate HTML report during an execution of mvn clean install command.

Upvotes: 3

Related Questions