views:

417

answers:

2

Hi,

I have a maven 2 project and I want to configure my Checkstyle report plugin so that only some of my classes are analysed. I have found the maven.checkstyle.excludes property, but despite passing this as a command line parameter (using "-D=maven.checkstyle.excludes=...") I can't get it to work. I can't find anything on the Plugin documentation page. Ideally I want to be able to set this in the section of my POM.

Can anyone help?

TIA

Cheers, Andrew

+2  A: 

If this question is about Maven 2, then the property is excludes and takes a comma-separated list of Ant patterns. So either pass this on the command line:

-Dexcludes=**/generated/**/*

Or set it up in the plugin configuration:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-checkstyle-plugin</artifactId>
   <configuration>
       <excludes>**/generated/**/*</excludes>
   </configuration>
</plugin>

Another option would be to use a suppression filter.

For example you could use the SuppressionCommentFilter to suppress audit events between a comment containing CHECKSTYLE:OFF and a comment containing CHECKSTYLE:ON (then just add these comments to the classes or parts of the code you don't want to check).

Pascal Thivent
Thanks Pascal. This works. I needed to ignore everything in my particular project, so just set <excludes>**</excludes>. Thanks very much for your help.
Andrew Harmel-Law
A: 

I don't understand why it is not consistent across all the plugins. In the PMD plugin for example you need to put every expression in separate exclude element, e.g.:

<excludes>
    <exclude>**/a/b/**/*.java</exclude>
    <exclude>**/c/d/**/*.java</exclude>
</excludes>
coffy