我目前正在尝试创建一个基于Google one的checkstyle样式表,但有一些细微的调整(新的行长和缩进长度。我从Github (https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml)抓取了这个文件,但当我运行它时,我得到了以下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.1:check (default-cli) on project some-api: Execution default-cli of goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.1:check failed: given name COMPACT_CTOR_DEF -> [Help 1]
Maven插件配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle-maven-plugin.version}</version>
<configuration>
<consoleOutput>true</consoleOutput>
<configLocation>google_checks1.xml</configLocation>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>我是否需要包含一些依赖项?有没有更好的方法来实现我的目标?任何反馈都将不胜感激。
发布于 2020-11-05 17:27:47
上面的注释给出了解决这个问题的方法。需要包含依赖项来指定maven插件的checkstyle版本。
以下方法对我有效,修复了复制的谷歌检查中的COMPACT_CTOR_DEF错误
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.1</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.36</version>
</dependency>
</dependencies>
<configuration>
<configLocation>my_checks.xml</configLocation>
</configuration>
</plugin>https://stackoverflow.com/questions/63852780
复制相似问题