diff --git a/maven-enforcer-plugin/src/it/projects/cli-always-fail-deprecated/invoker.properties b/maven-enforcer-plugin/src/it/projects/cli-always-fail-deprecated/invoker.properties
new file mode 100644
index 00000000..c683c671
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/cli-always-fail-deprecated/invoker.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+invoker.goals = validate -Drules=AlwaysFail
+invoker.buildResult = failure
diff --git a/maven-enforcer-plugin/src/it/projects/cli-always-fail-deprecated/pom.xml b/maven-enforcer-plugin/src/it/projects/cli-always-fail-deprecated/pom.xml
new file mode 100644
index 00000000..c3e9c7ab
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/cli-always-fail-deprecated/pom.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+ 4.0.0
+
+ org.apache.maven.its.enforcer
+ test
+ 1.0
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ @project.version@
+
+
+ test
+
+ enforce
+
+
+
+
+
+ true
+
+
+
+
+
+
+
diff --git a/maven-enforcer-plugin/src/it/projects/cli-always-fail-deprecated/verify.groovy b/maven-enforcer-plugin/src/it/projects/cli-always-fail-deprecated/verify.groovy
new file mode 100644
index 00000000..d7cdafa9
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/cli-always-fail-deprecated/verify.groovy
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+def buildLog = new File(basedir, 'build.log').text
+assert !buildLog.contains('[INFO] Always pass!')
diff --git a/maven-enforcer-plugin/src/it/projects/cli-always-fail/invoker.properties b/maven-enforcer-plugin/src/it/projects/cli-always-fail/invoker.properties
index ee2da69d..9d4f4503 100644
--- a/maven-enforcer-plugin/src/it/projects/cli-always-fail/invoker.properties
+++ b/maven-enforcer-plugin/src/it/projects/cli-always-fail/invoker.properties
@@ -14,5 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:enforce -Drules=alwaysFail
+invoker.goals = validate -Denforcer.rules=AlwaysFail
invoker.buildResult = failure
diff --git a/maven-enforcer-plugin/src/it/projects/cli-always-fail/pom.xml b/maven-enforcer-plugin/src/it/projects/cli-always-fail/pom.xml
index 0915303c..c3e9c7ab 100644
--- a/maven-enforcer-plugin/src/it/projects/cli-always-fail/pom.xml
+++ b/maven-enforcer-plugin/src/it/projects/cli-always-fail/pom.xml
@@ -35,6 +35,20 @@ under the License.
org.apache.maven.plugins
maven-enforcer-plugin
@project.version@
+
+
+ test
+
+ enforce
+
+
+
+
+
+ true
+
+
+
diff --git a/maven-enforcer-plugin/src/it/projects/cli-always-fail/verify.groovy b/maven-enforcer-plugin/src/it/projects/cli-always-fail/verify.groovy
new file mode 100644
index 00000000..d7cdafa9
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/cli-always-fail/verify.groovy
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+def buildLog = new File(basedir, 'build.log').text
+assert !buildLog.contains('[INFO] Always pass!')
diff --git a/maven-enforcer-plugin/src/it/projects/cli-always-pass-deprecated/invoker.properties b/maven-enforcer-plugin/src/it/projects/cli-always-pass-deprecated/invoker.properties
new file mode 100644
index 00000000..d70aaef9
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/cli-always-pass-deprecated/invoker.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+invoker.goals = validate -Drules=AlwaysPass
+invoker.buildResult = success
diff --git a/maven-enforcer-plugin/src/it/projects/cli-always-pass-deprecated/pom.xml b/maven-enforcer-plugin/src/it/projects/cli-always-pass-deprecated/pom.xml
new file mode 100644
index 00000000..e5e2e807
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/cli-always-pass-deprecated/pom.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+ 4.0.0
+
+ org.apache.maven.its.enforcer
+ test
+ 1.0
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ @project.version@
+
+
+ test
+
+ enforce
+
+
+
+
+
+ true
+
+
+
+
+
+
+
diff --git a/maven-enforcer-plugin/src/it/projects/cli-always-pass-deprecated/verify.groovy b/maven-enforcer-plugin/src/it/projects/cli-always-pass-deprecated/verify.groovy
new file mode 100644
index 00000000..34bbcab7
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/cli-always-pass-deprecated/verify.groovy
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+def buildLog = new File(basedir, 'build.log').text
+assert buildLog.contains('[INFO] Always pass!')
diff --git a/maven-enforcer-plugin/src/it/projects/cli-always-pass/invoker.properties b/maven-enforcer-plugin/src/it/projects/cli-always-pass/invoker.properties
index c67cebe4..9ce63b20 100644
--- a/maven-enforcer-plugin/src/it/projects/cli-always-pass/invoker.properties
+++ b/maven-enforcer-plugin/src/it/projects/cli-always-pass/invoker.properties
@@ -14,5 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:enforce -Drules=alwaysPass
+invoker.goals = validate -Denforcer.rules=AlwaysPass
invoker.buildResult = success
diff --git a/maven-enforcer-plugin/src/it/projects/cli-always-pass/pom.xml b/maven-enforcer-plugin/src/it/projects/cli-always-pass/pom.xml
index 2375f8c6..e5e2e807 100644
--- a/maven-enforcer-plugin/src/it/projects/cli-always-pass/pom.xml
+++ b/maven-enforcer-plugin/src/it/projects/cli-always-pass/pom.xml
@@ -43,8 +43,9 @@ under the License.
-
+
+ true
diff --git a/maven-enforcer-plugin/src/it/projects/cli-always-pass/verify.groovy b/maven-enforcer-plugin/src/it/projects/cli-always-pass/verify.groovy
new file mode 100644
index 00000000..34bbcab7
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/cli-always-pass/verify.groovy
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+def buildLog = new File(basedir, 'build.log').text
+assert buildLog.contains('[INFO] Always pass!')
diff --git a/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java b/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java
index cf44b6cd..6063083f 100644
--- a/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java
+++ b/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java
@@ -118,7 +118,7 @@ public class EnforceMojo extends AbstractMojo {
* <message>message for rule</message>
* </alwaysPass>
* <myRule implementation="org.example.MyRule"/>
- * </rules>
+ * </rules>
*
*
* @since 1.0.0
@@ -127,10 +127,12 @@ public class EnforceMojo extends AbstractMojo {
private PlexusConfiguration rules;
/**
- * List of strings that matches the EnforcerRules to execute.
+ * List of strings that matches the EnforcerRules to execute. Replacement for the rules
property.
+ *
+ * @since 3.2.0
*/
- @Parameter(required = false, property = "rules")
- private List commandLineRules;
+ @Parameter(required = false, property = "enforcer.rules")
+ private List rulesToExecute;
/**
* List of strings that matches the EnforcerRules to skip.
@@ -153,6 +155,25 @@ public class EnforceMojo extends AbstractMojo {
@Component
private EnforcerRuleManager enforcerRuleManager;
+ /**
+ * List of strings that matches the EnforcerRules to execute.
+ *
+ * @deprecated Use enforcer.rules
property instead
+ */
+ @Parameter(required = false, property = "rules")
+ @Deprecated
+ public void setCommandLineRules(List rulesToExecute) {
+ if (rulesToExecute != null && !rulesToExecute.isEmpty()) {
+ this.rulesToExecute = rulesToExecute;
+ }
+ }
+
+ public void setRulesToExecute(List rulesToExecute) {
+ if (rulesToExecute != null && !rulesToExecute.isEmpty()) {
+ this.rulesToExecute = rulesToExecute;
+ }
+ }
+
@Override
public void execute() throws MojoExecutionException {
Log log = this.getLog();
@@ -274,21 +295,19 @@ public void execute() throws MojoExecutionException {
*/
private Optional createRulesFromCommandLineOptions() {
- if (commandLineRules == null || commandLineRules.isEmpty()) {
+ if (rulesToExecute == null || rulesToExecute.isEmpty()) {
return Optional.empty();
}
PlexusConfiguration configuration = new DefaultPlexusConfiguration("rules");
-
- for (String rule : commandLineRules) {
+ for (String rule : rulesToExecute) {
configuration.addChild(new DefaultPlexusConfiguration(rule));
}
-
return Optional.of(configuration);
}
/**
- * Filter our (remove) rules that have been specifically skipped via additional configuration.
+ * Filter out (remove) rules that have been specifically skipped via additional configuration.
*
* @param allRules list of enforcer rules to go through and filter
*