如何使用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
智能推荐

注意!

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



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

赞助商广告