maven-checkstyle-plugin 不执行自定义规则
maven-checkstyle-plugin does not execute on custom rules
我正在尝试按照官方文档添加如下所示的 maven-checkstyle-plugin
作为构建检查的一部分。但是我尝试过,我无法使用自定义规则将其设置为 运行。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
checkstyle.xml
恰好包含在此 google_checks.xml 中找到的确切内容。
在执行 mvn checkstyle:check
时,我总是被
击中
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.0:check (default-cli) on project XXXXXXX: Failed during checkstyle configuration: cannot initialize module LineLength - Property 'fileExtensions' does not exist, please check the documentation
刚遇到同样的问题。
我看到文件已经在 5 天前更改了。
您需要使用来自相同版本的 checkstyle 的文件,例如,对于版本 8.12 的 checkstyle 选择 git 标签为 8.12
的分支
https://github.com/checkstyle/checkstyle/blob/checkstyle-8.12/src/main/resources/google_checks.xml
此文件具有 8.12 版的正确语法定义,例如同一文件的最新版本不适用于 8.12 版
希望对您有所帮助:)
这里的问题是最新的,v3.1.0 maven-checkstyle-plugin 只支持 checkstyle
版本 v8.19:
This version of the plugin uses Checkstyle 8.19 by default and
requires Java 8. But you can upgrade the version used at runtime.
所以你需要使用属于v9.19 checkstyle
的checkstyle.xml
。
不过好消息是你可以重新配置maven插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>...choose your version...</version>
</dependency>
</dependencies>
</plugin>
详情请查看官方documentation。
我正在尝试按照官方文档添加如下所示的 maven-checkstyle-plugin
作为构建检查的一部分。但是我尝试过,我无法使用自定义规则将其设置为 运行。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
checkstyle.xml
恰好包含在此 google_checks.xml 中找到的确切内容。
在执行 mvn checkstyle:check
时,我总是被
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.0:check (default-cli) on project XXXXXXX: Failed during checkstyle configuration: cannot initialize module LineLength - Property 'fileExtensions' does not exist, please check the documentation
刚遇到同样的问题。 我看到文件已经在 5 天前更改了。
您需要使用来自相同版本的 checkstyle 的文件,例如,对于版本 8.12 的 checkstyle 选择 git 标签为 8.12
的分支https://github.com/checkstyle/checkstyle/blob/checkstyle-8.12/src/main/resources/google_checks.xml
此文件具有 8.12 版的正确语法定义,例如同一文件的最新版本不适用于 8.12 版
希望对您有所帮助:)
这里的问题是最新的,v3.1.0 maven-checkstyle-plugin 只支持 checkstyle
版本 v8.19:
This version of the plugin uses Checkstyle 8.19 by default and requires Java 8. But you can upgrade the version used at runtime.
所以你需要使用属于v9.19 checkstyle
的checkstyle.xml
。
不过好消息是你可以重新配置maven插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>...choose your version...</version>
</dependency>
</dependencies>
</plugin>
详情请查看官方documentation。