我有一个带有以下结构的maven的java应用程序:
parent
| - pom.xml
| - child
| - pom.xml
| - analyzers
| - pmdrules.xml
| - checkstyle.xml
我已经在父 pom.xml 中配置了 PMD 和 checkstyle。对于 PMD,规则集配置如下,它适用于父模块和子模块:
<configuration>
<rulesets>
<ruleset>${basedir}/../analyzers/pmdrules.xml</ruleset>
</rulesets>
</configuration>
但是,对于 checkstyle,如果我以相同的方式配置 configLocation,它会在父级或子级中失败。我必须使用自定义属性来克服这个问题。
<configuration>
<!-- Below config with ${projectRootDir}, a custom property always pointing to parent root works fine -->
<configLocation>${projectRootDir}/analyzers/checkstyle.xml</configLocation>
<!-- Below configurations with ${basedir} will fail build for child -->
<!--<configLocation>${basedir}/analyzers/checkstyle.xml</configLocation>-->
<!-- Below configurations with ${basedir} will fail build for parent -->
<!--<configLocation>${basedir}/../analyzers/checkstyle.xml</configLocation>-->
</configuration>
这是一个复制器示例 - https://github.com/ramtech123/pocs/blob/master/myapp-parent-module/pom.xml
我尝试在调试模式下运行 Maven 构建。从日志中,对我来说,实际的 PMD 执行似乎只针对子模块发生,因此它正在顺利进行。
有人可以帮助我了解根本原因,并改进我的配置。
提前致谢。