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

bvn4nwqk  于 2021-06-27  发布在  Java
关注(0)|答案(0)|浏览(549)

我试图创建自定义spotbug任务来进行静态代码分析。因为它的大项目。在执行过程中,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.

由于这方面的文档非常少,任何帮助都将不胜感激。。谢谢您

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题