You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2008/08/14 21:19:16 UTC
svn commit: r685999 - in /maven:
components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/
core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/
core-integration-testing/t...
Author: jdcasey
Date: Thu Aug 14 12:19:15 2008
New Revision: 685999
URL: http://svn.apache.org/viewvc?rev=685999&view=rev
Log:
[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.
Added:
maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3710PollutedClonedPluginsTest.java
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/pom.xml
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/src/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/src/main/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/src/main/java/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/src/main/java/jar/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/src/main/java/jar/MyMojo.java
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/pom.xml
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/src/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/src/main/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/src/main/java/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/src/main/java/jar/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/src/main/java/jar/MyMojo.java
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/pom.xml
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/project/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/project/pom.xml
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/pom.xml
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/src/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/src/main/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/src/main/java/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/src/main/java/jar/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/src/main/java/jar/MyMojo.java
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/child/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/child/pom.xml
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/pom.xml
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/pom.xml
Modified:
maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java
Modified: maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java?rev=685999&r1=685998&r2=685999&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java (original)
+++ maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java Thu Aug 14 12:19:15 2008
@@ -46,10 +46,16 @@
import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.model.Resource;
import org.apache.maven.model.Site;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler;
import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -561,37 +567,84 @@
public static Model cloneModel( Model model )
{
+ StringWriter writer = new StringWriter();
+ try
+ {
+ new MavenXpp3Writer().write( writer, model );
+ }
+ catch ( IOException e )
+ {
+ }
+
+ try
+ {
+ return new MavenXpp3Reader().read( new StringReader( writer.toString() ) );
+ }
+ catch ( IOException e )
+ {
+ }
+ catch ( XmlPullParserException e )
+ {
+ }
+
+ return null;
+
// TODO: would be nice for the modello:java code to generate this as a copy constructor
// FIXME: Fix deep cloning issues with existing plugin instances (setting
// a version when resolved will pollute the original model instance)
- Model newModel = new Model();
- ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
- newModel.setModelVersion( model.getModelVersion() );
- newModel.setName( model.getName() );
- newModel.setParent( cloneParent( model.getParent() ) );
- newModel.setVersion( model.getVersion() );
- newModel.setArtifactId( model.getArtifactId() );
- newModel.setProperties( new Properties( model.getProperties() ) );
- newModel.setGroupId( model.getGroupId() );
- newModel.setPackaging( model.getPackaging() );
- newModel.setModules( cloneModules( model.getModules() ) );
-
- newModel.setProfiles( cloneProfiles( model.getProfiles() ) );
-
- assembler.copyModel( newModel, model );
-
- return newModel;
+// Model newModel = new Model();
+// ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
+// newModel.setModelVersion( model.getModelVersion() );
+// newModel.setName( model.getName() );
+// newModel.setParent( cloneParent( model.getParent() ) );
+// newModel.setVersion( model.getVersion() );
+// newModel.setArtifactId( model.getArtifactId() );
+// newModel.setProperties( new Properties( model.getProperties() ) );
+// newModel.setGroupId( model.getGroupId() );
+// newModel.setPackaging( model.getPackaging() );
+// newModel.setModules( cloneModules( model.getModules() ) );
+//
+// newModel.setProfiles( cloneProfiles( model.getProfiles() ) );
+//
+// assembler.copyModel( newModel, model );
+//
+// return newModel;
}
public static Build cloneBuild( Build build )
{
- ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
-
- Build clone = new Build();
-
- assembler.assembleBuildInheritance( clone, build, false );
-
- return clone;
+ Model model = new Model();
+ model.setBuild( build );
+
+ StringWriter writer = new StringWriter();
+ try
+ {
+ new MavenXpp3Writer().write( writer, model );
+ }
+ catch ( IOException e )
+ {
+ }
+
+ try
+ {
+ return new MavenXpp3Reader().read( new StringReader( writer.toString() ) ).getBuild();
+ }
+ catch ( IOException e )
+ {
+ }
+ catch ( XmlPullParserException e )
+ {
+ }
+
+ return null;
+
+// ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
+//
+// Build clone = new Build();
+//
+// assembler.assembleBuildInheritance( clone, build, false );
+//
+// return clone;
}
private static List cloneProfiles( List profiles )
Modified: maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java?rev=685999&r1=685998&r2=685999&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java (original)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java Thu Aug 14 12:19:15 2008
@@ -76,11 +76,11 @@
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 @@
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 );
Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3710PollutedClonedPluginsTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3710PollutedClonedPluginsTest.java?rev=685999&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3710PollutedClonedPluginsTest.java (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3710PollutedClonedPluginsTest.java Thu Aug 14 12:19:15 2008
@@ -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();
+ }
+}
Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/pom.xml?rev=685999&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/pom.xml Thu Aug 14 12:19:15 2008
@@ -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
Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/src/main/java/jar/MyMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/src/main/java/jar/MyMojo.java?rev=685999&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/src/main/java/jar/MyMojo.java (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-directInvoke-plugin/src/main/java/jar/MyMojo.java Thu Aug 14 12:19:15 2008
@@ -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." );
+ }
+}
Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/pom.xml?rev=685999&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/pom.xml Thu Aug 14 12:19:15 2008
@@ -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
Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/src/main/java/jar/MyMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/src/main/java/jar/MyMojo.java?rev=685999&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/src/main/java/jar/MyMojo.java (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/maven-mng3710-originalModel-plugin/src/main/java/jar/MyMojo.java Thu Aug 14 12:19:15 2008
@@ -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." );
+ }
+}
Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/pom.xml?rev=685999&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/plugins/pom.xml Thu Aug 14 12:19:15 2008
@@ -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
Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/project/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/project/pom.xml?rev=685999&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/project/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/original-model/project/pom.xml Thu Aug 14 12:19:15 2008
@@ -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
Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/pom.xml?rev=685999&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/pom.xml Thu Aug 14 12:19:15 2008
@@ -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
Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/src/main/java/jar/MyMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/src/main/java/jar/MyMojo.java?rev=685999&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/src/main/java/jar/MyMojo.java (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/maven-mng3710-pomInheritance-plugin/src/main/java/jar/MyMojo.java Thu Aug 14 12:19:15 2008
@@ -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
+ }
+ }
+ }
+ }
+}
Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/child/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/child/pom.xml?rev=685999&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/child/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/child/pom.xml Thu Aug 14 12:19:15 2008
@@ -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>
Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/pom.xml?rev=685999&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/middle/pom.xml Thu Aug 14 12:19:15 2008
@@ -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>
Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/pom.xml?rev=685999&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3710-pollutedClonedPlugins/pom-inheritance/projects/pom.xml Thu Aug 14 12:19:15 2008
@@ -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