【问题标题】:Maven checkstyle use wrong styleMaven checkstyle 使用错误的样式
【发布时间】:2020-03-17 10:31:04
【问题描述】:

我的pom.xml 中有以下配置:

<reporting>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-checkstyle-plugin</artifactId>
      <version>2.17</version>
      <configuration>
        <configLocation>google_checks.xml</configLocation>
        <failOnViolation>true</failOnViolation>
        <enableFilesSummary>false</enableFilesSummary>
      </configuration>
    </plugin>
  </plugins>
</reporting>

它设置为使用 Google 编码风格,但使用 sun_checks.xml 文件(这是此插件的默认设置):

mvn checkstyle:check | grep sun
[INFO] There are 913 errors reported by Checkstyle 8.19 with sun_checks.xml ruleset.

我的 POM 配置有什么问题?

提前谢谢你。

【问题讨论】:

    标签: maven checkstyle


    【解决方案1】:

    配置应该在&lt;build&gt;而不是&lt;reporting&gt;

    <build>
        <plugins>
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.17</version>
            <configuration>
              <configLocation>google_checks.xml</configLocation>
              <encoding>UTF-8</encoding>
              <consoleOutput>true</consoleOutput>
              <failsOnError>true</failsOnError>
            </configuration>
            <executions>
              <execution>
                <id>validate</id>
                <phase>validate</phase>
                <goals>
                  <goal>check</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    

    【讨论】:

      猜你喜欢
      • 2015-02-05
      • 2012-08-29
      • 1970-01-01
      • 2015-07-25
      • 2016-07-31
      • 2015-11-29
      • 2019-12-02
      • 2019-03-25
      相关资源
      最近更新 更多