My gradle file:
apply plugin: 'checkstyle'
check.dependsOn 'checkstyle'
def configDir = "${project.rootDir}/quality"
checkstyle {
toolVersion = '7.2'
}
task checkstyle(type: Checkstyle) {
configFile file("$configDir/checkstyle/checkstyle.xml")
configProperties.checkstyleSuppressionsPath = file("$configDir/checkstyle/suppressions.xml").absolutePath
source 'src'
include '**/*.java'
exclude '**/gen/**'
classpath = files()
}
I'm using this version of the google java style guide: https://github.com/checkstyle/checkstyle/commit/a1e1403df4478e161a1c9c5daf7607c362eca1f5
Gradle version: 3.3
checkstyle version 6.9 and lower:
Error:Execution failed for task ':app:checkstyle'. > Unable to create a Checker: cannot initialize module TreeWalker - Property 'scope' in module ParameterName does not exist, please check the documentation
checkstyle version 6.10 and higher:
Error:Execution failed for task ':app:checkstyle'. > Unable to create a Checker: configLocation{path}, classpath {null}.
It works with this checkstyle for some reason: https://github.com/google/google-api-java-client/blob/dev/checkstyle.xml
If you still have issues, please see http://checkstyle.sourceforge.net/report_issue.html#How_to_report_a_bug .
@SUPERCILEX
I'm using this version of the google java style guide: a1e1403
You may be trying to use a configuration that is too new for the version of checkstyle you are currently using. You are referencing code that is in version 7.3-SNAPSHOT which is not even released and your grade version is 7.2.
It works with this checkstyle for some reason: https://github.com/google/google-api-java-client/blob/dev/checkstyle.xml
That uses maven-checkstyle-plugin which defaults to Checkstyle version 6.11.2 and I didn't see an override in the pom.
I would start with the google config file that supports 7.2 and do any modification to fit your needs.
https://github.com/checkstyle/checkstyle/blob/5cb0f9d39aad100b31c28cd27c3f90a6835ed21d/src/main/resources/google_checks.xml#L104 (7.2 google config)
Please use version that is embeded to checkstyle jar.
You can wait till release of 7.3 , that will be at the end of the month.
Thanks! That explains things.
在buildscipt 里面的 dependencies 中添加 classpath 'com.puppycrawl.tools:checkstyle:7.1.2' , classpath 就不会为null
Most helpful comment
It works with this checkstyle for some reason: https://github.com/google/google-api-java-client/blob/dev/checkstyle.xml