Allow pmd rule set in Maven locally

I am trying to do the following:

  • I have a standard POM defined for all my Maven2 projects.
  • What POM includes tools for use, and for PMD - used ruleset.
  • I defined a property that names these rule sets each.

To find out that it works. I can define a new POM project, use it as a parent for my standard POM, and use the rules set there. I can even override a property definition that defines a rule set with a different name.

I determined that as auth-pmd-rule-set-3.x-v1-5.xml instead of pmd-rule-set-3.x-v1-5.xml (which is then selected by Maven2) and included the auth-pmd-rule-set-3.x-v1-5.xml file auth-pmd-rule-set-3.x-v1-5.xml locally in my new project (under src/main/resources ). But Maven doesn't find him. The error messages are as follows:

[DEBUG] Preparing a rule set: 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] Resource 'auth-pmd-rule-set-3.x-v1-5.xml' not found with resourceLoader org.codehaus.plexus.resource.loa der.FileResourceLoader.

[DEBUG] Resource 'auth-pmd-rule-set-3.x-v1-5.xml' not found with resourceLoader org.codehaus.plexus.resource.loa der.JarResourceLoader.

[DEBUG] Resource 'auth-pmd-rule-set-3.x-v1-5.xml' not found with resourceLoader org.codehaus.plexus.resource.loa der.ThreadContextClasspathResourceLoader.

[DEBUG] URLResourceLoader: Exception while searching 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 technical possibility to achieve what I want? I want to redefine the rule set that PMD should use without repeating the entire definition of everything.

+4
source share
1 answer

Based on the error message, it looks like you did not specify the full path to your custom auth-pmd-rule-set-3.x-v1-5.xml in your pom. According to the docs ,

Rule sets can reside in a classpath, file system, or URL. For rule sets that are associated with the PMD Tool, you do not need an absolute file path. This will be resolved by the plugin. But if the rule set is a custom rule set, you must specify its absolute path.

+4
source

Source: https://habr.com/ru/post/1338460/


All Articles