1

I know a similar question has been asked here, but my setup within pom.xml is a bit different and that answer isn't working for my case.

I have findbugs set up so that when I run [mvn compile findbugs:findbugs], I get the default findbugsXML.xml generated. I would like to get an html file generated so that it's more readable. Below is what I've added to pom.xml in order to get findbugs set up. I'm not sure why the html file isn't being generated given that I've included that specification when making the pom.xml edits. The below was added into the plugins section of build in pom.xml.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>findbugs-cookbook</artifactId>
<packaging>jar</packaging>
<version>3.0.1</version>
<name>FindBugs Maven plugin Cookbook</name>
<description>FindBugs Maven plugin Cookbook</description>
<licenses>
    <license>
        <name>Apache License 2.0</name>
        <url>http://www.apache.org/licenses/LICENSE-2.0</url>
    </license>
</licenses>
<properties>
    <jdk.version>1.7</jdk.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
    <finalName>findbugs</finalName>
    <resources>
        <resource>
            <filtering>true</filtering>
            <directory>src/main/resources</directory>
        </resource>
    </resources>
    <plugins>       
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>3.0.1</version>
        </plugin>
    <!--</plugins>
    <plugins> -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>${jdk.version}</source>
                <target>${jdk.version}</target>
                <encoding>${project.build.sourceEncoding}</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.0.1</version>
            <configuration>
                <encoding>${project.build.sourceEncoding}</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>3.0.1</version>
            <configuration>
                <effort>Max</effort>
                <failOnError>false</failOnError>
                <findbugsXmlOutputDirectory>${project.build.directory}/findbugs</findbugsXmlOutputDirectory>
                <threshold>Low</threshold>
                <xmlOutput>true</xmlOutput>
            </configuration>
            <executions>
                <execution>
                    <id>analyze-compile</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
        </plugin> 
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>xml-maven-plugin</artifactId>
            <version>1.0</version>
            <configuration>
                <transformationSets>
                    <transformationSet>
                        <dir>${project.build.directory}/findbugs</dir>
                        <outputDir>${project.build.directory}/findbugs</outputDir>

                        <!--<stylesheet>fancy-hist.xsl</stylesheet> -->
                        <!--<stylesheet>default.xsl</stylesheet> -->
                        <!--<stylesheet>plain.xsl</stylesheet>-->
                        <!--<stylesheet>fancy.xsl</stylesheet>-->
                        <!--<stylesheet>summary.xsl</stylesheet>-->

                        <fileMappers>
                            <fileMapper
                                    implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                <targetExtension>.html</targetExtension>
                            </fileMapper>
                        </fileMappers>
                    </transformationSet>
                </transformationSets>
            </configuration>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>transform</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.google.code.findbugs</groupId>
                    <artifactId>findbugs</artifactId>
                    <version>3.0.1</version>
                </dependency>
            </dependencies>
        </plugin>    
    </plugins>
</build>

I'm using Apache Maven 3.2.3 and Java version: 1.8.0_20. I've also included findbugs-3.0.1.jar and findbugs-maven-plugin-3.0.1.jar in my apache-maven-3.2.3 directory.

Community
  • 1
  • 1
armin
  • 11
  • 4

1 Answers1

0

There are 4 variables:

  • java/JDK version
  • maven version
  • findbugs plugin version
  • findbugs version

With java-1.7, it works on my Windows system with the specified versions of maven, findbugs, findbugs-maven-plugin. Essentially older versions of findbugs does not work with java 8.

With java-1.8, it works if I use version 3.0.1 of findbugs and findbugs-maven-plugin.

Since you have bound findbugs goals to compile task, you just need to run mvn clean compile.

Raghuram
  • 51,854
  • 11
  • 110
  • 122
  • Unfortunately, that still hasn't fixed the problem for me. I have updated the pom.xml contents and provided more information on the version I'm using for the 4 variables you mentioned. Any thoughts on what may be my problem? Still no success with generating html reports in my target folder.. just xml. – armin Jul 19 '15 at 02:57
  • Are you getting any errors? Also, you should be running `mvn compile` (I've updated the answer) since you have already bound `findbugs` goals to `compile` phase. – Raghuram Jul 20 '15 at 05:41