在本地解析 Maven 中的 pmd 规则集

发布于 2024-10-15 19:48:24 字数 1244 浏览 0 评论 0原文

我尝试执行以下操作:

  1. 我为所有 Maven2 项目定义了一个标准 POM。
  2. 该 POM 包括要使用的工具以及 PMD 要使用的规则集。
  3. 我定义了一个属性来命名这些规则集。

直到知道这是有效的。我可以定义一个新项目 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:

  1. I have a standard POM defined for all my Maven2 projects.
  2. That POM includes the tools to use, and for PMD the rulesets to use.
  3. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨曦÷微暖 2024-10-22 19:48:24

根据错误消息,您可能没有在 pom 中指定自定义规则集 auth-pmd-rule-set-3.x-v1-5.xml 的完整路径。根据文档

规则集可能驻留在
类路径、文件系统或 URL。为了
与捆绑在一起的规则集
PMD工具,不需要特别指定
文件的绝对路径。它将
通过插件解决。但如果
规则集是自定义规则集,您
需要指定其绝对路径。

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,

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文