Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven checkstyle use wrong style

I have the following configuration in my 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>

It is set to use the Google coding style, however is use the sun_checks.xml file (which is the default for this plugin):

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

What is wrong in my POM configuration?

Thank you in advance.

like image 629
Nakrule Avatar asked Nov 16 '25 11:11

Nakrule


1 Answers

The configuration should be in <build> and not in <reporting>:

<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>
like image 74
Nakrule Avatar answered Nov 19 '25 10:11

Nakrule