Created
February 9, 2015 03:19
-
-
Save AndrewReitz/434798c41ce421ad6432 to your computer and use it in GitHub Desktop.
Android Checkstyles
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
// 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