plugins {
id("checkstyle")
}
implementation("com.puppycrawl.tools:checkstyle:10.3.1")
checkstyleMain {
source = ["src/main/java"]
}
// Upgraded
checkstyle {
toolVersion "10.3.1"
configFile = file("config/checkstyle/checkstyle.xml")
}
Task :checkstyleMain FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':checkstyleMain'.
> A failure occurred while executing org.gradle.api.plugins.quality.internal.CheckstyleAction
> Unable to create Root Module: config {/Users/NOTiFY/IdeaProjects/GoStopHandle/config/checkstyle/checkstyle.xml}, classpath {null}.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 3s
openjdk version "18.0.1" 2022-04-19
/usr/local/Cellar/gradle/7.5/bin/gradle /usr/local/Cellar/gradle/7.5/libexec/bin/gradle /usr/local/Cellar/gradle/7.5/libexec/docs/ (2521 files) /usr/local/Cellar/gradle/7.5/libexec/lib/ (233 files) /usr/local/Cellar/gradle/7.5/libexec/src/ (8579 files)
/usr/local/Cellar/checkstyle/10.3.1/bin/checkstyle /usr/local/Cellar/checkstyle/10.3.1/libexec/checkstyle-10.3.1-all.jar
Have added:
gradle build clean --stacktrace
Errors:
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module TreeWalker - cannot initialize module JavadocMethod - Property 'scope' does not exist, please check the documentation
at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:478)
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:201)
at com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask.createRootModule(CheckstyleAntTask.java:424)
... 34 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module JavadocMethod - Property 'scope' does not exist, please check the documentation
at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:128)
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:201)
at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:473)
... 36 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Property 'scope' does not exist, please check the documentation
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.tryCopyProperty(AutomaticBean.java:227)
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:194)
at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:123)
... 38 more
CodePudding user response:
Fixed by upgraded "Checkstyle configuration for "Google Java Style" (Jul 8, 2022) at:
https://checkstyle.sourceforge.io/google_style.html https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
CodePudding user response:
This is Checkstyle's rather poor way of telling you there is something wrong with your configuration file (checkstyle.xml
). Do as is suggested by the output and run with --stacktrace
(or -S
for short) to see what the actual problem with the configuration is.
Also, the way to specify the Checkstyle version to use is like this:
checkstyle {
toolVersion('10.3.1')
}
What you did instead was to accidentally include the Checkstyle library on your own project classpath. So you are likely using the default version 8.x in Gradle right now.