I have been working on trying to get Checkstyle working in Maven in the Eclipse Indigo IDE for a while. Finally, I thought I will ask for some expert advise on this.
I am using Eclipse Indigo and trying to configure Checkstyle to run in Maven.
Below is a snippet of my pom.xml. Only checkstyle:checkstyle is working and creating the reports.
<profile>
<id>checkstyle-profile</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<configLocation>${basedir}/src/main/resources/maven_checks.xml</configLocation>
</configuration>
<executions>
<execution>
<id>checkstyle-check</id>
<goals>
<goal>check</goal>
</goals>
<phase>compile</phase> <!-- Default is "verify" -->
<configuration>
<violationSeverity>error</violationSeverity>
<maxAllowedViolations>7000</maxAllowedViolations>
<failOnViolation>true</failOnViolation>
<failsOnError>true</failsOnError>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<configLocation>${basedir}/src/main/resources/maven_checks.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>
Some of the things that are not working are:
checkstlye:check. I get below error. What target should I run so that the checkstyle:check runs.
Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.9.1:check (default-cli) on project zzz-web: You have 5950 Checkstyle violationsHoping for a quick response.
Thanks in advance. Varma
You have bound check goal of maven checkstyle plugin to compile phase. That being the case, you would need to run mvn compile for your configurations to be used. Running mvn checkstyle:check will use default configurations. This looks like the most likely case for items 1 and 2 above.
Even if you were to run mvn compile the above configuration will still fail the build on account of the two configuration entries failOnViolation and failOnError since both of them are set to true. Removing these entries and running mvn compile should pass the build so long as the number of violations are less than 7000.
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