[MNG-7939] Allow to exclude plugins from validation
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7939PluginsValidationExcludesTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7939PluginsValidationExcludesTest.java
new file mode 100644
index 0000000..5ff0e3a
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7939PluginsValidationExcludesTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+package org.apache.maven.it;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.shared.verifier.Verifier;
+import org.apache.maven.shared.verifier.util.ResourceExtractor;
+import org.junit.jupiter.api.Test;
+
+/**
+ * This is a test set for
+ * <a href="https://issues.apache.org/jira/browse/MNG-7939">MNG-7939</a>.
+ * Allow to exclude plugins from validation
+ */
+class MavenITmng7939PluginsValidationExcludesTest extends AbstractMavenIntegrationTestCase {
+
+    protected MavenITmng7939PluginsValidationExcludesTest() {
+        super("[4.0.0-alpha-9,)");
+    }
+
+    @Test
+    void warningForPluginValidationIsPresentInProject() throws Exception {
+        File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-7939-plugins-validation-excludes");
+
+        Verifier verifier = newVerifier(testDir.getAbsolutePath());
+        verifier.setAutoclean(false);
+        verifier.setLogFileName("with-warning-log.txt");
+        verifier.deleteDirectory("target");
+        verifier.addCliArgument("-Dmaven.plugin.validation=verbose");
+        verifier.addCliArgument("validate");
+        verifier.execute();
+        verifier.verifyErrorFreeLog();
+
+        List<String> logs = verifier.loadLines(verifier.getLogFileName(), null);
+
+        verifyTextInLog(logs, "[INFO] [MAVEN-CORE-IT-LOG] localRepository");
+        verifyTextInLog(logs, "[WARNING]  * org.apache.maven.its.plugins:maven-it-plugin-configuration:2.1-SNAPSHOT");
+        verifyTextInLog(
+                logs, "[WARNING] Plugin [INTERNAL, EXTERNAL] validation issues were detected in following plugin(s)");
+        verifyTextInLog(
+                logs, "[WARNING]    * Mojo itconfiguration:localRepo (org.apache.maven.plugin.coreit.LocalRepoMojo)");
+        verifyTextInLog(
+                logs,
+                "[WARNING]      - Parameter 'localRepository' uses deprecated parameter expression '${localRepository}'");
+    }
+
+    @Test
+    void excludePluginFromValidation() throws Exception {
+        File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-7939-plugins-validation-excludes");
+
+        Verifier verifier = newVerifier(testDir.getAbsolutePath());
+        verifier.setAutoclean(false);
+        verifier.setLogFileName("without-warning-log.txt");
+        verifier.deleteDirectory("target");
+        verifier.addCliArgument("-Dmaven.plugin.validation=verbose");
+        verifier.addCliArgument(
+                "-Dmaven.plugin.validation.excludes=org.apache.maven.its.plugins:maven-it-plugin-configuration:2.1-SNAPSHOT");
+        verifier.addCliArgument("validate");
+        verifier.execute();
+        verifier.verifyErrorFreeLog();
+
+        List<String> logs = verifier.loadLines(verifier.getLogFileName(), null);
+
+        verifyTextInLog(logs, "[INFO] [MAVEN-CORE-IT-LOG] localRepository");
+        verifyTextNotInLog(
+                logs, "[WARNING]  * org.apache.maven.its.plugins:maven-it-plugin-configuration:2.1-SNAPSHOT");
+        verifyTextNotInLog(
+                logs, "[WARNING] Plugin [INTERNAL, EXTERNAL] validation issues were detected in following plugin(s)");
+        verifyTextNotInLog(
+                logs, "[WARNING]    * Mojo itconfiguration:localRepo (org.apache.maven.plugin.coreit.LocalRepoMojo)");
+        verifyTextNotInLog(
+                logs,
+                "[WARNING]      - Parameter 'localRepository' uses deprecated parameter expression '${localRepository}'");
+    }
+
+    private void verifyTextInLog(List<String> logs, String text) {
+        assertTrue("Log file not contains: " + text, logs.stream().anyMatch(l -> l.contains(text)));
+    }
+
+    private void verifyTextNotInLog(List<String> logs, String text) {
+        assertFalse("Log file contains: " + text, logs.stream().anyMatch(l -> l.contains(text)));
+    }
+}
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
index ebcefa9..27917ab 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
@@ -120,6 +120,7 @@
          * the tests are to finishing. Newer tests are also more likely to fail, so this is
          * a fail fast technique as well.
          */
+        suite.addTestSuite(MavenITmng7939PluginsValidationExcludesTest.class);
         suite.addTestSuite(MavenITmng7837ProjectElementInPomTest.class);
         suite.addTestSuite(MavenITmng7804PluginExecutionOrderTest.class);
         suite.addTestSuite(MavenITmng7836AlternativePomSyntaxTest.class);
diff --git a/core-it-suite/src/test/resources/mng-7939-plugins-validation-excludes/pom.xml b/core-it-suite/src/test/resources/mng-7939-plugins-validation-excludes/pom.xml
new file mode 100644
index 0000000..544b058
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7939-plugins-validation-excludes/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mng7939</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-configuration</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>localRepo</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/LocalRepoMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/LocalRepoMojo.java
new file mode 100644
index 0000000..becb49c
--- /dev/null
+++ b/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/LocalRepoMojo.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.coreit;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+/**
+ * simple Mojo using detracted localRepository, in order to test plugin verification
+ */
+@Mojo(name = "localRepo", defaultPhase = LifecyclePhase.VALIDATE)
+public class LocalRepoMojo extends AbstractMojo {
+
+    @Parameter(defaultValue = "${localRepository}", readonly = true)
+    private ArtifactRepository localRepository;
+
+    public void execute() throws MojoExecutionException {
+        getLog().info("[MAVEN-CORE-IT-LOG] localRepository " + localRepository);
+    }
+}