【问题标题】:Creating a customized version of the Google Java Checkstyle XML file创建 Google Java Checkstyle XML 文件的自定义版本
【发布时间】:2020-12-30 07:33:06
【问题描述】:

我目前正在尝试创建一个基于 Google 样式表的 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>

我需要包含一些依赖项吗?有没有更好的方法来实现我的目标?任何反馈将不胜感激。

【问题讨论】:

标签: java maven checkstyle maven-checkstyle-plugin


【解决方案1】:

上面的评论提供了解决此问题的方法。 需要包含依赖来指定maven插件的checkstyle版本。

以下内容对我有用,修复了复制的 google 检查中的 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-07
    • 1970-01-01
    • 2014-07-23
    • 2019-02-14
    • 1970-01-01
    相关资源
    最近更新 更多