maven-pmd-plugin icon indicating copy to clipboard operation
maven-pmd-plugin copied to clipboard

Support Inline PMD Rule Configuration

Open yeikel opened this issue 5 months ago • 0 comments

Currently, the plugin requires rules to be specified via a ruleset file using the <rulesets> element. This approach is inflexible, especially in multi-module Maven projects with parent/child relationships. When a child project inherits plugin configuration from the parent, it does not inherit the ruleset file itself, leading to configuration drift and maintenance challenges.

It should be possible to create inline rule configuration using something like <rules> element, such as:

<rules>
    <rule ref="category/java/codestyle.xml/UnnecessaryImport"/>
</rules>

This configuration could be resolved at runtime and create a <rulesets> file as needed

This would allow parent POMs to define PMD rules that are inherited by child modules without relying on external files, improving maintainability and consistency across large projects.

Additional context

I am aware that https://maven.apache.org/plugins/maven-pmd-plugin/examples/multi-module-config.html is an alternative, but it seems like an overkill that we need a project just to host the rules

Checkstyle supports this via https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/inline-checker-config.html

yeikel avatar Oct 01 '25 23:10 yeikel