Custom Checkstyle config for Java projects.
- Put
checkstyle.xml
to$rootDir/config/checkstyle
. - Add the following to the Gradle build file:
plugins {
id "checkstyle"
}
checkstyle {
toolVersion "10.12.4"
sourceSets = [] // Don't check anything with Checkstyle during 'check' task
}
task checkstyle(type: Checkstyle) {
source "src"
classpath = files()
}
plugins {
checkstyle
}
checkstyle {
toolVersion = "10.12.4"
sourceSets = listOf() // Don't check anything with Checkstyle during 'check' task
}
tasks.register("checkstyle", Checkstyle::class) {
source = fileTree("$rootDir/src")
classpath = files()
}
Check last version here: https://checkstyle.sourceforge.io/releasenotes.html
Run ./gradlew checkstyle
.