本文介绍了将Android Gradle插件从3.1.3升级到3.2.0后,FindBugs停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android项目中使用FindBugs进行静态代码分析.设置如下:

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')
    }
}

但是在我将Gradle Android插件从3.1.3升级到3.2.0之后,构建开始失败:

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

降级到3.1.3使构建再次通过.我在更改日志中未找到任何相关内容Gradle Android插件.有人可以指出插件或设置的问题吗?

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?

推荐答案

经过简短调查,我发现Java类文件的位置已从build/intermediates/classes更改为build/intermediates/javac.新的FindBugs配置:

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")
   ...
}

Android Gradle插件中未提及这一重大变化的奇怪之处更改日志,或在Gradle 更改日志中.

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

这篇关于将Android Gradle插件从3.1.3升级到3.2.0后,FindBugs停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 20:48