Tuesday, October 27, 2009

Checkstyle 5 and maven-checkstyle-plugin 2.3

I installed Eclipse Checkstyle plugin, which uses Checksytle 5. The latest maven-checkstyle-plugin, version 2.3, uses Checkstyle 4.4.

Everything works fine in Eclipse with Checkstyl5 5. Things got tricky when I ran "mvn checkstyle:checkstyle". If I didn't specify custom configuration, it uses the default template from Checkstyle 4.4. So the report will have a lot of false alarm because it did not recognize Java 5 checks. So I specified a custom configuration like this.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.3</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
</configuration>
</plugin>

The template, checkstyle.xml, is the default "Sun Checks" from Checkstyle 5.0. However, maven threw an error "Unable to instantiate JavadocPackageCheck". According to this post, it is because "You are trying to use a Checkstyle check that was introduced in Checkstyle 5.0. The Checkstyle Plugin currently uses Checkstyle 4.4."

It looks like we have to live with this discrepancy until maven-checkstyle-plugin 2.4, which is based on Checkstyle 5, is released.

No comments:

Post a Comment