Search code examples
mavenmaven-enforcer-plugin

Run Maven Enforcer Plugin rule on command line


I would like to enforce the requireReleaseDeps rule of the Maven Enforcer Plugin on a Maven project without any POM configuration simply as a command line call.

According to the docs I should be able to just pass in the rules parameter like so

mvn enforcer:enforce -Drules=requireReleaseDeps

or maybe this should work

mvn enforcer:enforce -Drules=org.apache.maven.plugins.enforcer.RequireReleaseDeps

However both of these calls result in

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (default-cli) on project hel
lo-world: The parameters 'rules' for goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce are missing or in
valid -> [Help 1]

Anybody know if this usage scenario actually works somehow or do I have to dive into debugging the plugin at this stage to figure this out?


Solution

  • With the version 3.0.0-M3 of the plugin and newer release the enforcer goal now supports the rules parameter and command line execution without config in the pom. See more at https://maven.apache.org/enforcer/maven-enforcer-plugin/enforce-mojo.html#commandLineRules

    Unfortunately there is currently no such functionality but there is already a JIRA Issue for that.