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/09/03 23:40:04 UTC

svn commit: r691795 - in /maven/core-integration-testing/trunk/core-integration-tests/src/test: java/org/apache/maven/integrationtests/ resources/mng-3740-selfReferentialReactorProjects/ resources/mng-3740-selfReferentialReactorProjects/maven-mng3740-p...

Author: jdcasey
Date: Wed Sep  3 14:40:03 2008
New Revision: 691795

URL: http://svn.apache.org/viewvc?rev=691795&view=rev
Log:
[MNG-3740] Integration test.

Added:
    maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3740SelfReferentialReactorProjectsTest.java   (with props)
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/maven-mng3740-plugin.v1/
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/pom.xml   (with props)
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/src/
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/src/main/
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/src/main/java/
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/src/main/java/jar/
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/src/main/java/jar/MyMojo.java   (with props)
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/pom.xml   (with props)
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/pom.xml   (with props)
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/src/
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/src/main/
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/src/main/java/
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/src/main/java/jar/
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/src/main/java/jar/MyMojo.java   (with props)
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/pom.xml   (with props)
    maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/readme.txt   (with props)
Modified:
    maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java

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=691795&r1=691794&r2=691795&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 Wed Sep  3 14:40:03 2008
@@ -76,6 +76,7 @@
 MavenITmng3645POMSyntaxErrorTest
 */
 
+        suite.addTestSuite( MavenITmng3740SelfReferentialReactorProjectsTest.class );
         suite.addTestSuite( MavenITmng3729MultiForkAggregatorsTest.class );
         suite.addTestSuite( MavenITmng3724ExecutionProjectSyncTest.class );
         suite.addTestSuite( MavenITmng3723ConcreteParentProjectTest.class );

Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3740SelfReferentialReactorProjectsTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3740SelfReferentialReactorProjectsTest.java?rev=691795&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3740SelfReferentialReactorProjectsTest.java (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3740SelfReferentialReactorProjectsTest.java Wed Sep  3 14:40:03 2008
@@ -0,0 +1,68 @@
+/*
+ * 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 org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+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-3740">MNG-3740</a>.
+ *
+ * Check that when a plugin project build uses an earlier version of itself, it
+ * doesn't result in a StackOverflowError as a result of trying to calculate
+ * a concrete state for its project references, which includes itself because of
+ * this plugin configuration in the POM.
+ * 
+ * @author jdcasey
+ * 
+ */
+public class MavenITmng3740SelfReferentialReactorProjectsTest
+    extends AbstractMavenIntegrationTestCase
+{
+    public MavenITmng3740SelfReferentialReactorProjectsTest()
+        throws InvalidVersionSpecificationException
+    {
+        super( "(2.0.8,)" ); // only test in 2.0.9+
+    }
+
+    public void testitMNG3740 ()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3740-selfReferentialReactorProjects" );
+        File v1 = new File( testDir, "projects.v1" );
+        File v2 = new File( testDir, "projects.v2" );
+
+        Verifier verifier;
+
+        verifier = new Verifier( v1.getAbsolutePath() );
+        verifier.executeGoal( "install" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+        
+        verifier = new Verifier( v2.getAbsolutePath() );
+        verifier.executeGoal( "package" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+        
+    }
+}

Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3740SelfReferentialReactorProjectsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/pom.xml?rev=691795&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/pom.xml Wed Sep  3 14:40:03 2008
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.its.mng3740</groupId>
+    <artifactId>projects</artifactId>
+    <version>1</version>
+  </parent>
+  <groupId>org.apache.maven.its.mng3740</groupId>
+  <artifactId>maven-mng3740-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>
+  </dependencies>
+</project>
\ No newline at end of file

Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-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-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/src/main/java/jar/MyMojo.java?rev=691795&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/src/main/java/jar/MyMojo.java (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/src/main/java/jar/MyMojo.java Wed Sep  3 14:40:03 2008
@@ -0,0 +1,81 @@
+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}"
+     * @required
+     */
+    private File outputDirectory;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        File f = outputDirectory;
+
+        if ( !f.exists() )
+        {
+            f.mkdirs();
+        }
+
+        File touch = new File( f, "touch.txt" );
+
+        FileWriter w = null;
+        try
+        {
+            w = new FileWriter( touch );
+
+            w.write( "touch.txt" );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Error creating file " + touch, e );
+        }
+        finally
+        {
+            if ( w != null )
+            {
+                try
+                {
+                    w.close();
+                }
+                catch ( IOException e )
+                {
+                    // ignore
+                }
+            }
+        }
+    }
+}

Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/maven-mng3740-plugin/src/main/java/jar/MyMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/pom.xml?rev=691795&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/pom.xml Wed Sep  3 14:40:03 2008
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.its.mng3740</groupId>
+  <artifactId>projects</artifactId>
+  <packaging>pom</packaging>
+  <version>1</version>
+  
+  <modules>
+    <module>maven-mng3740-plugin</module>
+  </modules>
+</project>
\ No newline at end of file

Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v1/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/pom.xml?rev=691795&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/pom.xml Wed Sep  3 14:40:03 2008
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.its.mng3740</groupId>
+    <artifactId>projects</artifactId>
+    <version>2</version>
+  </parent>
+  <groupId>org.apache.maven.its.mng3740</groupId>
+  <artifactId>maven-mng3740-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <version>2</version>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-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-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/src/main/java/jar/MyMojo.java?rev=691795&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/src/main/java/jar/MyMojo.java (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/src/main/java/jar/MyMojo.java Wed Sep  3 14:40:03 2008
@@ -0,0 +1,81 @@
+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}"
+     * @required
+     */
+    private File outputDirectory;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        File f = outputDirectory;
+
+        if ( !f.exists() )
+        {
+            f.mkdirs();
+        }
+
+        File touch = new File( f, "touch.txt" );
+
+        FileWriter w = null;
+        try
+        {
+            w = new FileWriter( touch );
+
+            w.write( "touch.txt" );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Error creating file " + touch, e );
+        }
+        finally
+        {
+            if ( w != null )
+            {
+                try
+                {
+                    w.close();
+                }
+                catch ( IOException e )
+                {
+                    // ignore
+                }
+            }
+        }
+    }
+}

Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/maven-mng3740-plugin/src/main/java/jar/MyMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/pom.xml?rev=691795&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/pom.xml Wed Sep  3 14:40:03 2008
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.its.mng3740</groupId>
+  <artifactId>projects</artifactId>
+  <packaging>pom</packaging>
+  <version>2</version>
+  
+  <modules>
+    <module>maven-mng3740-plugin</module>
+  </modules>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.mng3740</groupId>
+        <artifactId>maven-mng3740-plugin</artifactId>
+        <version>1</version>
+        <executions>
+          <execution>
+            <id>test</id>
+            <phase>install</phase>
+            <goals>
+              <goal>touch</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file

Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/projects.v2/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/readme.txt
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/readme.txt?rev=691795&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/readme.txt (added)
+++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/readme.txt Wed Sep  3 14:40:03 2008
@@ -0,0 +1,3 @@
+This issue is caused by a reactor that contains a plugin that it also uses from the parent POM, where that plugin POM lists the parent POM as its <parent/>. When the parent project is loaded, a project reference is established between the parent and one of the child projects (the plugin project) even though the plugin referenced by the parent is an OLDER version. When Maven attempts to calculate the concrete state for one of the POMs in this scenario (I'm not clear on which one instigates the problem, though it's probably the first one encountered), it recurses infinitely between parent and child because of this [potentially erroneous] reference.
+
+The reason this has happened in the 2.1.0-M1 release candidates is because the processed project cache isn't passed down through the recursive calls from calculate* methods to restore* methods, and the current project being processed isn't marked as processed until near the end of the method. By marking it processed first thing, and passing a COPY of the processed project cache to the restore methods, we avoid infinite recursion. We have to use a copy to ensure the restore methods don't alter the set inappropriately.
\ No newline at end of file

Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3740-selfReferentialReactorProjects/readme.txt
------------------------------------------------------------------------------
    svn:eol-style = native