如何使用gradle腳本生成findbugs報告?

[英]How to generate findbugs reports using gradle script?


I am trying to generate reports using findbugs plugin for that i wrote below mentioned gradle script.I am setting the destination folder for reports but respective folder not get generated.So, how to solve this issue.

我正在嘗試使用findbugs插件生成我在下面提到的gradle腳本中編寫的報告。我正在為報告設置目標文件夾,但未生成相應的文件夾。那么,如何解決這個問題呢?

I can able to generate reports manually by using export button but i want generate from the gradle script.

我可以使用export按鈕手工生成報告,但我希望從gradle腳本生成報告。

Is it possible to generate reports from gradle script?

是否可以從gradle腳本生成報告?

my gradle version - 2.2.1

我的第二級- 2.2.1版

task findbugs(type: FindBugs) {
    ignoreFailures = true
    effort = "max"
    reportLevel = "high"
    classes = files("${project.buildDir}/findbugs")
    source 'src'
    include '**/*.java'
    exclude '**/gen/**'

    reports {
        xml.enabled = true
        xml {
            destination "$project.buildDir/reports/findbugs/findbugs.xml"
            xml.withMessages true
        }
    }
    classpath = files()
}

1 个解决方案

#1


10  

I managed to get to run findbugs with the newest gradle with the following gradle script snippet:

我成功地運行了findbugs,最新的gradle腳本片段如下:

apply plugin: 'findbugs'

task customFindbugs(type: FindBugs) {
    ignoreFailures = true
    effort = "default"
    reportLevel = "medium"
    classes = files("$project.buildDir/intermediates/classes")
    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"
    }
}
// UPDATE: renamed the task to customFindbugs and made it automatically be called when build is called
build.dependsOn customFindbugs

My exclude.xml looks like the following:

我的排除。xml如下所示:

<FindBugsFilter>
    <Match>
       <Class name="~.*R\$.*"/>
    </Match>
    <Match>
        <Class name="~.*Manifest\$.*"/>
    </Match>
    <Match>
        <Class name="~.*_\$.*"/>
    </Match>
</FindBugsFilter>

whereas the last check is used to omit classes generated by AndroidAnnotations and you most likely won't use this check...

而最后的檢查是用來忽略android注解生成的類,並且您很可能不會使用這個檢查……

After that I'm able to run the task by

之后我就能完成任務了

./gradlew customFindbugs

or since the update of my code just by

或者因為我的代碼更新了。

./gradlew build

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2015/03/24/72063d95438c64300fa7abb2a4c04e4d.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com