I'm using the Maven Checkstyle plugin in version 3.0.0 and Checkstyle 6.18.
This is my initial configuration:
<properties>
<maven.checkstyle.plugin.version>3.0.0</maven.checkstyle.plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven.checkstyle.plugin.version}</version>
<configuration>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
</plugins>
</build>
Running mvn checkstyle:checkstyle
will fail the build since there are checkstyle errors. This is expected.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check (default-cli) on project demo: Failed during checkstyle execution: There are 311 errors reported by Checkstyle 6.18 with sun_checks.xml ruleset. -> [Help 1]
However, when I use google_checks.xml
which comes bundled with the Maven plugin the build succeeds without any error (target/checkstyle-report.xml
still shows the issues though).
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven.checkstyle.plugin.version}</version>
<configuration>
<configLocation>google_checks.xml</configLocation>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
My expectation would be that the build fails when I use the google_checks.xml
configuration. What am I doing wrong?
UPDATE (04.05.2018): I've raised a bug for this.
In google_checks.xml, the severity is marked as failure. Changing that to error causes the check to fail.
Original:
<property name="severity" value="warning"/>
Updated:
<property name="severity" value="error"/>
In your Maven configuration, you can also tweak on which severity to fail:
<configuration>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
<violationSeverity>warning</violationSeverity>
<linkXRef>false</linkXRef>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With