continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r816464 - in /continuum/trunk/continuum-core/src: main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
Date Fri, 18 Sep 2009 03:58:08 GMT
Author: ctan
Date: Fri Sep 18 03:58:08 2009
New Revision: 816464

URL: http://svn.apache.org/viewvc?rev=816464&view=rev
Log:
[CONTINUUM-2350] fixed project scm root url for flat-multi-module project with module name
that starts with the same letter
merge -r 816460:816461 from 1.3.x branch

Modified:
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java?rev=816464&r1=816463&r2=816464&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
Fri Sep 18 03:58:08 2009
@@ -253,7 +253,19 @@
         else
         {
             int indexDiff = StringUtils.differenceAt( path1, path2 );
-            return path1.substring( 0, indexDiff );
+            String commonPath = path1.substring( 0, indexDiff );
+
+            if ( commonPath.lastIndexOf( '/' ) != commonPath.length() - 1 &&
+                 !( path1.contains( new String( commonPath + "/" ) ) || 
+                    path2.contains( new String( commonPath + "/" ) ) ) )
+            {
+                while ( commonPath.lastIndexOf( '/' ) != commonPath.length() - 1 )
+                {
+                    commonPath = commonPath.substring( 0, commonPath.length() - 1 );
+                }
+            }
+
+            return commonPath;
         }
     }
 

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java?rev=816464&r1=816463&r2=816464&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
(original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
Fri Sep 18 03:58:08 2009
@@ -25,6 +25,7 @@
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
+import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.continuum.project.builder.manager.ContinuumProjectBuilderManager;
@@ -42,9 +43,12 @@
 
     private CreateProjectsFromMetadataAction action;
 
+    private ContinuumProjectBuildingResult result;
+
     protected void setUp()
         throws Exception
     {
+        result = new ContinuumProjectBuildingResult();
         action = new CreateProjectsFromMetadataAction();
         action.enableLogging( new ConsoleLogger( Logger.LEVEL_DEBUG, "" ) );
         Mock projectBuilderManagerMock = mock( ContinuumProjectBuilderManager.class );
@@ -57,7 +61,7 @@
         projectBuilderManagerMock.expects( once() ).method( "getProjectBuilder" ).will(
             returnValue( projectBuilder.proxy() ) );
         projectBuilder.expects( once() ).method( "buildProjectsFromMetadata" ).will(
-            returnValue( new ContinuumProjectBuildingResult() ) );
+            returnValue( result ) );
 
         projectBuilder.expects( once() ).method( "getDefaultBuildDefinitionTemplate" ).will(
             returnValue( getDefaultBuildDefinitionTemplate() ) );
@@ -123,4 +127,55 @@
             result.hasErrors() );
     }
 
+    public void testExecuteFlatMultiModuleProjectThatStartsWithTheSameLetter()
+        throws Exception
+    {
+        Project project = new Project();
+        project.setGroupId( "com.example.flat" );
+        project.setArtifactId( "flat-parent" );
+        project.setVersion( "1.0-SNAPSHOT" );
+        project.setId( 6 );
+        project.setName( "Flat Example" );
+        project.setScmUrl( "scm:svn:http://svn.apache.org/repos/asf/continuum/sandbox/flat-example/flat-parent"
);
+
+        this.result.addProject( project );
+
+        project = new Project();
+        project.setGroupId( "com.example.flat" );
+        project.setArtifactId( "flat-core" );
+        project.setVersion( "1.0-SNAPSHOT" );
+        project.setId( 7 );
+        project.setName( "flat-core" );
+        project.setScmUrl( "scm:svn:http://svn.apache.org/repos/asf/continuum/sandbox/flat-example/flat-core"
);
+
+        this.result.addProject( project );
+
+        project = new Project();
+        project.setGroupId( "com.example.flat" );
+        project.setArtifactId( "flat-webapp" );
+        project.setVersion( "1.0-SNAPSHOT" );
+        project.setId( 8 );
+        project.setName( "flat-webapp Maven Webapp" );
+        project.setScmUrl( "scm:svn:http://svn.apache.org/repos/asf/continuum/sandbox/flat-example/flat-webapp"
);
+
+        this.result.addProject( project );
+
+        Map<String, Object> context = new HashMap<String, Object>();
+        CreateProjectsFromMetadataAction.setUrl( context,
+                                                 "http://svn.apache.org/repos/asf/continuum/sandbox/flat-example/flat-parent/pom.xml"
);
+        CreateProjectsFromMetadataAction.setProjectBuilderId( context, "id" );
+        CreateProjectsFromMetadataAction.setLoadRecursiveProject( context, true );
+
+        action.execute( context );
+
+        ContinuumProjectBuildingResult result = CreateProjectsFromMetadataAction.getProjectBuildingResult(
context );
+
+        assertFalse(
+            "Should not have errors but had " + result.getErrorsAsString() + " (this test
requires internet access)",
+            result.hasErrors() );
+
+        assertEquals(
+            "Wrong scm root url created", "scm:svn:http://svn.apache.org/repos/asf/continuum/sandbox/flat-example/",
+            CreateProjectsFromMetadataAction.getUrl( context ) );
+    }
 }



Mime
View raw message