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

你离开我真会死。 提交于 2019-12-08 19:34:01

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/52608215/findbugs-stopped-working-after-upgrading-android-gradle-plugin-from-3-1-3-to-3-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!