在本地解析 Maven 中的 pmd 规则集
我尝试执行以下操作:
- 我为所有 Maven2 项目定义了一个标准 POM。
- 该 POM 包括要使用的工具以及 PMD 要使用的规则集。
- 我定义了一个属性来命名这些规则集。
直到知道这是有效的。我可以定义一个新项目 POM,将其用作我的标准 POM 的父级,并使用其中定义的规则集。我什至可以用另一个名称覆盖定义规则集的属性的定义。
我已将其定义为 auth-pmd-rule-set-3.x-v1-5.xml
而不是 pmd-rule-set-3.x-v1-5.xml< /code> (然后由 Maven2 选择),并在我的新项目中本地包含文件
auth-pmd-rule-set-3.x-v1-5.xml
(在 src/main/resources
)。但Maven没有找到它。错误消息看起来像这样:
[DEBUG] 准备规则集:auth-pmd-rule-set-3.x-v1-5.xml
[DEBUG] 之前:auth-pmd-rule-set-3.x-v1-5.xml 之后:auth-pmd-rule-set-3.x-v1-5.xml
[DEBUG] 在资源加载器 org.codehaus.plexus.resource.loa 中找不到资源“auth-pmd-rule-set-3.x-v1-5.xml” der.FileResourceLoader。
[DEBUG] 在资源加载器 org.codehaus.plexus.resource.loa 中找不到资源“auth-pmd-rule-set-3.x-v1-5.xml” der.JarResourceLoader。
[DEBUG] 在资源加载器 org.codehaus.plexus.resource.loa 中找不到资源“auth-pmd-rule-set-3.x-v1-5.xml” der.ThreadContextClasspathResourceLoader。
[DEBUG] URLResourceLoader:在“”查找“auth-pmd-rule-set-3.x-v1-5.xml”时出现异常 java.net.MalformedURLException:无协议:auth-pmd-rule-set-3.x-v1-5.xml
有没有任何技术可以达到我想要的效果?我想重新定义 PMD 应该使用的规则集,而不重复所有内容的整个定义。
I try do the following:
- I have a standard POM defined for all my Maven2 projects.
- That POM includes the tools to use, and for PMD the rulesets to use.
- I have defined a property that names these rulesets each.
Up to know this is working. I can define a new project POM, use there as parent my standard POM, and use the rulesets there defined. I am even able to override the definition of the property that defines the ruleset by another name.
I have defined that as auth-pmd-rule-set-3.x-v1-5.xml
instead of pmd-rule-set-3.x-v1-5.xml
(which is then choosen by Maven2) and have included the file auth-pmd-rule-set-3.x-v1-5.xml
locally in my new project (under src/main/resources
). But Maven does not find it. The error messages look like that:
[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
Is there any technique available to reach what I want? I want to redefine the ruleset PMD should use without repeating the whole definition of everything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据错误消息,您可能没有在 pom 中指定自定义规则集
auth-pmd-rule-set-3.x-v1-5.xml
的完整路径。根据文档,Based on the error message, it looks like you may not have specified the full path to your custom rule-set
auth-pmd-rule-set-3.x-v1-5.xml
in your pom. As per the docs,