我正在运行 Maven 3.0.5 并尝试使用 maven checkstyle 插件,但我无法让它正确解析我的配置文件。在我的 POM 的报告部分,我有
<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>
在我的 checkstyle.xml 文件中,我将抑制过滤器定义为
<module name="SuppressionFilter">
<!-- <property name="file" value="${checkstyle.suppressions.file}"/>
-->
<property name="file" value="${suppressions.file}"/>
</module>
当我运行 checkstyle:checkstyle 目标时,我收到一个错误,即未定义 suppresss.file。我可以让它在 Eclipse 或 ant 下运行,但是当我尝试将它与 maven 一起使用时,我无法设置要设置的属性。我还尝试使用 checkstyle.suppressions.file 值并将其设置为 propertyExpansion 标记或 suppresssFile 标记。
有没有办法从 Maven 中做到这一点。我正在寻找的最终结果是能够在 Eclipse、Ant 和 Maven 中使用相同的规则文件。这将是我要指出的一个通用文件。同时,我希望能够在每个单独的项目中放置一个 suppresss.xml 文件,这将允许抑制过滤器由项目控制。