Problem
You use Checkstyle with custom rules in a Maven build.
While the check via mvn install
is performed with the custom ruleset, a check via mvn checkstyle:check
or checkstyle:checkstyle
is performed with the standard (Sun + Maven) ruleset.
With some tinkering you can get it to check no rules, but not to use the custom ruleset.
Solution
Your configuration probably looks something like this (from the official Maven Checkstyle usage[1]):
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.15</version> <executions> <execution> <id>validate</id> <phase>validate</phase> <configuration> <configLocation>checkstyle.xml</configLocation> <encoding>UTF-8</encoding> <consoleOutput>true</consoleOutput> <failsOnError>true</failsOnError> <linkXRef>false</linkXRef> </configuration> <goals> <goal>check</goal> </goals> </execution> </executions> </plugin>
Move the <configuration>
up, so it becomes a child of <plugin>
, like this:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.15</version> <configuration> <configLocation>checkstyle.xml</configLocation> <encoding>UTF-8</encoding> <consoleOutput>true</consoleOutput> <failsOnError>true</failsOnError> <linkXRef>false</linkXRef> </configuration> <executions> <execution> <id>validate</id> <phase>validate</phase> <goals> <goal>check</goal> </goals> </execution> </executions> </plugin>
Sources
[1] https://maven.apache.org/plugins/maven-checkstyle-plugin/usage.html
Leave a Reply