How to add maven-checkstyle to existing project?

233 Views Asked by At

I tried adding the maven-checkstyle-plugin to my project, but it does not produce any results:

<project>
....
    <build>
        <plugins>
            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-checkstyle-plugin</artifactId>
               <version>3.2.0</version>
                <configuration>
                    <configLocation>google_checks.xml</configLocation>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

mvn checkstyle:checkstyle or mvn checkstyle:check results in:

[INFO] You have 0 Checkstyle violations.

Which is essentially not true, because I added violations explicit in my code.

So my guess is that checkstyle is not running the analyser properly over my code (that resides just normal in /src/main/resources). What could I do?

Would I maybe have to add the google_checks.xml file explicit to my classpath??

1

There are 1 best solutions below

0
On

If the violations are warnings, you will need to add:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    [...]
        <configuration>
            <violationSeverity>warning</violationSeverity>
            <failsOnError>true</failsOnError>
            [...]