本文介绍了FindBugs的机器人摇篮插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android项目。我想介绍 FindBugs的在我的项目作为一个摇篮插件。我试图修改该项目的 build.gradle 如下图所示。

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.

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
           }
dependencies {
    classpath 'com.android.tools.build:gradle:1.0.0+'
    classpath 'io.fabric.tools:gradle:1.+'

    }
}

apply plugin: "java"
apply plugin: "findbugs"
findbugs {
  toolVersion = "2.0.1"
  sourceSets = [sourceSets.main]
  ignoreFailures = false
  reportsDir = file("$project.buildDir/findbugsReports")
  effort = "max"
  reportLevel = "high"
  includeFilter =     file("$rootProject.projectDir/config/findbugs/includeFilter.xml")
  excludeFilter = file("$rootProject.projectDir/config/findbugs/excludeFilter.xml")
 }

这是插件是否正确? 做任何事情neeed添加或删除?现在我应该做的就是这个结果 FindBugs的检查?我应该使用什么摇篮命令?

Is this plugin correct? Does anything neeed to be added or removed?Now what should I do to get the results of this findbugs check?What gradle command should I use?

推荐答案

只是把这个在你的模块 build.gradle

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

错误报告将在 $ project.buildDir /输出/ FindBugs的/ FindBugs的-output.html

这篇关于FindBugs的机器人摇篮插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-13 11:57