Author: bentmann
Date: Wed Jul 30 08:58:46 2008
New Revision: 681098

URL: http://svn.apache.org/viewvc?rev=681098&view=rev
Log:
[MINVOKER-44] cloneProjectsTo fails to copy projects with the same prefix

Added:
    
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/
    
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module/
    
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/
    
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/pom.xml
   (with props)
    
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/sub-module/
    
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/sub-module/pom.xml
   (with props)
    
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module/pom.xml
   (with props)
    
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/pom.xml
   (with props)
Modified:
    
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
    
maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java

Modified: 
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java?rev=681098&r1=681097&r2=681098&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
 Wed Jul 30 08:58:46 2008
@@ -589,13 +589,13 @@
         }
     }
 
-    private boolean alreadyCloned( String subpath, List clonedSubpaths )
+    static boolean alreadyCloned( String subpath, List clonedSubpaths )
     {
         for ( Iterator iter = clonedSubpaths.iterator(); iter.hasNext(); )
         {
             String path = (String) iter.next();
 
-            if ( ".".equals( path ) || subpath.startsWith( path ) )
+            if ( ".".equals( path ) || subpath.equals( path ) || 
subpath.startsWith( path + File.separator ) )
             {
                 return true;
             }

Modified: 
maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java?rev=681098&r1=681097&r2=681098&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java
 (original)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java
 Wed Jul 30 08:58:46 2008
@@ -67,7 +67,7 @@
         pomIncludes.add( "pom.xml" );
         setVariableValueToObject( invokerMojo, "pomIncludes", pomIncludes );
         setVariableValueToObject( invokerMojo, "invoker", 
getContainer().lookup( Invoker.ROLE ) );
-        File cloneProjectsTo = new File( "target/goals-from-file/" );
+        File cloneProjectsTo = new File( getBasedir(), 
"target/unit/goals-from-file/" );
         // clean if exists
         if ( cloneProjectsTo.exists() )
         {
@@ -125,6 +125,48 @@
         setVariableValueToObject( invokerMojo, "invokerTest", "*" );
         String[] poms = invokerMojo.getPoms();
         System.out.println( Arrays.asList( poms ) );
-        assertEquals( 3, poms.length );
+        assertEquals( 4, poms.length );
     }
+
+    public void testAlreadyCloned()
+        throws Exception
+    {
+        assertFalse( InvokerMojo.alreadyCloned( "dir", Collections.EMPTY_LIST 
) );
+        assertTrue( InvokerMojo.alreadyCloned( "dir", 
Collections.singletonList( "dir" ) ) );
+        assertTrue( InvokerMojo.alreadyCloned( "dir" + File.separator + "sub", 
Collections.singletonList( "dir" ) ) );
+        assertFalse( InvokerMojo.alreadyCloned( "dirs", 
Collections.singletonList( "dir" ) ) );
+    }    
+
+    public void testProjectCloning()
+        throws Exception
+    {
+        String dirPath = getBasedir() + 
"/src/test/resources/unit/nested-projects";
+
+        File cloneProjectsTo = new File( getBasedir(), 
"target/unit/nested-projects" );
+        if ( cloneProjectsTo.exists() )
+        {
+            FileUtils.deleteDirectory( cloneProjectsTo );
+        }
+
+        MavenProjectStub project = new MavenProjectStub();
+        project.setTestClasspathElements( Collections.EMPTY_LIST );
+
+        InvokerMojo invokerMojo = new InvokerMojo();
+        setVariableValueToObject( invokerMojo, "goals", 
Collections.singletonList( "validate" ) );
+        setVariableValueToObject( invokerMojo, "projectsDirectory", new File( 
dirPath ) );
+        setVariableValueToObject( invokerMojo, "pomIncludes", 
Collections.singletonList( "**/pom.xml" ) );
+        setVariableValueToObject( invokerMojo, "pomExcludes", 
Collections.singletonList( "pom.xml" ) );
+        setVariableValueToObject( invokerMojo, "cloneProjectsTo", 
cloneProjectsTo );
+        setVariableValueToObject( invokerMojo, "project", project );
+        setVariableValueToObject( invokerMojo, "settings", new Settings() );
+        setVariableValueToObject( invokerMojo, "invoker", 
getContainer().lookup( Invoker.ROLE ) );
+
+        invokerMojo.execute();
+
+        // NOTE: It is part of the test design that "module" is a prefix of 
"module-1"
+        assertTrue( new File( cloneProjectsTo, "module" ).isDirectory() );
+        assertTrue( new File( cloneProjectsTo, "module-1" ).isDirectory() );
+        assertTrue( new File( cloneProjectsTo, "module-1/sub-module" 
).isDirectory() );
+    }
+
 }

Added: 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/pom.xml?rev=681098&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/pom.xml
 Wed Jul 30 08:58:46 2008
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.test</groupId>
+  <artifactId>unit</artifactId>
+  <packaging>pom</packaging>
+  <version>0.1-SNAPSHOT</version>
+  <properties>
+    <interpolateValue>@foo@</interpolateValue>
+  </properties>
+</project>
\ No newline at end of file

Propchange: 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/sub-module/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/sub-module/pom.xml?rev=681098&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/sub-module/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/sub-module/pom.xml
 Wed Jul 30 08:58:46 2008
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.test</groupId>
+  <artifactId>unit</artifactId>
+  <packaging>pom</packaging>
+  <version>0.1-SNAPSHOT</version>
+  <properties>
+    <interpolateValue>@foo@</interpolateValue>
+  </properties>
+</project>
\ No newline at end of file

Propchange: 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/sub-module/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module-1/sub-module/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module/pom.xml?rev=681098&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module/pom.xml
 Wed Jul 30 08:58:46 2008
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.test</groupId>
+  <artifactId>unit</artifactId>
+  <packaging>pom</packaging>
+  <version>0.1-SNAPSHOT</version>
+  <properties>
+    <interpolateValue>@foo@</interpolateValue>
+  </properties>
+</project>
\ No newline at end of file

Propchange: 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/module/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/pom.xml?rev=681098&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/pom.xml
 Wed Jul 30 08:58:46 2008
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.test</groupId>
+  <artifactId>unit</artifactId>
+  <packaging>pom</packaging>
+  <version>0.1-SNAPSHOT</version>
+  <properties>
+    <interpolateValue>@foo@</interpolateValue>
+  </properties>
+</project>
\ No newline at end of file

Propchange: 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/nested-projects/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision


Reply via email to