Search code examples
mavencheckstylemaven-checkstyle-plugin

Maven lost checkstyle config


I try to connect custom checkstyle.xml config instead standart sun_checks.xml to this project.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>${checkstyle.version}</version>
    <configuration>
        <configLocation>src/main/resources/checkstyle.xml</configLocation>
    </configuration>
    <reportSets>
        <reportSet>
            <reports>
                <report>checkstyle</report>
            </reports>
        </reportSet>
    </reportSets>
</plugin>

But mvn -B clean verify checkstyle:checkstyle get output with sun_checks.xml

[INFO] There are 206 errors reported by Checkstyle 8.29 with sun_checks.xml ruleset.

Why <configLocation> is ignored, and hiw to fix it?


Solution

  • A solution is starting maven task with the config location argument:

    mvn checkstyle:check -Dcheckstyle.config.location=checkstyle.xml