我正在尝试设置一个 maven 项目,以便能够使用两个不同的规则集运行 checkstyle:一个用于 main,一个用于测试。我想做的是类似的事情:
<reporting>
<plugins>
<!-- One configuration for main -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>checkstyle</configLocation>
</configuration>
</plugin>
<!-- But a different set of rules for test -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
<configLocation>checkstyle-test.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>
我已经成功地运行了一个版本或另一个版本,但不能同时运行两个版本。包括尝试将它们绑定到不同的执行阶段,但似乎经验法则是最后一个定义是唯一使用的。
所以我要么想:
- 理想情况下 - 有两个可以独立运行的独立 checkstyle 配置文件
或者
- 有一个单一的 checkstyle 配置,使用配置属性 includeTestSourceDirectory 同时检查 main 和 test,但有一些规则有选择地应用于 main/test 或另一个。