我尝试执行以下操作:
直到知道这是有效的。我可以定义一个新的项目 POM,将那里用作我的标准 POM 的父项,并使用那里定义的规则集。我什至能够覆盖通过另一个名称定义规则集的属性的定义。
我已将其定义为
auth-pmd-rule-set-3.x-v1-5.xml
而不是 pmd-rule-set-3.x-v1-5.xml
(然后由 Maven2 选择)并包含文件 auth-pmd-rule-set-3.x-v1-5.xml
在我的新项目本地(在 src/main/resources
下)。但是Maven没有找到它。错误消息如下所示:[DEBUG] Preparing ruleset: auth-pmd-rule-set-3.x-v1-5.xml
[DEBUG] Before: auth-pmd-rule-set-3.x-v1-5.xml After: auth-pmd-rule-set-3.x-v1-5.xml
[DEBUG] The resource 'auth-pmd-rule-set-3.x-v1-5.xml' was not found with resourceLoader org.codehaus.plexus.resource.loa der.FileResourceLoader.
[DEBUG] The resource 'auth-pmd-rule-set-3.x-v1-5.xml' was not found with resourceLoader org.codehaus.plexus.resource.loa der.JarResourceLoader.
[DEBUG] The resource 'auth-pmd-rule-set-3.x-v1-5.xml' was not found with resourceLoader org.codehaus.plexus.resource.loa der.ThreadContextClasspathResourceLoader.
[DEBUG] URLResourceLoader: Exception when looking for 'auth-pmd-rule-set-3.x-v1-5.xml' at '' java.net.MalformedURLException: no protocol: auth-pmd-rule-set-3.x-v1-5.xml
有什么技术可以达到我想要的吗?我想重新定义 PMD 应该使用的规则集,而不重复所有内容的整个定义。
最佳答案
根据错误消息,您可能没有指定自定义规则集的完整路径 auth-pmd-rule-set-3.x-v1-5.xml
在你的 pom.根据 docs ,
The rule sets may reside in the classpath, filesystem or at a URL. For rule sets that are bundled with the PMD tool, you do not need to specificy the absolute path of the file. It will be resolved by the plugin. But if the rule set is a custom rule set, you need to specify its absolute path.
关于maven-2 - 在本地解析 Maven 中的 pmd 规则集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4901158/