I have a problems with Checkstyle plugin for java. I need to fail the whole multimodule project in case of any violations. In parent pom.xml I have the following
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ss.ita</groupId>
<artifactId>jresume</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>JResume</name>
<modules>
<module>common</module>
<module>persistence</module>
<module>business</module>
<module>logging</module>
<module>web</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.16</version>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>dev/checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
My checkstyle.xml is placed in dev folder.
When I run my project with
mvn clean install
It prints the list of all violations. But It cannot fail the whole project. It prints SUCCESS for all modules. I tried to use failsOnError and failOnViolation both. But It didn't work.In plugin documentation there are these requirements:
Where I go wrong. Maybe I wrote my pom.xml in a wrong way. Please help me solve this problem.
Probably you forget
<configuration>
...
<violationSeverity>warning</violationSeverity>
...
</configuration>
violationSeverity
: The lowest severity level that is considered a violation. Valid values are "error", "warning" and "info".
The default value is error
, which means warning
will not make maven build fail.
see more details in:
http://maven.apache.org/plugins/maven-checkstyle-plugin/check-mojo.html#violationSeverity
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