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")
}
任务:checkstyleMain失败
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版本"18.0.1“2022-04-19
/usr/local/c业力/gradle/7.5/bin/gradle /usr/local/Cellar/gradle/7.5/libexec/bin/gradle /usr/local/c业力/gradle/7.5/libexec/docs/ (2521个文件)/usr/local/files/gradle/7.5/libexec/lib/(233个文件) /usr/local/Cellar/gradle/7.5/libexec/src/ (8579个文件)
/usr/local/Cellar/checkstyle/10.3.1/bin/checkstyle /usr/local/Cellar/checkstyle/10.3.1/libexec/checkstyle-10.3.1-all.jar
增加了:
gradle build clean --stacktrace
错误:
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
发布于 2022-07-20 08:59:24
通过升级"Google Java样式“的Check样式配置(2022年7月8日),修正了:
https://checkstyle.sourceforge.io/google_style.html https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
发布于 2022-07-19 11:05:28
这是Checkstyle告诉您配置文件(checkstyle.xml
)有问题的非常糟糕的方式。按照输出的建议,使用--stacktrace
(简称-S
)运行,看看配置的实际问题是什么。
此外,指定要使用的Check样式版本的方法如下所示:
checkstyle {
toolVersion('10.3.1')
}
相反,您所做的是意外地在您自己的项目类路径中包含了Checkstyle库。因此,您现在可能正在使用Gradle中的默认版本8.x。
https://stackoverflow.com/questions/73012720
复制相似问题