Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FindBugs stopped working after upgrading Android Gradle Plugin from 3.1.3 to 3.2.0

I use FindBugs for static code analysis in my Android projects. The setup is the following:

quality.gradle

plugins.apply('findbugs')

task findbugs(type: FindBugs) {
    ignoreFailures = false
    effort = 'max'
    reportLevel = 'high' // Report only high priority problems.

    classes = files("${project.projectDir}/build/intermediates/classes")
    source = fileTree('src/main/java')

    classpath = files()

    reports {
        xml.enabled = true
        html.enabled = false
    }

    excludeFilter = rootProject.file('quality/findbugs.xml')
} 

build.gradle:

subprojects {
    afterEvaluate {
        project.apply from: '../quality/quality.gradle'
        tasks.findByName('findbugs').dependsOn('assemble')
        tasks.findByName('check').dependsOn('findbugs')
    }
}

But after I upgraded the Gradle Android Plugin from 3.1.3 to 3.2.0 the build started failing:

./gradlew clean build

> Task :app:findbugs FAILED
No files to be analyzed

...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:findbugs'.
> Failed to run Gradle FindBugs Worker
   > Process 'Gradle FindBugs Worker 6' finished with non-zero exit value 1

Downgrading to 3.1.3 makes the build pass again. I haven't found anything related in the changelog of the Gradle Android Plugin. Can anybody point me out what's wrong with the plugin or my setup?

like image 499
makovkastar Avatar asked Oct 02 '18 12:10

makovkastar


People also ask

Is FindBugs deprecated?

The deprecated FindBugs plugin has been removed. As an alternative, you can use the SpotBugs plugin from the Gradle Plugin Portal.

How do I fix failed to apply plugin com Android internal application?

Updated June 24, 2020 You need to update to the latest gradle version to solve this issue. It might show a popup asking your permission to update gradle , please update and it will download the latest distribution automatically and the issue will be resolved.

What is FindBugs Android?

findbugs-android This plugin provides those tasks already configured for you. In addition, the plugin automatically excludes Generated classes from Android databinding library, android resource, Butterknife and Dagger 2. If you want more added to this list or want it configurable, open an issue.


1 Answers

After a short investigation, I found out that the location of Java class files has changed from build/intermediates/classes to build/intermediates/javac. The new FindBugs configuration:

task findbugs(type: FindBugs) {
    ...
    classes = files("${project.projectDir}/build/intermediates/javac")
   ...
} 

The strange thing that this breaking change isn't mentioned in the Android Gradle Plugin changelog, or in the Gradle changelog.

like image 147
makovkastar Avatar answered Oct 29 '22 16:10

makovkastar