Gradle not inferring findbugs version correctly

We recently performed a build system upgrade to gradle 2.2.1 and Oracle java 8u25. The CM build machines and some developer machines work fine. But on other developer machines, the build fails with:

The version of FindBugs (0.0.0) inferred from FindBugs classpath is too low to work with currently used Java version (1.8). Please use higher version of FindBugs. Inspected FindBugs classpath: [yjp-controller-api-redist.jar, ant.jar, findbugs-ant.jar, annotations.jar, jdepend-2.9.jar, jFormatString.jar, jcip-annotations.jar, jaxen-1.1.6.jar, findbugs-3.0.0.jar, commons-lang-2.6.jar, asm-debug-all-5.0.2.jar, bcel-6.0-SNAPSHOT.jar, dom4j-1.6.1.jar, jsr305.jar]

We search for the findbugs jar with:

findbugs externalDirectory.matching {include "findbugs/3.0.0/lib/*.jar"}

findbugs itself is configured:

apply plugin: 'findbugs'
...
findbugs {
        toolVersion = "3.0.0"
        sourceSets = [sourceSets.main]
        ignoreFailures = true
        effort = "max"
        reportLevel = "high"
          tasks.withType(FindBugs) {
            reports {
                xml.enabled = false
                html.enabled = true
            }
         }
    }

Shouldn’t gradle infer the the version number from the jar name findbugs-3.0.0.jar?

Can we set the version explicitly somehow?

The error message is a bit confusing because from looking at the code it should detect the FindBugs version to be 3.0.0 and not 0.0.0.

What exactly do you mean by “We search for the findbugs jar with: ‘findbugs externalDirectory.matching {include “findbugs/3.0.0/lib/*.jar”}’”? Why do you need to redefine the ‘findbugs’ configuration?

Marcin,

We have a copy of findbugs downloaded from http://findbugs.sourceforge.net stored in a separate directory from the build. The line

findbugs externalDirectory.matching {include "findbugs/3.0.0/lib/*.jar"}"

points us at that directory.

Mark

I think that the problem might originate from the fact that you have ‘findbugs-ant.jar’ on the classpath as well. Iteration order over files will be different on different file systems and on some ‘findbugs-ant.jar’ will be analysed instead of ‘findbugs-3.0.0’. Where is this ant support file coming from?

Can you please explain what is the type of ‘externalDirectory’ in your snippet of code? Is it a configuration?

Why do you manually pull FindBugs into some local dir? Are you not allowed to use Maven Central? Why don’t you simply define the required version using ‘findbugs.toolVersion’ and then allow Gradle to resolve FindBugs from Maven Central for you?

We’re not allowed to use Maven Central.

We’ll try renaming the findbugs-ant.jar. Thanks.

findbugs-ant.jar -> findbugs-ant-3.0.0.jar did not work for the afflicted hosts.

To answer:

Can you please explain what is the type of externalDirectory in your snippet of code? Is it a configuration?

That line is in our main build.gradle file.

Renaming ‘findbugs-ant.jar’ to ‘findbugs-ant-3.0.0.jar’ will not fix it because the version detection pattern is ‘findbugs-(.*).jar’ which means that you cannot have any other jar file that starts with ‘findbugs’ on the classpath. I would suggest renaming it to ‘ant-findbugs.jar’.

So the solution was to rename findbugs-ant.jar to ant-findbugs.jar while also naming findbugs.jar to findbugs-3.0.0.jar

Success.

Thanks, Marcin.