Created
September 2, 2015 05:44
-
-
Save sinergy/a5d98f1e6f297e40c149 to your computer and use it in GitHub Desktop.
add FindBugs Gradle task into Android project
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' | |
afterEvaluate { | |
def variants = plugins.hasPlugin('com.android.application') ? | |
android.applicationVariants : android.libraryVariants | |
variants.each { variant -> | |
def task = tasks.create("findBugs${variant.name.capitalize()}", FindBugs) | |
task.group = 'verification' | |
task.description = "Run FindBugs for the ${variant.description}." | |
task.excludeFilter = rootProject.file('config/findbugs-filter.xml') | |
task.effort = 'max' | |
task.reportLevel = 'high' | |
task.reports { | |
xml.enabled = false | |
html.enabled = true | |
xml { | |
destination "$project.buildDir/reports/findbugs/findbugs.xml" | |
} | |
html { | |
destination "$project.buildDir/reports/findbugs/findbugs.html" | |
} | |
} | |
def variantCompile = variant.javaCompile | |
task.classes = fileTree(variantCompile.destinationDir) | |
task.source = variantCompile.source | |
task.classpath = variantCompile.classpath.plus(project.files(android.bootClasspath)) | |
task.dependsOn(variantCompile) | |
tasks.getByName('check').dependsOn(task) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
android-findbugs.gradle
into your project.gradle
directory might be good place for it.build.gradle
filefor example:
apply from: rootProject.file('gradle/android-findbugs.gradle')