Skip to content

Instantly share code, notes, and snippets.

@AndrewReitz
Created February 9, 2015 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewReitz/434798c41ce421ad6432 to your computer and use it in GitHub Desktop.
Save AndrewReitz/434798c41ce421ad6432 to your computer and use it in GitHub Desktop.
Android Checkstyles
// Checkstyle
apply plugin: 'checkstyle'
checkstyle {
showViolations true
configFile = rootProject.file('codequality/checkstyle.xml')
}
def isLibraryPlugin = project.plugins.findPlugin('android-library') != null
def setupCheck = { variant ->
def name = variant.buildType.name
def checkstyle = project.tasks.create "checkstyle${name.capitalize()}", Checkstyle
checkstyle.dependsOn variant.javaCompile
checkstyle.source variant.javaCompile.source
checkstyle.classpath = project.fileTree(variant.javaCompile.destinationDir)
checkstyle.exclude('**/BuildConfig.java')
checkstyle.exclude('**/R.java')
project.tasks.getByName("check").dependsOn checkstyle
}
if (isLibraryPlugin) {
android.libraryVariants.all { variant -> setupCheck(variant) }
} else {
android.applicationVariants.all { variant -> setupCheck(variant) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment