1. Introduction

In this post, I would demo how to solve the following error when you run mvn commands on a project with findbugs plugin:

[ERROR] Failed to execute goal org.codehaus.mojo:findbugs-maven-plugin:3.0.2:findbugs (findbugs) on project project1: Unable to parse configuration of mojo org.codehaus.mojo:findbugs-maven-plugin:3.0.2:findbugs for parameter pluginArtifacts: Cannot assign configuration entry 'pluginArtifacts' with value '${plugin.artifacts}' of type java.util.Collections.UnmodifiableRandomAccessList to property of type java.util.ArrayList -> [Help 1]

2. Environment

  • Maven 3.6.0+
  • findbugs-maven-plugin 3.0.2

3. The pom.xml

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>findbugs-maven-plugin</artifactId>
    <version>3.0.2</version>
    <configuration>
        <!--
            Enables analysis which takes more memory but finds more bugs.
            If you run out of memory, changes the value of the effort element
            to 'Low'.
        -->
        <effort>Max</effort>
        <!-- Build fail if problems are found -->
        <failOnError>false</failOnError>
        <!-- Reports all bugs (other values are medium and max) -->
        <threshold>Low</threshold>
        <!-- Produces XML report -->
        <xmlOutput>true</xmlOutput>
        <!-- Configures the directory in which the XML report is created -->
        <findbugsXmlOutputDirectory>${project.build.directory}/findbugs</findbugsXmlOutputDirectory>
    </configuration>
    <executions>
        <!--
            Ensures that FindBugs inspects source code when project is compiled.
        -->
        <execution>
            <id>analyze-compile</id>
            <phase>compile</phase>
            <goals>
                <goal>check</goal>
            </goals>
        </execution>
    </executions>
</plugin>

4. How to solve this problem?

4.1 Downgrade your maven version

Because you are using 3.0.2 of findbugs-maven-plugin,it’s not compatible with maven 3.6.0+

Check your maven version by the following command:

➜  conf mvn --version
Apache Maven 3.6.0 ....
Maven home: /Users/bswen/tech/maven/apache-maven-3.6.0
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre

If you are using maven version greater than 3.6.0, you should downgrade the version of maven by downloading an old version from its official site.

The recommended version is 3.3.9.

4.2 Upgrade your findbugs-maven-plugin version

Upgrade your findbugs-maven-plugin to 3.0.4+, it’s compatible with your 3.6.0 maven installation.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>findbugs-maven-plugin</artifactId>
    <version>3.0.4</version>
    ...
</plugin>

5. Summary

Be careful if you want to use findbugs-maven-plugin with the latest version of maven.