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 MNG-3710.
+ *
+ * @todo Fill in a better description of what this test verifies!
+ * @author Brian Fox
+ * @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 @@
+
+ 4.0.0
+ org.apache.maven.its.mng3710
+ maven-mng3710-directInvoke-plugin
+ maven-plugin
+ 1
+
+
+
+ org.apache.maven
+ maven-plugin-api
+ 2.0
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+
\ 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 @@
+
+ 4.0.0
+ org.apache.maven.its.mng3710
+ maven-mng3710-originalModel-plugin
+ maven-plugin
+ 1
+
+
+
+ org.apache.maven
+ maven-plugin-api
+ 2.0
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+ org.apache.maven
+ maven-project
+ 2.0.9
+
+
+
\ 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 @@
+
+
+ 4.0.0
+
+ org.apache.maven.its.mng3710
+ plugins
+ 1
+ pom
+
+ maven-mng3710-directInvoke-plugin
+ maven-mng3710-originalModel-plugin
+
+
\ 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 @@
+
+
+ 4.0.0
+
+ org.apache.maven.its.mng3710
+ project
+ 1
+ jar
+
+
+
+
+ org.apache.maven.its.mng3710
+ maven-mng3710-originalModel-plugin
+ 1
+
+
+
+ check
+ package
+
+ check
+
+
+
+
+
+
+
\ 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 @@
+
+ 4.0.0
+ org.apache.maven.its.mng3710
+ maven-mng3710-pomInheritance-plugin
+ maven-plugin
+ 1
+
+
+
+ org.apache.maven
+ maven-plugin-api
+ 2.0
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+
\ 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 @@
+
+
+ 4.0.0
+
+ middle
+ org.apache.maven.its.mng3710
+ 1
+
+ org.apache.maven.its.mng3710
+ child
+ 1
+ pom
+
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 @@
+
+
+ 4.0.0
+
+ projects
+ org.apache.maven.its.mng3710
+ 1
+
+ org.apache.maven.its.mng3710
+ middle
+ 1
+ pom
+
+ child
+
+
+
+
+
+
+ org.apache.maven.its.mng3710
+ maven-mng3710-pomInheritance-plugin
+
+
+
+ touch
+ validate
+
+ touch
+
+
+
+
+
+
+
+
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 @@
+
+
+ 4.0.0
+
+ org.apache.maven.its.mng3710
+ projects
+ 1
+ pom
+
+ middle
+
+
+
+
+
+ org.apache.maven.its.mng3710
+ maven-mng3710-pomInheritance-plugin
+ 1
+
+
+
+
\ No newline at end of file