continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r946548 [2/3] - in /continuum/trunk: ./ continuum-api/src/main/java/org/apache/continuum/buildmanager/ continuum-api/src/main/java/org/apache/continuum/taskqueue/ continuum-api/src/main/java/org/apache/maven/continuum/ continuum-api/src/mai...
Date Thu, 20 May 2010 07:30:46 GMT
Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckWorkingDirectoryAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckWorkingDirectoryAction.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckWorkingDirectoryAction.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckWorkingDirectoryAction.java Thu May 20 07:30:43 2010
@@ -20,6 +20,7 @@ package org.apache.maven.continuum.core.
  */
 
 import java.io.File;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.continuum.dao.ProjectDao;
@@ -36,8 +37,6 @@ import org.apache.maven.continuum.utils.
 public class CheckWorkingDirectoryAction
     extends AbstractContinuumAction
 {
-    private static final String KEY_WORKING_DIRECTORY_EXISTS = "working-directory-exists";
-
     /**
      * @plexus.requirement
      */
@@ -47,17 +46,23 @@ public class CheckWorkingDirectoryAction
      * @plexus.requirement
      */
     private ProjectDao projectDao;
+    
+    private static final String KEY_WORKING_DIRECTORY_EXISTS = "working-directory-exists";
 
     public void execute( Map context )
         throws Exception
     {
         Project project = projectDao.getProject( getProjectId( context ) );
-
-        File workingDirectory = workingDirectoryService.getWorkingDirectory( project );
+        List<Project> projectsWithCommonScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context );
+        String projectScmRootUrl = getProjectScmRootUrl( context, project.getScmUrl() );
+       
+        File workingDirectory =
+            workingDirectoryService.getWorkingDirectory( project, projectScmRootUrl,
+                                                         projectsWithCommonScmRoot );
 
         if ( !workingDirectory.exists() )
         {
-            setWorkingDirectoryExist( context, false );
+            setWorkingDirectoryExists( context, false );
 
             return;
         }
@@ -72,16 +77,17 @@ public class CheckWorkingDirectoryAction
             throw new ContinuumException( msg );
         }
 
-        setWorkingDirectoryExist( context, files.length > 0 );
+        setWorkingDirectoryExists( context, files.length > 0 );
     }
-
-    public static boolean isWorkingDirectoryExist( Map<String, Object> context )
+    
+    public static boolean isWorkingDirectoryExists( Map<String, Object> context )
     {
-        return getBoolean( context, KEY_WORKING_DIRECTORY_EXISTS );
+        return getBoolean( context, KEY_WORKING_DIRECTORY_EXISTS, false );
     }
 
-    private static void setWorkingDirectoryExist( Map<String, Object> context, boolean exists )
+    public static void setWorkingDirectoryExists( Map<String, Object> context, boolean isWorkingDirectoryExists )
     {
-        context.put( KEY_WORKING_DIRECTORY_EXISTS, exists );
+        context.put( KEY_WORKING_DIRECTORY_EXISTS, isWorkingDirectoryExists );
     }
+
 }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java Thu May 20 07:30:43 2010
@@ -53,9 +53,9 @@ public class CheckoutProjectContinuumAct
 
     private static final String KEY_SCM_PASSWORD = "scmUserPassword";
 
-    private static final String KEY_CHECKOUT_SCM_RESULT = "checkout-result";
-
     private static final String KEY_PROJECT_RELATIVE_PATH = "project-relative-path";
+    
+    private static final String KEY_CHECKOUT_SCM_RESULT = "checkout-result";
 
     /**
      * @plexus.requirement
@@ -103,13 +103,17 @@ public class CheckoutProjectContinuumAct
 
         ScmResult result;
 
+        List<Project> projectsWithCommonScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context );
+        
         try
         {
             String scmUserName = getScmUsername( context, project.getScmUsername() );
             String scmPassword = getScmPassword( context, project.getScmPassword() );
+            String scmRootUrl = getProjectScmRootUrl( context, project.getScmUrl() );
+            
             ContinuumScmConfiguration config =
-                createScmConfiguration( project, workingDirectory, scmUserName, scmPassword );
-
+            	createScmConfiguration( project, workingDirectory, scmUserName, scmPassword, scmRootUrl, isRootDirectory( context ) );
+                
             String tag = config.getTag();
             getLogger().info(
                 "Checking out project: '" + project.getName() + "', id: '" + project.getId() + "' " + "to '" +
@@ -118,7 +122,7 @@ public class CheckoutProjectContinuumAct
             CheckOutScmResult checkoutResult = scm.checkout( config );
             if ( StringUtils.isNotEmpty( checkoutResult.getRelativePathProjectDirectory() ) )
             {
-                context.put( KEY_PROJECT_RELATIVE_PATH, checkoutResult.getRelativePathProjectDirectory() );
+                setProjectRelativePath( context, checkoutResult.getRelativePathProjectDirectory() );
             }
 
             if ( !checkoutResult.isSuccess() )
@@ -186,7 +190,8 @@ public class CheckoutProjectContinuumAct
         }
         finally
         {
-            String relativePath = getString( context, KEY_PROJECT_RELATIVE_PATH, "" );
+            String relativePath = getProjectRelativePath( context );
+            
             if ( StringUtils.isNotEmpty( relativePath ) )
             {
                 project.setRelativePath( relativePath );
@@ -205,18 +210,40 @@ public class CheckoutProjectContinuumAct
 
             projectDao.updateProject( project );
 
+            // update state of sub-projects 
+            // if multi-module project was checked out in a single directory, these must not be null            
+            for( Project projectWithCommonScmRoot : projectsWithCommonScmRoot )
+            {
+                projectWithCommonScmRoot = projectDao.getProject( projectWithCommonScmRoot.getId() );
+                if( projectWithCommonScmRoot != null && projectWithCommonScmRoot.getId() != project.getId() &&
+                                projectWithCommonScmRoot.getState() == ContinuumProjectState.NEW )
+                {
+                    projectWithCommonScmRoot.setState( ContinuumProjectState.CHECKEDOUT );
+                   projectDao.updateProject( projectWithCommonScmRoot );                    
+                }
+            }
+            
             notifier.checkoutComplete( project, buildDefinition );
         }
 
-        setCheckoutResult( context, result );
+        setCheckoutScmResult( context, result );
         setProject( context, project );
     }
 
     private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory,
-                                                              String scmUserName, String scmPassword )
+    													String scmUserName, String scmPassword, String scmRootUrl,
+    		                                                              boolean isRootDirectory )
     {
         ContinuumScmConfiguration config = new ContinuumScmConfiguration();
-        config.setUrl( project.getScmUrl() );
+        
+        if( project.isCheckedOutInSingleDirectory() && scmRootUrl!= null && !"".equals( scmRootUrl ) && isRootDirectory )
+        {
+            config.setUrl( scmRootUrl );
+        }
+        else
+        {
+            config.setUrl( project.getScmUrl() );
+        }
         config.setUsername( scmUserName );
         config.setPassword( scmPassword );
         config.setUseCredentialsCache( project.isScmUseCache() );
@@ -302,14 +329,24 @@ public class CheckoutProjectContinuumAct
     {
         context.put( KEY_SCM_PASSWORD, scmPassword );
     }
-
-    public static ScmResult getCheckoutResult( Map<String, Object> context, Object defaultValue )
+    
+    public static String getProjectRelativePath( Map<String, Object> context )
+    {
+        return getString( context, KEY_PROJECT_RELATIVE_PATH, "" );
+    }
+    
+    public static void setProjectRelativePath( Map<String, Object> context, String projectRelativePath )
+    {
+        context.put( KEY_PROJECT_RELATIVE_PATH, projectRelativePath );
+    }
+    
+    public static ScmResult getCheckoutScmResult( Map<String, Object> context, ScmResult defaultValue )
     {
         return (ScmResult) getObject( context, KEY_CHECKOUT_SCM_RESULT, defaultValue );
     }
 
-    public static void setCheckoutResult( Map<String, Object> context, ScmResult checkoutResult )
+    public static void setCheckoutScmResult( Map<String, Object> context, ScmResult scmResult )
     {
-        context.put( KEY_CHECKOUT_SCM_RESULT, checkoutResult );
+        context.put( KEY_CHECKOUT_SCM_RESULT, scmResult );
     }
 }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CleanWorkingDirectoryAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CleanWorkingDirectoryAction.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CleanWorkingDirectoryAction.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CleanWorkingDirectoryAction.java Thu May 20 07:30:43 2010
@@ -26,6 +26,7 @@ import org.apache.maven.shared.model.fil
 import org.apache.maven.shared.model.fileset.util.FileSetManager;
 
 import java.io.File;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -51,8 +52,12 @@ public class CleanWorkingDirectoryAction
         throws Exception
     {
         Project project = projectDao.getProject( getProjectId( context ) );
+        List<Project> projectsWithCommonScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context );        
+        String projectScmRootUrl = getProjectScmRootUrl( context, project.getScmUrl() );
 
-        File workingDirectory = workingDirectoryService.getWorkingDirectory( project );
+        File workingDirectory =
+        	            workingDirectoryService.getWorkingDirectory( project, projectScmRootUrl,
+        	                                                         projectsWithCommonScmRoot );
 
         if ( workingDirectory.exists() )
         {

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=946548&r1=946547&r2=946548&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 Thu May 20 07:30:43 2010
@@ -61,14 +61,19 @@ import org.codehaus.plexus.util.xml.pull
 public class CreateProjectsFromMetadataAction
     extends AbstractContinuumAction
 {
+    /**
+     * Metadata url for adding projects.
+    */
     private static final String KEY_URL = "url";
-
-    private static final String KEY_PROJECT_BUILDER_ID = "builderId";
-
-    private static final String KEY_PROJECT_BUILDING_RESULT = "projectBuildingResult";
-
+    
+	private static final String KEY_PROJECT_BUILDER_ID = "builderId";
+	
+	private static final String KEY_PROJECT_BUILDING_RESULT = "projectBuildingResult";
+	
     private static final String KEY_LOAD_RECURSIVE_PROJECTS = "loadRecursiveProjects";
 
+    public static final String KEY_CHECKOUT_PROJECTS_IN_SINGLE_DIRECTORY = "checkoutProjectsInSingleDirectory";
+
     /**
      * @plexus.requirement
      */
@@ -88,11 +93,13 @@ public class CreateProjectsFromMetadataA
         throws ContinuumException, ContinuumProjectBuilderManagerException, ContinuumProjectBuilderException
     {
         String projectBuilderId = getProjectBuilderId( context );
-
+    	
         boolean loadRecursiveProjects = isLoadRecursiveProject( context );
+    	        
+        boolean checkoutProjectsInSingleDirectory = getBoolean( context, KEY_CHECKOUT_PROJECTS_IN_SINGLE_DIRECTORY );
 
         String curl = getUrl( context );
-
+        
         URL url;
 
         ContinuumProjectBuilder projectBuilder = projectBuilderManager.getProjectBuilder( projectBuilderId );
@@ -111,7 +118,7 @@ public class CreateProjectsFromMetadataA
                 url = new URL( curl );
 
                 result = projectBuilder.buildProjectsFromMetadata( url, null, null, loadRecursiveProjects,
-                                                                   buildDefinitionTemplate );
+                		 						buildDefinitionTemplate, checkoutProjectsInSingleDirectory );
 
             }
             else
@@ -150,7 +157,7 @@ public class CreateProjectsFromMetadataA
                 {
 
                     result = projectBuilder.buildProjectsFromMetadata( url, username, password, loadRecursiveProjects,
-                                                                       buildDefinitionTemplate );
+                    											buildDefinitionTemplate, checkoutProjectsInSingleDirectory );
 
                 }
                 else
@@ -177,7 +184,8 @@ public class CreateProjectsFromMetadataA
                     }
                 }
 
-                setUrl( context, scmRootUrl );
+                //setUrl( context, scmRootUrl );
+                setProjectScmRootUrl( context, scmRootUrl );
             }
         }
         catch ( MalformedURLException e )
@@ -298,17 +306,7 @@ public class CreateProjectsFromMetadataA
     {
         this.urlValidator = urlValidator;
     }
-
-    public static ContinuumProjectBuildingResult getProjectBuildingResult( Map<String, Object> context )
-    {
-        return (ContinuumProjectBuildingResult) getObject( context, KEY_PROJECT_BUILDING_RESULT );
-    }
-
-    private static void setProjectBuildingResult( Map<String, Object> context, ContinuumProjectBuildingResult result )
-    {
-        context.put( KEY_PROJECT_BUILDING_RESULT, result );
-    }
-
+    
     public static String getUrl( Map<String, Object> context )
     {
         return getString( context, KEY_URL );
@@ -318,7 +316,7 @@ public class CreateProjectsFromMetadataA
     {
         context.put( KEY_URL, url );
     }
-
+    
     public static String getProjectBuilderId( Map<String, Object> context )
     {
         return getString( context, KEY_PROJECT_BUILDER_ID );
@@ -329,6 +327,16 @@ public class CreateProjectsFromMetadataA
         context.put( KEY_PROJECT_BUILDER_ID, projectBuilderId );
     }
 
+    public static ContinuumProjectBuildingResult getProjectBuildingResult( Map<String, Object> context )
+    {
+        return (ContinuumProjectBuildingResult) getObject( context, KEY_PROJECT_BUILDING_RESULT );
+    }
+
+    private static void setProjectBuildingResult( Map<String, Object> context, ContinuumProjectBuildingResult result )
+    {
+        context.put( KEY_PROJECT_BUILDING_RESULT, result );
+    }
+    
     public static boolean isLoadRecursiveProject( Map<String, Object> context )
     {
         return getBoolean( context, KEY_LOAD_RECURSIVE_PROJECTS );
@@ -338,4 +346,14 @@ public class CreateProjectsFromMetadataA
     {
         context.put( KEY_LOAD_RECURSIVE_PROJECTS, loadRecursiveProject );
     }
+    
+    public static boolean isCheckoutProjectsInSingleDirectory( Map<String, Object> context )
+    {
+        return getBoolean( context, KEY_CHECKOUT_PROJECTS_IN_SINGLE_DIRECTORY );
+    }
+    
+    public static void setCheckoutProjectsInSingleDirectory( Map<String, Object> context, boolean checkoutProjectsInSingleDirectory )
+    {
+        context.put( KEY_CHECKOUT_PROJECTS_IN_SINGLE_DIRECTORY, checkoutProjectsInSingleDirectory );
+    }
 }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java Thu May 20 07:30:43 2010
@@ -101,10 +101,14 @@ public class DeployArtifactContinuumActi
             if ( project.getState() == ContinuumProjectState.OK )
             {
                 BuildDefinition buildDefinition = getBuildDefinition( context );
+                
+                String projectScmRootUrl = getProjectScmRootUrl( context, project.getScmUrl() );
+                
+                List<Project> projectsWithCommonScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context );
 
                 List<Artifact> artifacts = buildExecutor.getDeployableArtifacts( project,
-                                                                                 workingDirectoryService.getWorkingDirectory(
-                                                                                     project ), buildDefinition );
+                									workingDirectoryService.getWorkingDirectory( 
+                									project, projectScmRootUrl, projectsWithCommonScmRoot ), buildDefinition );
 
                 LocalRepository repository = project.getProjectGroup().getLocalRepository();
 

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java Thu May 20 07:30:43 2010
@@ -123,14 +123,19 @@ public class ExecuteBuilderContinuumActi
         setCancelled( context, false );
 
         buildResult = buildResultDao.getBuildResult( buildResult.getId() );
-
+        
+        String projectScmRootUrl = getProjectScmRootUrl( context, project.getScmUrl() );
+        List<Project> projectsWithCommonScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context );
+        
         try
         {
             notifier.runningGoals( project, buildDefinition, buildResult );
 
             File buildOutputFile = configurationService.getBuildOutputFile( buildResult.getId(), project.getId() );
-
-            ContinuumBuildExecutionResult result = buildExecutor.build( project, buildDefinition, buildOutputFile );
+            
+            ContinuumBuildExecutionResult result =
+                buildExecutor.build( project, buildDefinition, buildOutputFile, projectsWithCommonScmRoot,
+                                     projectScmRootUrl );
 
             buildResult.setState( result.getExitCode() == 0 ? ContinuumProjectState.OK : ContinuumProjectState.FAILED );
 
@@ -204,12 +209,15 @@ public class ExecuteBuilderContinuumActi
             AbstractContinuumAction.setProject( context, project );
 
             projectDao.updateProject( project );
+            
+            projectScmRootUrl = getProjectScmRootUrl( context, project.getScmUrl() );
+            projectsWithCommonScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context );
 
             // ----------------------------------------------------------------------
             // Backup test result files
             // ----------------------------------------------------------------------
             //TODO: Move as a plugin
-            buildExecutor.backupTestFiles( project, buildResult.getId() );
+            buildExecutor.backupTestFiles( project, buildResult.getId(), projectScmRootUrl, projectsWithCommonScmRoot );
         }
     }
 

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreCheckOutScmResultAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreCheckOutScmResultAction.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreCheckOutScmResultAction.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreCheckOutScmResultAction.java Thu May 20 07:30:43 2010
@@ -50,7 +50,7 @@ public class StoreCheckOutScmResultActio
             //
             // ----------------------------------------------------------------------
 
-            ScmResult scmResult = CheckoutProjectContinuumAction.getCheckoutResult( context, null );
+            ScmResult scmResult = CheckoutProjectContinuumAction.getCheckoutScmResult( context, null );
 
             Project project = projectDao.getProject( getProjectId( context ) );
 

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromWorkingDirectoryContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromWorkingDirectoryContinuumAction.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromWorkingDirectoryContinuumAction.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromWorkingDirectoryContinuumAction.java Thu May 20 07:30:43 2010
@@ -19,6 +19,7 @@ package org.apache.maven.continuum.core.
  * under the License.
  */
 
+import java.util.List;
 import java.util.Map;
 
 import org.apache.continuum.dao.BuildDefinitionDao;
@@ -80,9 +81,11 @@ public class UpdateProjectFromWorkingDir
         ContinuumBuildExecutor builder = buildExecutorManager.getBuildExecutor( project.getExecutorId() );
 
         ScmResult scmResult = (ScmResult) context.get( "scmResult" );
-        builder.updateProjectFromCheckOut( workingDirectoryService.getWorkingDirectory( project ), project,
-                                           buildDefinition, scmResult );
-
+        List<Project> projectsWithCommonScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context );
+        String projectScmRootUrl = getProjectScmRootUrl( context, project.getScmUrl() );
+        
+        builder.updateProjectFromCheckOut( workingDirectoryService.getWorkingDirectory( project, 
+                        projectScmRootUrl, projectsWithCommonScmRoot ), project, buildDefinition, scmResult );
         // ----------------------------------------------------------------------
         // Store the new descriptor
         // ----------------------------------------------------------------------

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java Thu May 20 07:30:43 2010
@@ -116,9 +116,15 @@ public class UpdateWorkingDirectoryFromS
         {
             notifier.checkoutStarted( project, buildDefinition );
 
-            // TODO: not sure why this is different to the context, but it all needs to change
-            File workingDirectory = workingDirectoryService.getWorkingDirectory( project );
-            ContinuumScmConfiguration config = createScmConfiguration( project, workingDirectory );
+            List<Project> projectsWithCommonScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context );           
+            String projectScmRootUrl = getProjectScmRootUrl( context, project.getScmUrl() );
+            
+         // TODO: not sure why this is different to the context, but it all needs to change            
+            File workingDirectory =
+                workingDirectoryService.getWorkingDirectory( project, projectScmRootUrl,
+                                                             projectsWithCommonScmRoot );    
+            
+            ContinuumScmConfiguration config = createScmConfiguration( project, workingDirectory, projectScmRootUrl );
             config.setLatestUpdateDate( latestUpdateDate );
             String tag = config.getTag();
             String msg =
@@ -194,14 +200,23 @@ public class UpdateWorkingDirectoryFromS
             notifier.checkoutComplete( project, buildDefinition );
         }
 
-        context.put( KEY_UPDATE_SCM_RESULT, result );
+        setUpdateScmResult( context, result );
         AbstractContinuumAction.setProject( context, project );
     }
 
-    private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory )
+    private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory, String scmRootUrl )
     {
         ContinuumScmConfiguration config = new ContinuumScmConfiguration();
-        config.setUrl( project.getScmUrl() );
+        
+        if( project.isCheckedOutInSingleDirectory() && scmRootUrl!= null && !"".equals( scmRootUrl ) )
+        {
+            config.setUrl( scmRootUrl );
+        }
+        else
+        {
+            config.setUrl( project.getScmUrl() );
+        }
+        
         config.setUsername( project.getScmUsername() );
         config.setPassword( project.getScmPassword() );
         config.setUseCredentialsCache( project.isScmUseCache() );
@@ -337,14 +352,14 @@ public class UpdateWorkingDirectoryFromS
         }
         return message.toString();
     }
-
-    public static ScmResult getUpdateScmResult( Map<String, Object> context )
-    {
-        return getUpdateScmResult( context, null );
-    }
-
+    
     public static ScmResult getUpdateScmResult( Map<String, Object> context, ScmResult defaultValue )
     {
         return (ScmResult) getObject( context, KEY_UPDATE_SCM_RESULT, defaultValue );
     }
+    
+    public static void setUpdateScmResult( Map<String, Object> context, ScmResult scmResult )
+    {
+        context.put( KEY_UPDATE_SCM_RESULT, scmResult );
+    }
 }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java Thu May 20 07:30:43 2010
@@ -244,11 +244,13 @@ public abstract class AbstractBuildExecu
     }
 
     protected ContinuumBuildExecutionResult executeShellCommand( Project project, String executable, String arguments,
-                                                                 File output, Map<String, String> environments )
+                                                                 File output, Map<String, String> environments,
+                                                                 List<Project> projectsWithCommonScmRoot,
+                                                                 String projectScmRootUrl )
         throws ContinuumBuildExecutorException
     {
 
-        File workingDirectory = getWorkingDirectory( project );
+    	File workingDirectory = getWorkingDirectory( project, projectScmRootUrl, projectsWithCommonScmRoot );
 
         String actualExecutable = findExecutable( executable, defaultExecutable, resolveExecutable, workingDirectory );
 
@@ -340,7 +342,7 @@ public abstract class AbstractBuildExecu
         return jdk.getVarValue();
     }
 
-    public void backupTestFiles( Project project, int buildId )
+    public void backupTestFiles( Project project, int buildId, String projectScmRootUrl, List<Project> projectsWithCommonScmRoot )
     {
         //Nothing to do, by default
     }
@@ -453,12 +455,12 @@ public abstract class AbstractBuildExecu
         throws ContinuumBuildExecutorException
     {
         // Not supported by this builder
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
     }
 
-    public File getWorkingDirectory( Project project )
+    public File getWorkingDirectory( Project project, String projectScmRootUrl, List<Project> projectsWithCommonScmRoot )
     {
-        return getWorkingDirectoryService().getWorkingDirectory( project );
+        return getWorkingDirectoryService().getWorkingDirectory( project, projectScmRootUrl, projectsWithCommonScmRoot );
     }
 
     public InstallationService getInstallationService()

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/ant/AntBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/ant/AntBuildExecutor.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/ant/AntBuildExecutor.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/ant/AntBuildExecutor.java Thu May 20 07:30:43 2010
@@ -36,6 +36,7 @@ import java.io.File;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
@@ -70,7 +71,7 @@ public class AntBuildExecutor
     // ContinuumBuilder Implementation
     // ----------------------------------------------------------------------
 
-    public ContinuumBuildExecutionResult build( Project project, BuildDefinition buildDefinition, File buildOutput )
+    public ContinuumBuildExecutionResult build( Project project, BuildDefinition buildDefinition, File buildOutput, List<Project> projectsWithCommonScmRoot, String projectScmRootUrl )
         throws ContinuumBuildExecutorException
     {
         String executable = getInstallationService().getExecutorConfigurator( InstallationService.ANT_TYPE )
@@ -105,7 +106,7 @@ public class AntBuildExecutor
             setResolveExecutable( false );
         }
 
-        return executeShellCommand( project, executable, arguments.toString(), buildOutput, environments );
+        return executeShellCommand( project, executable, arguments.toString(), buildOutput, environments, null, null );
     }
 
     protected Map<String, String> getEnvironments( BuildDefinition buildDefinition )

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutor.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutor.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutor.java Thu May 20 07:30:43 2010
@@ -23,6 +23,7 @@ import java.io.File;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
@@ -81,7 +82,7 @@ public class MavenOneBuildExecutor
     // Builder Implementation
     // ----------------------------------------------------------------------
 
-    public ContinuumBuildExecutionResult build( Project project, BuildDefinition buildDefinition, File buildOutput )
+    public ContinuumBuildExecutionResult build( Project project, BuildDefinition buildDefinition, File buildOutput, List<Project> projectsWithCommonScmRoot, String projectScmRootUrl )
         throws ContinuumBuildExecutorException
     {
         String executable =
@@ -124,7 +125,7 @@ public class MavenOneBuildExecutor
             setResolveExecutable( false );
         }
 
-        return executeShellCommand( project, executable, arguments.toString(), buildOutput, environments );
+        return executeShellCommand( project, executable, arguments.toString(), buildOutput, environments, null, null );
     }
 
     protected Map<String, String> getEnvironments( BuildDefinition buildDefinition )

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java Thu May 20 07:30:43 2010
@@ -135,7 +135,8 @@ public class MavenTwoBuildExecutor
     // ContinuumBuilder Implementation
     // ----------------------------------------------------------------------
 
-    public ContinuumBuildExecutionResult build( Project project, BuildDefinition buildDefinition, File buildOutput )
+    public ContinuumBuildExecutionResult build( Project project, BuildDefinition buildDefinition, File buildOutput,
+                                                List<Project> projectsWithCommonScmRoot, String projectScmRootUrl )
         throws ContinuumBuildExecutorException
     {
         String executable = getInstallationService().getExecutorConfigurator( InstallationService.MAVEN2_TYPE )
@@ -177,7 +178,7 @@ public class MavenTwoBuildExecutor
             setResolveExecutable( false );
         }
 
-        return executeShellCommand( project, executable, arguments.toString(), buildOutput, environments );
+        return executeShellCommand( project, executable, arguments.toString(), buildOutput, environments, null, null );
     }
 
     public void updateProjectFromCheckOut( File workingDirectory, Project project, BuildDefinition buildDefinition,
@@ -338,7 +339,7 @@ public class MavenTwoBuildExecutor
     }
 
     @Override
-    public void backupTestFiles( Project project, int buildId )
+    public void backupTestFiles( Project project, int buildId, String projectScmRootUrl, List<Project> projectsWithCommonScmRoot )
     {
         File backupDirectory = null;
         try
@@ -353,7 +354,7 @@ public class MavenTwoBuildExecutor
         {
             log.info( "error on surefire backup directory creation skip backup " + e.getMessage(), e );
         }
-        backupTestFiles( getWorkingDirectory( project ), backupDirectory );
+        backupTestFiles( getWorkingDirectory( project, projectScmRootUrl, projectsWithCommonScmRoot ), backupDirectory );
     }
 
     private void backupTestFiles( File workingDir, File backupDirectory )

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/shell/ShellBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/shell/ShellBuildExecutor.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/shell/ShellBuildExecutor.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/shell/ShellBuildExecutor.java Thu May 20 07:30:43 2010
@@ -35,6 +35,7 @@ import org.codehaus.plexus.util.StringUt
 import java.io.File;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -67,14 +68,14 @@ public class ShellBuildExecutor
     // ----------------------------------------------------------------------
 
     public synchronized ContinuumBuildExecutionResult build( Project project, BuildDefinition buildDefinition,
-                                                             File buildOutput )
+                                                             File buildOutput, List<Project> projectsWithCommonScmRoot, String projectScmRootUrl )
         throws ContinuumBuildExecutorException
     {
         // TODO: this should be validated earlier?
         String executable = getBuildFileForProject( project, buildDefinition );
 
         return executeShellCommand( project, executable, buildDefinition.getArguments(), buildOutput,
-                                    getEnvironments( buildDefinition ) );
+                                    getEnvironments( buildDefinition ), null, null );
     }
 
     protected Map<String, String> getEnvironments( BuildDefinition buildDefinition )

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java Thu May 20 07:30:43 2010
@@ -67,17 +67,17 @@ public class MavenOneContinuumProjectBui
     public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String password )
         throws ContinuumProjectBuilderException
     {
-        return buildProjectsFromMetadata( url, username, password, true );
+    	return buildProjectsFromMetadata( url, username, password, true, false );
     }
 
     public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String password,
-                                                                     boolean recursiveProjects )
+    						boolean recursiveProjects, boolean checkoutInSingleDirectory )
         throws ContinuumProjectBuilderException
     {
         try
         {
             return buildProjectsFromMetadata( url, username, password, recursiveProjects,
-                                              buildDefinitionService.getDefaultMavenOneBuildDefinitionTemplate() );
+            				buildDefinitionService.getDefaultMavenOneBuildDefinitionTemplate(), false );
         }
         catch ( BuildDefinitionServiceException e )
         {
@@ -87,7 +87,7 @@ public class MavenOneContinuumProjectBui
 
     public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String password,
                                                                      boolean recursiveProjects,
-                                                                     BuildDefinitionTemplate buildDefinitionTemplate )
+                                                                     BuildDefinitionTemplate buildDefinitionTemplate, boolean checkoutInSingleDirectory )
         throws ContinuumProjectBuilderException
     {
         ContinuumProjectBuildingResult result = new ContinuumProjectBuildingResult();

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java Thu May 20 07:30:43 2010
@@ -83,6 +83,8 @@ public class MavenTwoContinuumProjectBui
      * @plexus.configuration
      */
     private List<String> excludedPackagingTypes = new ArrayList<String>();
+        
+    private Project rootProject;
 
     // ----------------------------------------------------------------------
     // AbstractContinuumProjectBuilder Implementation
@@ -90,17 +92,18 @@ public class MavenTwoContinuumProjectBui
     public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String password )
         throws ContinuumProjectBuilderException
     {
-        return buildProjectsFromMetadata( url, username, password, true );
+    	return buildProjectsFromMetadata( url, username, password, true, false );
     }
 
     public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String password,
-                                                                     boolean loadRecursiveProjects )
+    				boolean loadRecursiveProjects, boolean checkoutInSingleDirectory )
         throws ContinuumProjectBuilderException
     {
         try
         {
             return buildProjectsFromMetadata( url, username, password, loadRecursiveProjects,
-                                              buildDefinitionService.getDefaultMavenTwoBuildDefinitionTemplate() );
+            						buildDefinitionService.getDefaultMavenTwoBuildDefinitionTemplate(),
+                                    checkoutInSingleDirectory );
         }
         catch ( BuildDefinitionServiceException e )
         {
@@ -110,7 +113,7 @@ public class MavenTwoContinuumProjectBui
 
     public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String password,
                                                                      boolean loadRecursiveProjects,
-                                                                     BuildDefinitionTemplate buildDefinitionTemplate )
+                                                                     BuildDefinitionTemplate buildDefinitionTemplate, boolean checkoutInSingleDirectory )
         throws ContinuumProjectBuilderException
     {
         // ----------------------------------------------------------------------
@@ -121,7 +124,7 @@ public class MavenTwoContinuumProjectBui
 
         try
         {
-            readModules( url, result, true, username, password, null, loadRecursiveProjects, buildDefinitionTemplate );
+        	readModules( url, result, true, username, password, null, loadRecursiveProjects, buildDefinitionTemplate, checkoutInSingleDirectory );
         }
         catch ( BuildDefinitionServiceException e )
         {
@@ -136,7 +139,7 @@ public class MavenTwoContinuumProjectBui
 
     private void readModules( URL url, ContinuumProjectBuildingResult result, boolean groupPom, String username,
                               String password, String scmUrl, boolean loadRecursiveProjects,
-                              BuildDefinitionTemplate buildDefinitionTemplate )
+                              BuildDefinitionTemplate buildDefinitionTemplate, boolean checkoutInSingleDirectory )
         throws ContinuumProjectBuilderException, BuildDefinitionServiceException
     {
 
@@ -238,6 +241,9 @@ public class MavenTwoContinuumProjectBui
                     continuumProject.setScmPassword( password );
                 }
             }
+            
+            continuumProject.setCheckedOutInSingleDirectory( checkoutInSingleDirectory );
+            
             // New project
             builderHelper.mapMavenProjectToContinuumProject( result, mavenProject, continuumProject, true);
 
@@ -264,6 +270,13 @@ public class MavenTwoContinuumProjectBui
                 continuumProject.setScmTag( mavenProject.getScm().getTag() );
             }
             result.addProject( continuumProject, MavenTwoBuildExecutor.ID );
+            
+                        
+	        if( checkoutInSingleDirectory && rootProject == null )
+	        {
+	            rootProject = continuumProject;
+	            result.setRootProject( rootProject );
+	        }
         }
 
         List<String> modules = mavenProject.getModules();
@@ -300,6 +313,7 @@ public class MavenTwoContinuumProjectBui
 
                     try
                     {
+                    	urlString = StringUtils.replace( urlString, '\\', '/' );
                         moduleUrl = new URL( urlString );
                     }
                     catch ( MalformedURLException e )
@@ -308,19 +322,34 @@ public class MavenTwoContinuumProjectBui
                         result.addError( ContinuumProjectBuildingResult.ERROR_MALFORMED_URL, urlString );
                         continue;
                     }
-
-                    String moduleScmUrl;
-                    if ( scmUrl.endsWith( "/" ) )
-                    {
-                        moduleScmUrl = scmUrl + module;
+                    
+                    String moduleScmUrl = "";                    
+                 
+                    String modulePath = StringUtils.replace( new String( module ), '\\', '/' );
+                    
+                    // check if module is relative
+                    if( modulePath.indexOf( "../" ) != -1 )
+                    {   
+                        int depth =
+                            StringUtils.countMatches( StringUtils.substring( modulePath, 0,
+                                                                             modulePath.lastIndexOf( '/' ) + 1 ), "/" );
+                        
+                        String baseUrl = "";
+                        for( int j = 1; j <= depth; j++ )
+                        {
+                            scmUrl = StringUtils.chompLast( new String( scmUrl ), "/" );
+                            baseUrl = StringUtils.substring( scmUrl, 0, scmUrl.lastIndexOf( '/' ) );                            
+                        }
+                        moduleScmUrl = baseUrl + "/" + StringUtils.substring( modulePath, modulePath.lastIndexOf( "../" ) + 3 );
                     }
                     else
                     {
-                        moduleScmUrl = scmUrl + "/" + module;
+                    	scmUrl = StringUtils.chompLast( scmUrl, "/" );
+                    	moduleScmUrl = scmUrl + "/" + modulePath;
                     }
                     // we are in recursive loading mode
                     readModules( moduleUrl, result, false, username, password, moduleScmUrl, true,
-                                 buildDefinitionTemplate );
+                    		buildDefinitionTemplate, checkoutInSingleDirectory );
                 }
             }
         }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java Thu May 20 07:30:43 2010
@@ -95,6 +95,10 @@ public class CheckOutTaskExecutor
         CheckoutProjectContinuumAction.setScmUsername( context, task.getScmUserName() );
 
         CheckoutProjectContinuumAction.setScmPassword( context, task.getScmPassword() );
+        
+        AbstractContinuumAction.setProjectScmRootUrl( context, task.getScmRootUrl() );
+        
+        AbstractContinuumAction.setListOfProjectsInGroupWithCommonScmRoot( context, task.getProjectsWithCommonScmRoot() );
 
         try
         {

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java Thu May 20 07:30:43 2010
@@ -24,10 +24,12 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.io.File;
 
 import org.apache.continuum.dao.BuildDefinitionDao;
 import org.apache.continuum.dao.BuildResultDao;
 import org.apache.continuum.dao.ProjectDao;
+import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.continuum.dao.ProjectScmRootDao;
 import org.apache.continuum.model.project.ProjectScmRoot;
 import org.apache.continuum.taskqueue.PrepareBuildProjectsTask;
@@ -103,6 +105,11 @@ public class PrepareBuildProjectsTaskExe
      */
     private ContinuumNotificationDispatcher notifierDispatcher;
 
+    /**
+     * @plexus.requirement
+     */
+    private ProjectGroupDao projectGroupDao;
+
     public void executeTask( Task task )
         throws TaskExecutionException
     {
@@ -113,58 +120,89 @@ public class PrepareBuildProjectsTaskExe
         Set<Integer> projectsId = projectsBuildDefinitionsMap.keySet();
         Map<String, Object> context = new HashMap<String, Object>();
         Map<Integer, ScmResult> scmResultMap = new HashMap<Integer, ScmResult>();
+        List<Project> projectList = new ArrayList<Project>();
+        int projectGroupId = 0;
 
         try
         {
-            for ( Integer projectId : projectsId )
+        	if ( !projectsId.isEmpty() )
             {
-                int buildDefinitionId = projectsBuildDefinitionsMap.get( projectId );
+        	    int projectId = projectsId.iterator().next();
+                Project project = projectDao.getProject( projectId );
+                ProjectGroup projectGroup = project.getProjectGroup();
+                projectGroupId = projectGroup.getId();
 
-                log.info( "Initializing prepare build" );
-                context = initializeContext( projectId, buildDefinitionId, prepareTask.getBuildTrigger() );
+                List<Project> projects = projectDao.getProjectsWithDependenciesByGroupId( projectGroupId );
+                projectList = ProjectSorter.getSortedProjects( projects, log );
+            }
 
-                log.info(
-                    "Starting prepare build of project: " + AbstractContinuumAction.getProject( context ).getName() );
-                startPrepareBuild( context );
+            Project rootProject = null;
 
-                if ( !checkProjectScmRoot( context ) )
+            for ( Project project : projectList )
+            {
+	            if ( rootProject == null )
                 {
-                    break;
+                    // first project is the root project.
+                    rootProject = project;
                 }
 
-                try
+                int projectId = project.getId();
+                int buildDefinitionId;
+
+                if ( projectsBuildDefinitionsMap.get( projectId ) != null )
                 {
-                    if ( AbstractContinuumAction.getBuildDefinition( context ).isBuildFresh() )
+                    buildDefinitionId = projectsBuildDefinitionsMap.get( projectId );
+
+                    log.info( "Initializing prepare build" );
+                    context = initializeContext( project, buildDefinitionId, prepareTask.getBuildTrigger() );
+    
+                    log.info(
+                        "Starting prepare build of project: " + AbstractContinuumAction.getProject( context ).getName() );
+                    startPrepareBuild( context );
+    
+                    if ( !checkProjectScmRoot( context ) )
                     {
-                        log.info( "Purging existing working copy" );
-                        cleanWorkingDirectory( context );
+                    	break;
                     }
 
-                    // ----------------------------------------------------------------------
-                    // TODO: Centralize the error handling from the SCM related actions.
-                    // ContinuumScmResult should return a ContinuumScmResult from all
-                    // methods, even in a case of failure.
-                    // ----------------------------------------------------------------------
-                    log.info( "Updating working dir" );
-                    updateWorkingDirectory( context );
-
-                    log.info( "Merging SCM results" );
-                    //CONTINUUM-1393
-                    if ( !AbstractContinuumAction.getBuildDefinition( context ).isBuildFresh() )
+                    try
+                    {
+                        if ( AbstractContinuumAction.getBuildDefinition( context ).isBuildFresh() )
+                        {
+                            log.info( "Purging existing working copy" );
+                            cleanWorkingDirectory( context );
+                        }
+    
+                        // ----------------------------------------------------------------------
+                        // TODO: Centralize the error handling from the SCM related actions.
+                        // ContinuumScmResult should return a ContinuumScmResult from all
+                        // methods, even in a case of failure.
+                        // ----------------------------------------------------------------------
+                        log.info( "Updating working dir" );
+                        updateWorkingDirectory( context, rootProject );
+    
+                        log.info( "Merging SCM results" );
+                        //CONTINUUM-1393
+                        if ( !AbstractContinuumAction.getBuildDefinition( context ).isBuildFresh() )
+                        {
+                            mergeScmResults( context );
+                        }
+                    }
+                    finally
                     {
-                        mergeScmResults( context );
+                        log.info(
+                            "Ending prepare build of project: " + AbstractContinuumAction.getProject( context ).getName() );
+                        scmResultMap.put( AbstractContinuumAction.getProjectId( context ),
+                                          AbstractContinuumAction.getScmResult( context, null ) );
+                        endProjectPrepareBuild( context );
                     }
                 }
-                finally
-                {
-                    log.info(
-                        "Ending prepare build of project: " + AbstractContinuumAction.getProject( context ).getName() );
-                    scmResultMap.put( AbstractContinuumAction.getProjectId( context ),
-                                      AbstractContinuumAction.getScmResult( context, new ScmResult() ) );
-                    endProjectPrepareBuild( context );
-                }
             }
         }
+        catch ( ContinuumStoreException e )
+        {
+            throw new TaskExecutionException( "Failed to prepare build project group: " + projectGroupId, e );
+        }
         finally
         {
             log.info( "Ending prepare build" );
@@ -173,35 +211,38 @@ public class PrepareBuildProjectsTaskExe
 
         if ( checkProjectScmRoot( context ) )
         {
-            int projectGroupId = AbstractContinuumAction.getProjectGroupId( context );
-            buildProjects( projectGroupId, projectsBuildDefinitionsMap, buildTrigger, scmResultMap );
+            projectGroupId = AbstractContinuumAction.getProjectGroupId( context );
+            buildProjects( projectGroupId, projectList, projectsBuildDefinitionsMap, buildTrigger, scmResultMap );
         }
     }
 
-    private Map<String, Object> initializeContext( int projectId, int buildDefinitionId, BuildTrigger buildTrigger )
+    private Map<String, Object> initializeContext( Project project, int buildDefinitionId, BuildTrigger buildTrigger )
         throws TaskExecutionException
     {
         Map<String, Object> context = new HashMap<String, Object>();
 
         try
         {
-            Project project = projectDao.getProject( projectId );
             ProjectGroup projectGroup = project.getProjectGroup();
 
             List<ProjectScmRoot> scmRoots = projectScmRootDao.getProjectScmRootByProjectGroup( projectGroup.getId() );
             String projectScmUrl = project.getScmUrl();
+            String projectScmRootAddress = "";
 
             for ( ProjectScmRoot projectScmRoot : scmRoots )
             {
+            	projectScmRootAddress = projectScmRoot.getScmRootAddress();
+            	
                 if ( projectScmUrl.startsWith( projectScmRoot.getScmRootAddress() ) )
                 {
                     AbstractContinuumAction.setProjectScmRoot( context, projectScmRoot );
+                    AbstractContinuumAction.setProjectScmRootUrl( context, projectScmRootAddress );
                     break;
                 }
             }
 
             AbstractContinuumAction.setProjectGroupId( context, projectGroup.getId() );
-            AbstractContinuumAction.setProjectId( context, projectId );
+            AbstractContinuumAction.setProjectId( context, project.getId() );
             AbstractContinuumAction.setProject( context, project );
             AbstractContinuumAction.setBuildTrigger( context, buildTrigger );
 
@@ -209,13 +250,28 @@ public class PrepareBuildProjectsTaskExe
             AbstractContinuumAction.setBuildDefinition( context,
                                                         buildDefinitionDao.getBuildDefinition( buildDefinitionId ) );
 
+             if( project.isCheckedOutInSingleDirectory() )
+             {
+                 List<Project> projectsInGroup =
+                     projectGroupDao.getProjectGroupWithProjects( projectGroup.getId() ).getProjects(); 
+                 List<Project> projectsWithCommonScmRoot = new ArrayList<Project>();            
+                 for( Project projectInGroup : projectsInGroup )
+                 {
+                     if( projectInGroup.getScmUrl().startsWith( projectScmRootAddress ) )
+                     {
+                         projectsWithCommonScmRoot.add( projectInGroup );
+                     }
+                 }            
+                 AbstractContinuumAction.setListOfProjectsInGroupWithCommonScmRoot( context, projectsWithCommonScmRoot );
+             }
+            
             BuildResult oldBuildResult =
-                buildResultDao.getLatestBuildResultForBuildDefinition( projectId, buildDefinitionId );
+            	buildResultDao.getLatestBuildResultForBuildDefinition( project.getId(), buildDefinitionId );
 
             if ( oldBuildResult != null )
             {
                 AbstractContinuumAction.setOldScmResult( context,
-                                                         getOldScmResults( projectId, oldBuildResult.getBuildNumber(),
+                										getOldScmResults( project.getId(), oldBuildResult.getBuildNumber(),
                                                                            oldBuildResult.getEndTime() ) );
             }
             else
@@ -237,12 +293,12 @@ public class PrepareBuildProjectsTaskExe
         performAction( "clean-working-directory", context );
     }
 
-    private void updateWorkingDirectory( Map<String, Object> context )
+    private void updateWorkingDirectory( Map<String, Object> context, Project rootProject )
         throws TaskExecutionException
-    {
+    {   
         performAction( "check-working-directory", context );
 
-        boolean workingDirectoryExists = CheckWorkingDirectoryAction.isWorkingDirectoryExist( context );
+        boolean workingDirectoryExists = CheckWorkingDirectoryAction.isWorkingDirectoryExists( context );
 
         ScmResult scmResult;
 
@@ -250,7 +306,7 @@ public class PrepareBuildProjectsTaskExe
         {
             performAction( "update-working-directory-from-scm", context );
 
-            scmResult = UpdateWorkingDirectoryFromScmContinuumAction.getUpdateScmResult( context );
+            scmResult = UpdateWorkingDirectoryFromScmContinuumAction.getUpdateScmResult( context, null );
         }
         else
         {
@@ -258,10 +314,47 @@ public class PrepareBuildProjectsTaskExe
 
             AbstractContinuumAction.setWorkingDirectory( context, workingDirectoryService.getWorkingDirectory(
                 project ).getAbsolutePath() );
+            
+            List<Project> projectsWithCommonScmRoot = AbstractContinuumAction.getListOfProjectsInGroupWithCommonScmRoot( context );           
+            String projectScmRootUrl = AbstractContinuumAction.getProjectScmRootUrl( context, project.getScmUrl() );
+            String workingDir = null;
+
+            if ( rootProject.getId() == project.getId() )
+            {
+                workingDir = workingDirectoryService.getWorkingDirectory( project, false ).getAbsolutePath();
+
+                if ( project.isCheckedOutInSingleDirectory() )
+                {
+                    File parentDir = new File( workingDir );
+
+                    while ( !isRootDirectory( parentDir.getAbsolutePath(), project ) )
+                    {
+                        parentDir = parentDir.getParentFile();
+                    }
+
+                    if ( !parentDir.exists() )
+                    {
+                        workingDir = parentDir.getAbsolutePath();
+                    }
+                }
+            }
+
+            if ( workingDir == null || new File( workingDir ).exists() )
+            {
+                workingDir = workingDirectoryService.getWorkingDirectory( 
+                    project, projectScmRootUrl, projectsWithCommonScmRoot ).getAbsolutePath();
+            }
+
+            AbstractContinuumAction.setWorkingDirectory( context, workingDir );
+
+            if ( rootProject.getId() != project.getId() || ( rootProject.getId() == project.getId() && !isRootDirectory( workingDir, rootProject ) ) )
+            {
+                AbstractContinuumAction.setRootDirectory( context, false );
+            }
 
             performAction( "checkout-project", context );
 
-            scmResult = CheckoutProjectContinuumAction.getCheckoutResult( context, null );
+            scmResult = CheckoutProjectContinuumAction.getCheckoutScmResult( context, null );
         }
 
         // [CONTINUUM-2207] when returned scmResult is null, this causes a problem when building the project 
@@ -509,15 +602,10 @@ public class PrepareBuildProjectsTaskExe
         }
     }
 
-    private void buildProjects( int projectGroupId, Map<Integer, Integer> projectsAndBuildDefinitionsMap,
-    		                    BuildTrigger buildTrigger, Map<Integer, ScmResult> scmResultMap )
+    private void buildProjects( int projectGroupId, List<Project> projectList, Map<Integer, Integer> projectsAndBuildDefinitionsMap, BuildTrigger buildTrigger,
+    		Map<Integer, ScmResult> scmResultMap )
         throws TaskExecutionException
-    {
-        List<Project> projects = projectDao.getProjectsWithDependenciesByGroupId( projectGroupId );
-        List<Project> projectList;
-
-        projectList = ProjectSorter.getSortedProjects( projects, log );
-
+    {   
         List<Project> projectsToBeBuilt = new ArrayList<Project>();
         Map<Integer, BuildDefinition> projectsBuildDefinitionsMap = new HashMap<Integer, BuildDefinition>();
 
@@ -566,4 +654,10 @@ public class PrepareBuildProjectsTaskExe
             throw new TaskExecutionException( "Error executing action 'build-project'", e );
         }
     }
+    
+    private boolean isRootDirectory( String workingDir, Project rootProject )
+    {
+        return workingDir.endsWith( Integer.toString( rootProject.getId() ) + System.getProperty( "line.separator" ) )
+            || workingDir.endsWith( Integer.toString( rootProject.getId() ) );
+    }
 }

Modified: continuum/trunk/continuum-core/src/test-projects/multi-module/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test-projects/multi-module/pom.xml?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test-projects/multi-module/pom.xml (original)
+++ continuum/trunk/continuum-core/src/test-projects/multi-module/pom.xml Thu May 20 07:30:43 2010
@@ -41,5 +41,6 @@
   <modules>
     <module>module-A</module>
     <module>module-B</module>
+    <module>module-C/module-D</module>
   </modules>
 </project>

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java (original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java Thu May 20 07:30:43 2010
@@ -435,8 +435,8 @@ public class ParallelBuildsManagerTest
         recordCheckoutProjectBuildQueuesAreEmpty();
 
         buildsManager.checkoutProject( 1, "continuum-project-test-1",
-                                       new File( getBasedir(), "/target/test-working-dir/1" ), "dummy", "dummypass",
-                                       buildDef );
+        			new File( getBasedir(), "/target/test-working-dir/1" ), null, "dummy", "dummypass",
+        			buildDef, null );
         context.assertIsSatisfied();
     }
 
@@ -452,8 +452,8 @@ public class ParallelBuildsManagerTest
         recordCheckoutProjectBuildQueuesAreEmpty();
 
         buildsManager.checkoutProject( 1, "continuum-project-test-1",
-                                       new File( getBasedir(), "/target/test-working-dir/1" ), "dummy", "dummypass",
-                                       buildDef );
+	        		new File( getBasedir(), "/target/test-working-dir/1" ), null, "dummy", "dummypass",
+	    			buildDef, null );
         context.assertIsSatisfied();
 
         // queue second project - 1st queue has 1 task while 2nd queue is empty; project should be queued in
@@ -465,7 +465,7 @@ public class ParallelBuildsManagerTest
         final List<Task> tasksInFirstCheckoutQueue = new ArrayList<Task>();
         tasksInFirstCheckoutQueue.add(
             new CheckOutTask( 1, new File( getBasedir(), "/target/test-working-dir/1" ), "continuum-project-test-1",
-                              "dummy", "dummypass" ) );
+            			"dummy", "dummypass", null, null ) );
 
         context.checking( new Expectations()
         {
@@ -486,8 +486,8 @@ public class ParallelBuildsManagerTest
         recordAddToCheckoutQueue();
 
         buildsManager.checkoutProject( 2, "continuum-project-test-2",
-                                       new File( getBasedir(), "/target/test-working-dir/1" ), "dummy", "dummypass",
-                                       buildDef );
+	        		new File( getBasedir(), "/target/test-working-dir/1" ), null, "dummy", "dummypass",
+	    			buildDef, null );
         context.assertIsSatisfied();
 
         // queue third project - both queues have 1 task queued each; third project should be queued in 1st queue
@@ -509,8 +509,8 @@ public class ParallelBuildsManagerTest
         recordAddToCheckoutQueue();
 
         buildsManager.checkoutProject( 3, "continuum-project-test-3",
-                                       new File( getBasedir(), "/target/test-working-dir/1" ), "dummy", "dummypass",
-                                       buildDef );
+	        		new File( getBasedir(), "/target/test-working-dir/1" ), null, "dummy", "dummypass",
+	    			buildDef, null );
         context.assertIsSatisfied();
     }
 
@@ -613,7 +613,7 @@ public class ParallelBuildsManagerTest
         final List<CheckOutTask> checkoutTasks = new ArrayList<CheckOutTask>();
         checkoutTasks.add(
             new CheckOutTask( 2, new File( getBasedir(), "/target/test-working-dir/1" ), "continuum-project-test-2",
-                              "dummy", "dummypass" ) );
+            			"dummy", "dummypass", null, null ) );
 
         final ParallelBuildsThreadedTaskQueueExecutor buildTaskQueueExecutor =
             context.mock( ParallelBuildsThreadedTaskQueueExecutor.class, "parallel-build-task-executor" );
@@ -756,7 +756,7 @@ public class ParallelBuildsManagerTest
         final List<CheckOutTask> checkoutTasks = new ArrayList<CheckOutTask>();
         checkoutTasks.add(
             new CheckOutTask( 2, new File( getBasedir(), "/target/test-working-dir/1" ), "continuum-project-test-2",
-                              "dummy", "dummypass" ) );
+            			"dummy", "dummypass", null, null ) );
 
         try
         {
@@ -863,7 +863,7 @@ public class ParallelBuildsManagerTest
         final List<Task> tasks = new ArrayList<Task>();
         tasks.add(
             new CheckOutTask( 2, new File( getBasedir(), "/target/test-working-dir/1" ), "continuum-project-test-2",
-                              "dummy", "dummypass" ) );
+            			"dummy", "dummypass", null, null ) );
 
         context.checking( new Expectations()
         {

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueueTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueueTest.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueueTest.java (original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueueTest.java Thu May 20 07:30:43 2010
@@ -85,7 +85,7 @@ public class DefaultOverallBuildQueueTes
     {
         final CheckOutTask checkoutTask =
             new CheckOutTask( 1, new File( getBasedir(), "/target/test-working-dir/1" ), "continuum-project-test-1",
-                              "dummy", "dummypass" );
+            			"dummy", "dummypass", null, null );
         final TaskQueue checkoutQueue = context.mock( TaskQueue.class, "checkout-queue" );
 
         context.checking( new Expectations()
@@ -108,7 +108,7 @@ public class DefaultOverallBuildQueueTes
         final List<Task> tasks = new ArrayList<Task>();
         tasks.add(
             new CheckOutTask( 1, new File( getBasedir(), "/target/test-working-dir/1" ), "continuum-project-test-1",
-                              "dummy", "dummypass" ) );
+            			"dummy", "dummypass", null, null ) );
 
         context.checking( new Expectations()
         {
@@ -134,7 +134,7 @@ public class DefaultOverallBuildQueueTes
         final List<Task> tasks = new ArrayList<Task>();
         tasks.add(
             new CheckOutTask( 1, new File( getBasedir(), "/target/test-working-dir/1" ), "continuum-project-test-1",
-                              "dummy", "dummypass" ) );
+            			"dummy", "dummypass", null, null ) );
 
         context.checking( new Expectations()
         {
@@ -155,7 +155,7 @@ public class DefaultOverallBuildQueueTes
     {
         final Task checkoutTask =
             new CheckOutTask( 1, new File( getBasedir(), "/target/test-working-dir/1" ), "continuum-project-test-1",
-                              "dummy", "dummypass" );
+            			"dummy", "dummypass", null, null );
         final TaskQueue checkoutQueue = context.mock( TaskQueue.class, "checkout-queue" );
         final List<Task> tasks = new ArrayList<Task>();
         tasks.add( checkoutTask );

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java (original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java Thu May 20 07:30:43 2010
@@ -91,7 +91,7 @@ public class AddMaven2ProjectTest
         ContinuumProjectBuildingResult result = getContinuum().addMavenTwoProject(
                                                                                    rootPom.toURI().toURL()
                                                                                        .toExternalForm(), pg.getId(),
-                                                                                   true, false, false, bdt.getId() );
+                                                                                       true, false, false, bdt.getId(), false );
         assertNotNull( result );
 
         assertEquals( 1, result.getProjects().size() );
@@ -118,7 +118,7 @@ public class AddMaven2ProjectTest
         ContinuumProjectBuildingResult result = getContinuum().addMavenTwoProject(
                                                                                    rootPom.toURI().toURL()
                                                                                        .toExternalForm(), -1, true,
-                                                                                   false, true, bdt.getId() );
+                                                                                       false, true, bdt.getId(), false );
         assertNotNull( result );
 
         assertEquals( 1, result.getProjects().size() );
@@ -154,7 +154,7 @@ public class AddMaven2ProjectTest
         ContinuumProjectBuildingResult result = getContinuum().addMavenTwoProject(
                                                                                    rootPom.toURI().toURL()
                                                                                        .toExternalForm(), -1, true,
-                                                                                   false, true, -1 );
+                                                                                       false, true, -1, false );
         assertNotNull( result );
 
         assertEquals( 1, result.getProjects().size() );
@@ -202,7 +202,7 @@ public class AddMaven2ProjectTest
         ContinuumProjectBuildingResult result = getContinuum().addMavenTwoProject(
                                                                                    rootPom.toURI().toURL()
                                                                                        .toExternalForm(), pg.getId(),
-                                                                                   true, false, false, -1 );
+                                                                                       true, false, false, -1, false );
         assertNotNull( result );
 
         assertEquals( 1, result.getProjects().size() );

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java (original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java Thu May 20 07:30:43 2010
@@ -44,7 +44,7 @@ public class AddProjectTest
         
         ContinuumProjectBuildingResult result = continuum
             .executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID,
-                                                     getDefaultProjectGroup().getId(), false, true, false, -1, false );
+            						getDefaultProjectGroup().getId(), false, true, false, -1, false, false );
         assertEquals( 1, result.getProjects().size() );
         
         // read the project from store
@@ -62,7 +62,7 @@ public class AddProjectTest
 
         ContinuumProjectBuildingResult result = continuum
             .executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID,
-                                                     getDefaultProjectGroup().getId(), false, false, false, -1, false );
+            						getDefaultProjectGroup().getId(), false, false, false, -1, false, false );
         assertEquals( 1, result.getProjects().size() );
 
         // read the project from store

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java?rev=946548&r1=946547&r2=946548&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java (original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java Thu May 20 07:30:43 2010
@@ -29,6 +29,7 @@ import java.util.Map;
 import org.apache.continuum.buildmanager.BuildsManager;
 import org.apache.continuum.dao.BuildResultDao;
 import org.apache.continuum.dao.ProjectDao;
+import org.apache.continuum.model.project.ProjectScmRoot;
 import org.apache.continuum.model.release.ContinuumReleaseResult;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.repository.RepositoryService;
@@ -100,7 +101,7 @@ public class DefaultContinuumTest
         assertTrue( rootPom.exists() );
 
         ContinuumProjectBuildingResult result =
-            continuum.addMavenTwoProject( rootPom.toURI().toURL().toExternalForm(), -1, true, false, true, -1 );
+        	continuum.addMavenTwoProject( rootPom.toURI().toURL().toExternalForm(), -1, true, false, true, -1, false );
 
         assertNotNull( result );
 
@@ -134,9 +135,95 @@ public class DefaultContinuumTest
 
         assertTrue( "no jabber notifier", projects.containsKey( "Continuum Jabber Notifier" ) );
 
-
     }
+    
+    // handle flat multi-module projects
+    public void testAddMavenTwoProjectSetInSingleDirectory()
+        throws Exception
+    {   
+        Continuum continuum = (Continuum) lookup( Continuum.ROLE );
+        
+        String url = getTestFile( "src/test-projects/flat-multi-module/parent-project/pom.xml" ).toURL().toExternalForm();
+
+        ContinuumProjectBuildingResult result = continuum.addMavenTwoProject( url, -1, true, false, true, -1, true );
+ 
+        assertNotNull( result );
+
+        List<Project> projects = result.getProjects();
+
+        assertEquals( 4, projects.size() );     
+        
+        Project rootProject = result.getRootProject();
+        
+        assertNotNull( rootProject );
+        
+        Map<String, Project> projectsMap = new HashMap<String, Project>();
+
+        int projectGroupId = 0;
+
+        for ( Project project : getProjectDao().getAllProjectsByName() )
+        {
+            projectsMap.put( project.getName(), project );
+
+            ProjectGroup projectGroup = getProjectGroupDao().getProjectGroupByProjectId( project.getId() );
+            projectGroupId = projectGroup.getId();
+
+            // validate project in project group
+            assertTrue( "project not in project group", projectGroup != null );
+        }
+
+        // sometimes projects don't get added to checkout queue
+        continuum.buildProjectGroup( projectGroupId, new org.apache.continuum.utils.build.BuildTrigger( 1, "user" ) );
 
+        assertTrue( "no module-a", projectsMap.containsKey( "module-a" ) );
+        
+        assertTrue( "no module-b", projectsMap.containsKey( "module-b" ) );
+
+        assertTrue( "no module-d", projectsMap.containsKey( "module-d" ) );
+
+        // check if the modules were checked out in the same directory as the parent
+        ConfigurationService configurationService = ( ConfigurationService ) lookup( "configurationService" );
+        
+        File workingDir = configurationService.getWorkingDirectory();
+        
+        Project parentProject = getProjectDao().getProjectByName( "parent-project" );
+        
+        File checkoutDir = new File( workingDir, String.valueOf( parentProject.getId() ) );
+
+        for( long delay = 0; delay <= 999999999; delay++ )
+        {
+            // wait while the project has been checked out/build
+        }
+        
+        assertTrue( "checkout directory of project 'parent-project' does not exist." , new File( checkoutDir, "parent-project" ).exists() );
+        
+        assertFalse( "module-a should not have been checked out as a separate project.",
+                    new File( workingDir, String.valueOf( getProjectDao().getProjectByName( "module-a" ).getId() ) ).exists() );
+        
+        assertFalse( "module-b should not have been checked out as a separate project.",
+                    new File( workingDir, String.valueOf( getProjectDao().getProjectByName( "module-b" ).getId() ) ).exists() );
+
+        assertFalse( "module-d should not have been checked out as a separate project.",
+                     new File( workingDir, String.valueOf( getProjectDao().getProjectByName( "module-d" ).getId() ) ).exists() );
+
+        assertTrue( "module-a was not checked out in the same directory as it's parent.", new File( checkoutDir, "module-a" ).exists() );
+        
+        assertTrue( "module-b was not checked out in the same directory as it's parent.", new File( checkoutDir, "module-b" ).exists() );
+
+        assertTrue( "module-d was not checked out in the same directory as it's parent.", new File( checkoutDir, "module-c/module-d" ).exists() );
+
+        // assert project state
+        // commented out this test case as it sometimes fails because the actual checkout hasn't finished yet so
+        //    the state hasn't been updated yet
+        /*assertEquals( "state of 'parent-project' should have been updated.", ContinuumProjectState.CHECKEDOUT, parentProject.getState() );
+        
+        assertEquals( "state of 'module-a' should have been updated.", ContinuumProjectState.CHECKEDOUT,
+                      getProjectDao().getProjectByName( "module-a" ).getState() );
+        
+        assertEquals( "state of 'module-b' should have been updated.", ContinuumProjectState.CHECKEDOUT,
+                      getProjectDao().getProjectByName( "module-b" ).getState() );*/        
+    }
+        
     public void testUpdateMavenTwoProject()
         throws Exception
     {
@@ -432,6 +519,51 @@ public class DefaultContinuumTest
         assertFalse( "project still exist on the checkout queue",
                      parallelBuildsManager.isInAnyCheckoutQueue( project.getId() ) );
     }
+    
+    /*public void testCreationOfProjectScmRootDuringInitialization()
+        throws Exception
+    {
+        DefaultContinuum continuum = (DefaultContinuum) getContinuum();
+
+        ProjectGroup defaultProjectGroup =
+            continuum.getProjectGroupByGroupId( ContinuumInitializer.DEFAULT_PROJECT_GROUP_GROUP_ID );
+
+        ProjectScmRoot scmRoot = new ProjectScmRoot();
+        scmRoot.setProjectGroup( defaultProjectGroup );
+        scmRoot.setScmRootAddress( "http://temp.company.com/svn/trunk" );
+        getProjectScmRootDao().addProjectScmRoot( scmRoot );
+        
+        defaultProjectGroup = continuum.getProjectGroupWithProjects( defaultProjectGroup.getId() );
+        assertEquals( 0, defaultProjectGroup.getProjects().size() );
+        
+        Project project = new Project();
+        project.setGroupId( "project1" );
+        project.setArtifactId( "project1" );
+        project.setVersion( "1.0-SNAPSHOT" );
+        project.setScmUrl( "http://temp.company.com/svn/trunk/project1" );
+        defaultProjectGroup.addProject( project );
+
+        project = new Project();
+        project.setGroupId( "project2" );
+        project.setArtifactId( "project2" );
+        project.setVersion( "1.0-SNAPSHOT" );
+        project.setScmUrl( "http://temp.company.com/svn/trunk/project2" );
+        defaultProjectGroup.addProject( project );
+
+        project = new Project();
+        project.setGroupId( "project3" );
+        project.setArtifactId( "project3" );
+        project.setVersion( "1.0-SNAPSHOT" );
+        project.setScmUrl( "http://temp.company.com/svn/trunk/project3" );
+        defaultProjectGroup.addProject( project );
+
+        getProjectGroupDao().updateProjectGroup( defaultProjectGroup );
+
+        continuum.initialize();
+
+        List<ProjectScmRoot> scmRoots = continuum.getProjectScmRootByProjectGroup( defaultProjectGroup.getId() );
+        assertEquals( "#scmRoots in the group", 1, scmRoots.size() );
+    }    */
 
     public void testAddAntProjectWithdefaultBuildDef()
         throws Exception



Mime
View raw message