如何使用 spotbugs 创建自定义任务以在 gradle 中运行静态代码分析?

问题描述

我正在尝试创建自定义 spotbugs 任务来进行静态代码分析。因为它的大项目。在执行过程中,gradle 会抛出一些错误并最终导致构建失败。

我的自定义任务:


apply plugin: "com.github.spotbugs-base"

task customSpotbugs (type: com.github.spotbugs.snom.SpotBugsTask) {
    ignoreFailures = true
    effort = "default"
    reportLevel = "medium"
    classes = files("$project.buildDir/intermediates/javac/dxRelease/compileDxReleaseJavaWithJavac/classes")
    excludeFilter = file("$rootProject.rootDir/exclude.xml")
    reports {
        xml.enabled = false
        html.enabled = true
        html {
            stylesheet = 'fancy-hist.xsl'
        }
    }
}

dependencies {
    spotbugs 'com.github.spotbugs:spotbugs:4.0.0'
    spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.7.1'
}

错误

The following classes needed for analysis were missing:
  androidx.room.EntityDeletionorUpdateAdapter
  androidx.room.SharedsqliteStatement
  androidx.room.EntityInsertionAdapter
..........
> Task :Domain:customSpotbugs Failed
:Domain:customSpotbugs (Thread[Execution worker for ':' Thread 8,5,main]) completed. Took 2 hrs 0 mins 12.064 secs.

FAILURE: Build Failed with an exception.

* What went wrong:
Execution Failed for task ':Domain:customSpotbugs'.
> A failure occurred while executing com.github.spotbugs.snom.internal.SpotBugsRunnerForWorker$SpotBugsExecutor
   > Verification Failed: SpotBugs execution thrown exception

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

由于关于此的文档非常少,任何帮助将不胜感激.. 谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)