4
votes

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.

1

1 Answers

4
votes

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.