You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Simon Taddiken <si...@gmail.com> on 2021/10/22 10:17:55 UTC

Custom enforcer rule in 'org.apache.maven.plugins.enforcer' package?

Hi all,

I do maintain a custom enforcer rule implementation to restrict usage of
unwanted classes in a code base.
From the enforcer plugin's documentation I learned that such a custom rule
can be used like this:
<configuration>
    <rules>
        <restrictImports *implementation*
="de.skuzzle.enforcer.restrictimports.rule.*RestrictImports*">
        ...

Thus, referring to the custom implementation with its fully qualified class
name. However, I was curious why the default rules and also the rules from
the org.codehaus.mojo:extra-enforcer-rules do work without the
'implementation' attribute but by solely specifying the class name as tag
within <rules>, This seems to be the case because they are all in the same
package with the name org.apache.maven.plugins.enforcer. When I move my
custom rule to that package I can use it like this:
<configuration>
    <rules>
        <*RestrictImports*>
       ...

I do wonder whether it is ok or discouraged for custom rule implementations
to reuse that package. From a user's perspective it would be way nicer not
having to write the fully qualified name.

Kind regards,
Simon