Skip to content

Instantly share code, notes, and snippets.

@danielgomezrico
Last active September 5, 2016 11:44
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danielgomezrico/fb103d6b395ca359c1a5 to your computer and use it in GitHub Desktop.
Save danielgomezrico/fb103d6b395ca359c1a5 to your computer and use it in GitHub Desktop.
Gradle / Android tasks to run findbugs and pmd static code checkers after assembleDebug. thanks to https://gist.github.com/rciovati/8461832
// How to use it inside any gradle build
apply from: "quality.gradle"
<FindBugsFilter>
<Match>
<Class name="~.*R\$.*" />
</Match>
<Match>
<Class name="~.*Manifest\$.*" />
</Match>
</FindBugsFilter>*R
apply plugin: 'findbugs'
apply plugin: 'pmd'
findbugs {
ignoreFailures = true
reportsDir = file("$project.buildDir/outputs/")
reportLevel = "medium"
effort = "max"
}
pmd {
ignoreFailures = true
reportsDir = file("$project.buildDir/outputs/")
}
task findbugs(type: FindBugs, dependsOn: assembleDebug) {
description 'Run findbugs'
group 'verification'
classes = fileTree("build/intermediates/classes/debug/")
source = fileTree('src/main/java')
classpath = files()
effort = 'max'
excludeFilter = file("../setup/findbugs_exclude.xml")
reports {
xml.enabled = false
html.enabled = true
}
}
task pmd(type: Pmd, dependsOn: assembleDebug) {
description 'Run pmd'
group 'verification'
ruleSets = ["java-basic", "java-braces", "java-strings", "java-design", "java-unusedcode"]
source = fileTree('src/main/java')
reports {
xml.enabled = false
html.enabled = true
}
}
check.doLast {
project.tasks.getByName("findbugs").execute()
project.tasks.getByName("pmd").execute()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment