maven-checkstyle-plugin 不会在自定义规则上执行

Rui*_* Ma 2 maven-checkstyle-plugin

我正在尝试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>
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

Ant*_*imo 7

只是有同样的问题。我看到该文件已在 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 版本

希望它有帮助:)