Gradle中集成 FindBugs

参考资料

Gradle 中 Findbugs插件的帮助文档
https://docs.gradle.org/current/dsl/org.gradle.api.plugins.quality.FindBugs.html
报告模板

build.gradle

建议在每个 project 的 module 下的 build.gradle 中进行修改

  • 添加插件
apply plugin: 'com.android.application'
//下面是添加的
apply plugin: 'findbugs'
  • 添加 task :
task findbugs(type: FindBugs) 
{    
    //excludeFilter file('findbugs-filter.xml')
    classes = fileTree('build/intermediates/classes/debug')
    source = fileTree('src/main/java/')
    classpath = files()
    effort = 'max'
    reports {        
        xml.enabled false
        html.enabled true
        html.stylesheet resources.text.fromFile('findbugs-template.xsl')
    }
}

注意, 这里的findbugs-template.xsl是报告的模板, 可以参考前文给出的模板例子.

使用

gradle findbugs

会看到report 生成的路径信息

> FindBugs rule violations were found. See the report at: file:///Users/.../app/build/reports/findbugs/findbugs.html
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,107评论 19 139
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,993评论 6 342
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,003评论 25 709
  • Gradle对于很多开发者来说有一种既熟悉又陌生的感觉,他是离我们那么近,以至于我每天做项目都需要他,但是他又是离...
    阿_希爸阅读 9,619评论 10 199
  • 【淘淘作业本】2017年3月5日 作业一:发掘空性 老公晚上老是跟儿子玩的很晚都不睡觉。 1、一切都是对的。 老公...
    淘淘的简书阅读 184评论 0 0