Sunday, 8 September 2013

Maven checkstyle plugin with properties

Maven checkstyle plugin with properties

I am running Maven 3.0.5 and am trying to use the maven checkstyle plugin
but I am not able to get it to parse my configuration file correctly. In
the reporting section of my POM, I have
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.10</version>
<configuration>
<propertyExpansion>suppressions.file=${basedir}/suppressions.xml</propertyExpansion>
<configLocation>file:///${basedir}/../buildTools/checkstyle/checkstyle-5.0-checks.xml</configLocation>
</configuration>
</plugin>
In my checkstyle.xml file, I have suppressions filter defined as
<module name="SuppressionFilter">
<!-- <property name="file" value="${checkstyle.suppressions.file}"/>
-->
<property name="file" value="${suppressions.file}"/>
</module>
When I run the checkstyle:checkstyle goal, I am getting an error that
suppressions.file is not defined. I can get this to run under either
Eclipse or ant but when I try to use this with maven, I can not get the
property to be set. I have also tried using the
checkstyle.suppressions.file value and setting it with the
propertyExpansion tag or the suppressionsFile tag.
Is there a way to do this out of Maven. The end result that I am looking
for is to be able to user the same rules file in Eclipse, Ant, and Maven.
This would be a common file that I would point to. At the same time, I
want to be able to put a suppressions.xml file in each individual project
that would allow the suppressions filter to be controlled by project.

No comments:

Post a Comment