检查样式 10.3.1 无法在 Gradle 7.5 上运行


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 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/地方/地窖/gradle/7.5/bin/gradle/usr/local/Cellar/gradle/7.5/libexec/bin/gradle/usr/local/地窖/gradle/7.5/libexec/docs/(2521个文件)/usr/local/地窖/gradle/7.5/libexec/lib//usr/local/cellar/gradle/7.5/libexec/src/

/usr/地方/地窖/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

这是Checkstyle告诉您配置文件(checkstyle.xml)有问题的相当糟糕的方式。按照输出的建议,使用--stacktrace(或简称-S)运行,看看配置的实际问题是什么。

同样,指定要使用的Checkstyle版本的方法如下:

checkstyle {
toolVersion('10.3.1')
}

您所做的是意外地将Checkstyle库包含在您自己的项目类路径中。因此,您可能会使用默认版本8。

修复了"Google Java style"的"Checkstyle"配置。(2022年7月8日)在:

https://checkstyle.sourceforge.io/google_style.htmlhttps://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml

相关内容

  • 没有找到相关文章

最新更新