From 693fb14fe2f88a5e4247d2956f8eeff0dbe06d12 Mon Sep 17 00:00:00 2001
From: John Dennis Casey <jdcasey@apache.org>
Date: Thu, 14 Aug 2008 19:19:15 +0000
Subject: [PATCH] [MNG-3710] Use generated reader/writer to create clean deep
 clones of Model and Build instances, rather than trying to reuse logic meant
 for assembling inheritance and/or injecting defaults. Also including
 integration tests to check for plugin pollution.

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@685999 13f79535-47bb-0310-9956-ffa450edef68
---
 .../IntegrationTestSuite.java                 |   3 +-
 ...venITmng3710PollutedClonedPluginsTest.java | 107 ++++++++++++++++++
 .../maven-mng3710-directInvoke-plugin/pom.xml |  21 ++++
 .../src/main/java/jar/MyMojo.java             |  33 ++++++
 .../pom.xml                                   |  26 +++++
 .../src/main/java/jar/MyMojo.java             |  61 ++++++++++
 .../original-model/plugins/pom.xml            |  13 +++
 .../original-model/project/pom.xml            |  29 +++++
 .../pom.xml                                   |  21 ++++
 .../src/main/java/jar/MyMojo.java             |  79 +++++++++++++
 .../projects/middle/child/pom.xml             |  13 +++
 .../pom-inheritance/projects/middle/pom.xml   |  37 ++++++
 .../pom-inheritance/projects/pom.xml          |  22 ++++
 13 files changed, 464 insertions(+), 1 deletion(-)
 create mode 100644 its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3710PollutedClonedPluginsTest.java
 create mode 100644 its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/pom.xml
 create mode 100644 its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/src/main/java/jar/MyMojo.java
 create mode 100644 its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/pom.xml
 create mode 100644 its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/src/main/java/jar/MyMojo.java
 create mode 100644 its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/pom.xml
 create mode 100644 its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/project/pom.xml
 create mode 100644 its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/pom.xml
 create mode 100644 its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/src/main/java/jar/MyMojo.java
 create mode 100644 its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/child/pom.xml
 create mode 100644 its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/pom.xml
 create mode 100644 its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/pom.xml

diff --git a/its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java b/its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java
index 9118a0ed75..180bce971e 100644
--- a/its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java
+++ b/its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java
@@ -76,11 +76,11 @@ public static Test suite()
 MavenITmng3645POMSyntaxErrorTest
 */
 
+        suite.addTestSuite( MavenITmng3710PollutedClonedPluginsTest.class );
         suite.addTestSuite( MavenITmng3704LifecycleExecutorWrapperTest.class );
         suite.addTestSuite( MavenITmng3703ExecutionProjectWithRelativePathsTest.class );
         suite.addTestSuite( MavenITmng3694ReactorProjectsDynamismTest.class );
         suite.addTestSuite( MavenITmng3693PomFileBasedirChangeTest.class );
-        suite.addTestSuite( MavenITmng3599useHttpProxyForWebDAV.class );
         suite.addTestSuite( MavenITmng3684BuildPluginParameterTest.class );
         suite.addTestSuite( MavenITmng3680InvalidDependencyPOMTest.class );
         suite.addTestSuite( MavenITmng3679PluginExecIdInterpolationTest.class );
@@ -88,6 +88,7 @@ public static Test suite()
         suite.addTestSuite( MavenITmng3667ResolveDepsWithBadPomVersionTest.class );
         suite.addTestSuite( MavenITmng3652UserAgentHeader.class );
         suite.addTestSuite( MavenITmng3642DynamicResourcesTest.class );
+        suite.addTestSuite( MavenITmng3599useHttpProxyForWebDAV.class );
         suite.addTestSuite( MavenITmng3581PluginUsesWagonDependency.class );
         suite.addTestSuite( MavenITmng3545ProfileDeactivation.class );
         suite.addTestSuite( MavenITmng3536AppendedAbsolutePaths.class );
diff --git a/its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3710PollutedClonedPluginsTest.java b/its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3710PollutedClonedPluginsTest.java
new file mode 100644
index 0000000000..c2374da04c
--- /dev/null
+++ b/its/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3710PollutedClonedPluginsTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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.integrationtests;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.integrationtests.AbstractMavenIntegrationTestCase;
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+
+/**
+ * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3710">MNG-3710</a>.
+ * 
+ * @todo Fill in a better description of what this test verifies!
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * @author jdcasey
+ */
+public class MavenITmng3710PollutedClonedPluginsTest
+    extends AbstractMavenIntegrationTestCase
+{
+    public MavenITmng3710PollutedClonedPluginsTest()
+        throws InvalidVersionSpecificationException
+    {
+        super( "(2.0.8,)" ); // only test in 2.0.9+
+    }
+
+    public void testitMNG3710_POMInheritance()
+        throws Exception
+    {
+        File testDir =
+            ResourceExtractor.simpleExtractResources( getClass(), "/mng-3710-pollutedClonedPlugins/pom-inheritance" );
+        File pluginDir = new File( testDir, "maven-mng3710-pomInheritance-plugin" );
+        File projectsDir = new File( testDir, "projects" );
+
+        Verifier verifier;
+
+        verifier = new Verifier( pluginDir.getAbsolutePath() );
+        verifier.executeGoal( "install" );
+
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        verifier = new Verifier( projectsDir.getAbsolutePath() );
+        verifier.executeGoal( "validate" );
+
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        File topLevelTouchFile = new File( projectsDir, "target/touch.txt" );
+        assertFalse( "Top-level touch file should NOT be created in projects tree.", topLevelTouchFile.exists() );
+
+        File midLevelTouchFile = new File( projectsDir, "middle/target/touch.txt" );
+        assertTrue( "Mid-level touch file should have been created in projects tree.", midLevelTouchFile.exists() );
+
+        File childLevelTouchFile = new File( projectsDir, "middle/child/target/touch.txt" );
+        assertTrue( "Child-level touch file should have been created in projects tree.", childLevelTouchFile.exists() );
+
+    }
+
+    public void testitMNG3710_OriginalModel()
+        throws Exception
+    {
+        File testDir =
+            ResourceExtractor.simpleExtractResources( getClass(), "/mng-3710-pollutedClonedPlugins/original-model" );
+        File pluginsDir = new File( testDir, "plugins" );
+        File projectDir = new File( testDir, "project" );
+
+        Verifier verifier;
+
+        verifier = new Verifier( pluginsDir.getAbsolutePath() );
+        verifier.executeGoal( "install" );
+
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        verifier = new Verifier( projectDir.getAbsolutePath() );
+        
+        List goals = new ArrayList();
+        goals.add( "org.apache.maven.its.mng3710:maven-mng3710-directInvoke-plugin:1:run" );
+        goals.add( "validate" );
+        
+        verifier.executeGoals( goals );
+
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+    }
+}
diff --git a/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/pom.xml b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/pom.xml
new file mode 100644
index 0000000000..c84744da56
--- /dev/null
+++ b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/pom.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.its.mng3710</groupId>
+  <artifactId>maven-mng3710-directInvoke-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <version>1</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file
diff --git a/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/src/main/java/jar/MyMojo.java b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/src/main/java/jar/MyMojo.java
new file mode 100644
index 0000000000..9053853f54
--- /dev/null
+++ b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/src/main/java/jar/MyMojo.java
@@ -0,0 +1,33 @@
+package jar;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * @goal run
+ */
+public class MyMojo
+    extends AbstractMojo
+{
+    public void execute()
+        throws MojoExecutionException
+    {
+        getLog().info( "Direct-invoke mojo executed." );
+    }
+}
diff --git a/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/pom.xml b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/pom.xml
new file mode 100644
index 0000000000..12c7a244db
--- /dev/null
+++ b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/pom.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.its.mng3710</groupId>
+  <artifactId>maven-mng3710-originalModel-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <version>1</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+    	<groupId>org.apache.maven</groupId>
+    	<artifactId>maven-project</artifactId>
+    	<version>2.0.9</version>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file
diff --git a/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/src/main/java/jar/MyMojo.java b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/src/main/java/jar/MyMojo.java
new file mode 100644
index 0000000000..0fab443c53
--- /dev/null
+++ b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/src/main/java/jar/MyMojo.java
@@ -0,0 +1,61 @@
+package jar;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import java.util.Map;
+
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * @goal check
+ */
+public class MyMojo
+    extends AbstractMojo
+{
+    /**
+     * @parameter default-value="${project}"
+     * @required
+     * @readonly
+     */
+    private MavenProject project;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        Model originalModel = project.getOriginalModel();
+        Build originalBuild = originalModel.getBuild();
+        
+        Map originalPluginMap = originalBuild.getPluginsAsMap();
+        
+        if ( originalPluginMap.containsKey( Plugin.constructKey( "org.apache.maven.its.mng3710", "maven-mng3710-directInvoke-plugin" ) ) )
+        {
+            throw new MojoExecutionException( "Project's original model has been polluted by an entry for a plugin that was invoked directly from the command line." );
+        }
+        
+        if ( originalPluginMap.containsKey( Plugin.constructKey( "org.apache.maven.plugins", "maven-compiler-plugin" ) ) )
+        {
+            throw new MojoExecutionException( "Project's original model has been polluted by an entry for a plugin that is specified in the lifecycle mapping for this project's packaging." );
+        }
+        
+        getLog().info( "Original-model verification completed successfully." );
+    }
+}
diff --git a/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/pom.xml b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/pom.xml
new file mode 100644
index 0000000000..e2dc430188
--- /dev/null
+++ b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/pom.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  
+  <groupId>org.apache.maven.its.mng3710</groupId>
+  <artifactId>plugins</artifactId>
+  <version>1</version>
+  <packaging>pom</packaging>
+  <modules>
+    <module>maven-mng3710-directInvoke-plugin</module>
+    <module>maven-mng3710-originalModel-plugin</module>
+  </modules>
+</project>
\ No newline at end of file
diff --git a/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/project/pom.xml b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/project/pom.xml
new file mode 100644
index 0000000000..fd6fa78913
--- /dev/null
+++ b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/project/pom.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  
+  <groupId>org.apache.maven.its.mng3710</groupId>
+  <artifactId>project</artifactId>
+  <version>1</version>
+  <packaging>jar</packaging>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.mng3710</groupId>
+        <artifactId>maven-mng3710-originalModel-plugin</artifactId>
+        <version>1</version>
+        
+        <executions>
+          <execution>
+            <id>check</id>
+            <phase>package</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file
diff --git a/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/pom.xml b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/pom.xml
new file mode 100644
index 0000000000..da376bf457
--- /dev/null
+++ b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/pom.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.its.mng3710</groupId>
+  <artifactId>maven-mng3710-pomInheritance-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <version>1</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file
diff --git a/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/src/main/java/jar/MyMojo.java b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/src/main/java/jar/MyMojo.java
new file mode 100644
index 0000000000..14ea8d2962
--- /dev/null
+++ b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/src/main/java/jar/MyMojo.java
@@ -0,0 +1,79 @@
+package jar;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+/**
+ * Goal which touches a timestamp file.
+ *
+ * @goal touch
+ * 
+ * @phase process-sources
+ */
+public class MyMojo
+    extends AbstractMojo
+{
+    /**
+     * Location of the file.
+     * @parameter expression="${project.build.directory}/touch.txt"
+     * @required
+     */
+    private File touchFile;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        File dir = touchFile.getParentFile();
+
+        if ( dir != null && !dir.exists() )
+        {
+            dir.mkdirs();
+        }
+
+        FileWriter w = null;
+        try
+        {
+            w = new FileWriter( touchFile );
+
+            w.write( "touch.txt" );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Error creating file " + touchFile, e );
+        }
+        finally
+        {
+            if ( w != null )
+            {
+                try
+                {
+                    w.close();
+                }
+                catch ( IOException e )
+                {
+                    // ignore
+                }
+            }
+        }
+    }
+}
diff --git a/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/child/pom.xml b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/child/pom.xml
new file mode 100644
index 0000000000..4419048af5
--- /dev/null
+++ b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/child/pom.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+        <artifactId>middle</artifactId>
+        <groupId>org.apache.maven.its.mng3710</groupId>
+        <version>1</version>
+    </parent>
+  <groupId>org.apache.maven.its.mng3710</groupId>
+  <artifactId>child</artifactId>
+  <version>1</version>
+  <packaging>pom</packaging>
+</project>
diff --git a/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/pom.xml b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/pom.xml
new file mode 100644
index 0000000000..71e7e19e28
--- /dev/null
+++ b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+        <artifactId>projects</artifactId>
+        <groupId>org.apache.maven.its.mng3710</groupId>
+        <version>1</version>
+    </parent>
+  <groupId>org.apache.maven.its.mng3710</groupId>
+  <artifactId>middle</artifactId>
+  <version>1</version>
+  <packaging>pom</packaging>
+  <modules>
+  	<module>child</module>
+  </modules>
+  
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.its.mng3710</groupId>
+          <artifactId>maven-mng3710-pomInheritance-plugin</artifactId>
+          
+          <executions>
+            <execution>
+              <id>touch</id>
+              <phase>validate</phase>
+              <goals>
+                <goal>touch</goal>
+              </goals>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
diff --git a/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/pom.xml b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/pom.xml
new file mode 100644
index 0000000000..c1938eee15
--- /dev/null
+++ b/its/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/pom.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  
+  <groupId>org.apache.maven.its.mng3710</groupId>
+  <artifactId>projects</artifactId>
+  <version>1</version>
+  <packaging>pom</packaging>
+  <modules>
+    <module>middle</module>
+  </modules>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.mng3710</groupId>
+        <artifactId>maven-mng3710-pomInheritance-plugin</artifactId>
+        <version>1</version>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file