I cant seem to figure out how to get maven-checkstyle-plugin to print warnings to the console when I run the check goal.
If I configure as:
<module name="Checker">
<module name="TreeWalker">
<module name="NPathComplexity">
<property name="max" value="5" />
<property name="severity" value="warning" />
</module>
</module>
</module>
...i see nothing in console and the check does not fail. If I change the severity to error, the check fails.
Any ideas? Am I missing something?
Plugin config is as follows
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<logViolationsToConsole>true</logViolationsToConsole>
<configLocation>
rules.xml</configLocation>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
To view to violation report, go to Window -> Show View -> Other, and search for Checkstyle. Options for Violations and Violations Chart should be displayed.
To generate the Checkstyle report as part of the Project Reports, add the Checkstyle Plugin in the <reporting> section of your pom. xml . Then, execute the site phase to generate the report.
I had a similar problem. This configuration worked for me.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<consoleOutput>true</consoleOutput>
</configuration>
<executions>
<execution>
<id>checkstyle</id>
<goals>
<goal>checkstyle</goal>
</goals>
<phase>prepare-package</phase>
</execution>
</executions>
</plugin>
Adding <violationSeverity>warning</violationSeverity>
to the <configuration>
in the pom.xml worked for me:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<logViolationsToConsole>true</logViolationsToConsole>
<configLocation>checkstyle.xml</configLocation>
<violationSeverity>warning</violationSeverity>
</configuration>
<executions>
...
</executions>
...
</plugin>
Also, I have this in my checkstyle.xml:
<module name="Checker">
<module name="SeverityMatchFilter">
<!-- report all violations except ignore -->
<property name="severity" value="ignore"/>
<property name="acceptOnMatch" value="false"/>
</module>
...
</module>
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