Author: dennisl
Date: Tue Jul 22 04:28:13 2008
New Revision: 678718

URL: http://svn.apache.org/viewvc?rev=678718&view=rev
Log:
[MIDEA-103] Incorrect module paths are generated when parent project name is 
prefix in child project names

Modified:
    
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/AbstractIdeaMojo.java
    
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaMojoTestCase.java

Modified: 
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/AbstractIdeaMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/AbstractIdeaMojo.java?rev=678718&r1=678717&r2=678718&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/AbstractIdeaMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/AbstractIdeaMojo.java
 Tue Jul 22 04:28:13 2008
@@ -232,11 +232,13 @@
             convertedAbsolutePath = convertedAbsolutePath.substring( 0, 
convertedAbsolutePath.length() - 1 );
         }
 
-        if ( convertedAbsolutePath.startsWith( convertedBasedir )
-            && convertedAbsolutePath.length() > convertedBasedir.length() )
+        // IDEA-103 Make sure that the basedir is appended with a / before we 
attempt to match it to the absolute path
+        String matchableBasedir = convertedBasedir + "/";
+        if ( convertedAbsolutePath.startsWith( matchableBasedir )
+            && convertedAbsolutePath.length() > matchableBasedir.length() )
         {
             // Simple case, path starts with basepath
-            relative = convertedAbsolutePath.substring( 
convertedBasedir.length() + 1 );
+            relative = convertedAbsolutePath.substring( 
matchableBasedir.length() );
         }
         else
         {

Modified: 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaMojoTestCase.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaMojoTestCase.java?rev=678718&r1=678717&r2=678718&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaMojoTestCase.java
 (original)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaMojoTestCase.java
 Tue Jul 22 04:28:13 2008
@@ -57,6 +57,7 @@
                                         
"C:/dev/voca/gateway/parser/gateway-parser.iml" );
         assertEquals( "Test toRelative child, trailing slash", 
"parser/gateway-parser.iml", relativePath );
 
+        // Tests for MIDEA-102
         relativePath = mojo.toRelative( "C:\\foo\\master",
                                         "C:\\foo\\child" );
         assertEquals( "Test toRelative sibling, no trailing backspace", 
"../child", relativePath );
@@ -72,5 +73,14 @@
         relativePath = mojo.toRelative( "C:\\foo\\master\\",
                                         "C:\\foo\\child\\" );
         assertEquals( "Test toRelative sibling, both trailing backspace", 
"../child", relativePath );
+
+        // Tests for MIDEA-103
+        relativePath = mojo.toRelative( "/myproject/myproject",
+                                        
"/myproject/myproject-module1/myproject-module1.iml" );
+        assertEquals( "Test parent matches prefix of child, no trailing 
slash", "../myproject-module1/myproject-module1.iml", relativePath );
+
+        relativePath = mojo.toRelative( "/myproject/myproject/",
+                                        
"/myproject/myproject-module1/myproject-module1.iml" );
+        assertEquals( "Test parent matches prefix of child, trailing slash", 
"../myproject-module1/myproject-module1.iml", relativePath );
     }
 }
\ No newline at end of file


Reply via email to