-
-
Save bonnyfone/39575e86e3c71a4615726b1954d07157 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to use it inside any gradle build | |
apply from: "quality.gradle" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<FindBugsFilter> | |
<Match> | |
<Class name="~.*R\$.*" /> | |
</Match> | |
<Match> | |
<Class name="~.*Manifest\$.*" /> | |
</Match> | |
</FindBugsFilter>*R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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