我已经为 pmd 编写了一个自定义规则(用 java 编写)。我希望在我的项目中执行这条规则。我已将规则添加到 pmd.xml:
<rule name="MyRule"
message="some message"
class="MyRule">
<description>
some description
</description>
<properties>
<property name="someproperty" value="1" />
</properties>
<priority>3</priority>
</rule>
问题就出现了。我不知道在哪里放置规则定义 - MyRule.class。我试图向 pmd 添加 Maven 依赖项:
<dependency>
<groupId>pmd.rules</groupId>
<artifactId>CustomJavaRules</artifactId>
<version>1.0</version>
</dependency>
其中 CustomJavaRules 是包含 MyRule.class 的 jar Artifact (来自本地“file://”存储库)。该 jar 已找到并加载,但 MyRule.class 对于 pmd 仍然不可见。
我试图将类放在不同的目录中......结果很差。
有人遇到过类似的问题吗?
最佳答案
已解决:
<dependency>
<groupId>pmd.rules</groupId>
<artifactId>CustomJavaRules</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>path/to/my/jar/CustomJavaRules.jar</systemPath>
</dependency>
关于java - 将自定义 java 规则添加到 pmd maven 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18595491/