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")
}
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?
Just place this in your modules
build.gradle
.Then after changing directory to your project path from command line, use
The error report will be in
$project.buildDir/outputs/findbugs/findbugs-output.html
I modified a little bit Nevin Raj Victor's answer.
This version generates a findbug task for each build variant, and (more importantly) it correctly creates dependencies on their respective compilation tasks. Indeed, findbugs requires the code to be compiled before it can be analyzed.
After this, you can run
Or other findbugs tasks on different variants, depending on your configuration.
Please take a look at this project https://github.com/Piasy/AndroidCodeQualityConfig.
This project including lint, pmd, findbugs, checkstyle, jacoco code coverage.And support project with submodules.
I see some problems with your configuration:
2.0.1
version use latest3.0.1
reportLevel
tolow
instead ofhigh
to report all the violationsincludeFilter
orexcludeFilter
- these are only whitelist and blacklists of checks if you need some customizationTo run analysis just invoke
gradle findbugsMain
. Results should be visible in the output.