Skip to content

Support Inline PMD Rule Configuration #660

@yeikel

Description

@yeikel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions