config/android-checkstyle.gradle
author Da Risk <da_risk@geekorum.com>
Fri, 08 May 2020 21:33:19 -0400
changeset 1 831cffa9c991
child 6 99ad8c14fec2
permissions -rw-r--r--
source import

apply plugin: 'checkstyle'
check.dependsOn 'checkstyle'

checkstyle {
    toolVersion = '6.19'
}

task checkstyle(type: Checkstyle) {
    description = "Check Java style with Checkstyle"
    configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml")
    source = javaSources()
    classpath = files()
    ignoreFailures = true
}

def javaSources() {
    def files = []
    android.sourceSets.each { sourceSet ->
        sourceSet.java.each { javaSource ->
            javaSource.getSrcDirs().each {
                if (it.exists()) {
                    files.add(it)
                }
            }
        }
    }
    return files
}