slawekjaranowski commented on code in PR #211:
URL: https://github.com/apache/maven-enforcer/pull/211#discussion_r1059133637


##########
maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java:
##########
@@ -153,6 +147,36 @@ public class EnforceMojo extends AbstractMojo {
     @Component
     private EnforcerRuleManager enforcerRuleManager;
 
+    private List<String> rulesToExecute;
+
+    /**
+     * List of strings that matches the EnforcerRules to execute. Replacement 
for the <code>rules</code> property.
+     *
+     * @since 3.2.0
+     */
+    @Parameter(required = false, property = "enforcer.rules")
+    public void setRulesToExecute(List<String> rulesToExecute) throws 
MojoExecutionException {
+        if (rulesToExecute != null && !rulesToExecute.isEmpty()) {
+            if (this.rulesToExecute != null && !this.rulesToExecute.isEmpty()) 
{
+                throw new MojoExecutionException("Detected the usage of both 
'-Drules' (which is deprecated) "
+                        + "and '-Denforcer.rules'. Please use only one of 
them, preferably '-Denforcer.rules'.");
+            }
+            this.rulesToExecute = rulesToExecute;
+        }
+    }
+
+    /**
+     * List of strings that matches the EnforcerRules to execute.
+     *
+     * @deprecated Use <code>enforcer.rules</code> property instead
+     */
+    @Parameter(required = false, property = "rules")
+    @Deprecated
+    public void setCommandLineRules(List<String> rulesToExecute) throws 
MojoExecutionException {
+        getLog().warn("Detected the usage of property '-Drules' which is 
deprecated. Use '-Denforcer.rules' instead.");

Review Comment:
   Maven 3.9 will take care about it and warn about deprecated items ... but 
can be now
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to