Findbugs android gradle plugin

后端 未结 4 1490
天涯浪人
天涯浪人 2021-02-08 15:12

I have an android project. I want to introduce findbugs in my project as a gradle plugin. I tried to edit the project\'s build.gradle as below.

4条回答
  •  轮回少年
    2021-02-08 16:16

    Just place this in your modules build.gradle.

    apply plugin: 'findbugs'
    
    task customFindbugs(type: FindBugs) {
        ignoreFailures = false
        effort = "max"
        reportLevel = "low"
        classes = files("$project.buildDir/intermediates/classes")
    
        // Use this only if you want exclude some errors
        excludeFilter = file("$rootProject.rootDir/config/findbugs/exclude.xml")
    
        source = fileTree('src/main/java/')
        classpath = files()
    
        reports {
            xml.enabled = false
            xml.withMessages = true
            html.enabled = !xml.isEnabled()
            xml.destination "$project.buildDir/outputs/findbugs/findbugs-output.xml"
            html.destination "$project.buildDir/outputs/findbugs/findbugs-output.html"
        }
    }
    
    build.dependsOn customFindbugs
    

    Then after changing directory to your project path from command line, use

    ./gradlew build
    

    The error report will be in $project.buildDir/outputs/findbugs/findbugs-output.html

提交回复
热议问题