continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r941625 [9/24] - in /continuum/branches/continuum-flat-multi-module: ./ continuum-api/ continuum-api/src/main/java/org/apache/continuum/builder/distributed/ continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/ conti...
Date Thu, 06 May 2010 09:23:34 GMT
Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java Thu May  6 09:23:13 2010
@@ -82,7 +82,7 @@ public class DefaultSchedulesActivator
      */
     private Scheduler scheduler;
 
-    //private int delay = 3600;
+    // private int delay = 3600;
     private static final int delay = 1;
 
     public void activateSchedules( Continuum continuum )
@@ -94,42 +94,27 @@ public class DefaultSchedulesActivator
 
         for ( Schedule schedule : schedules )
         {
-            if ( StringUtils.isEmpty( schedule.getCronExpression() ) )
-            {
-                // TODO: this can possibly be removed but it's here now to
-                // weed out any bugs
-                log.info( "Not scheduling " + schedule.getName() );
-
-                continue;
-            }
-
-            try
+            if ( schedule.isActive() )
             {
-                // check schedule job class
-                if ( isScheduleFromBuildJob( schedule ) )
+                try
                 {
-                    schedule( schedule, continuum, ContinuumBuildJob.class );
+                    activateSchedule( schedule, continuum );
                 }
-
-                if ( isScheduleFromPurgeJob( schedule ) )
+                catch ( SchedulesActivationException e )
                 {
-                    schedule( schedule, continuum, ContinuumPurgeJob.class );
-                }
-            }
-            catch ( SchedulesActivationException e )
-            {
-                log.error( "Can't activate schedule '" + schedule.getName() + "'", e );
+                    log.error( "Can't activate schedule '" + schedule.getName() + "'", e );
 
-                schedule.setActive( false );
+                    schedule.setActive( false );
 
-                try
-                {
-                    scheduleDao.storeSchedule( schedule );
-                }
-                catch ( ContinuumStoreException e1 )
-                {
-                    throw new SchedulesActivationException( "Can't desactivate schedule '" + schedule.getName() + "'",
-                                                            e );
+                    try
+                    {
+                        scheduleDao.storeSchedule( schedule );
+                    }
+                    catch ( ContinuumStoreException e1 )
+                    {
+                        throw new SchedulesActivationException( "Can't desactivate schedule '" + schedule.getName()
+                            + "'", e );
+                    }
                 }
             }
         }
@@ -138,16 +123,31 @@ public class DefaultSchedulesActivator
     public void activateSchedule( Schedule schedule, Continuum continuum )
         throws SchedulesActivationException
     {
-        log.info( "Activating schedule " + schedule.getName() );
+        if ( schedule != null )
+        {
+            log.info( "Activating schedule " + schedule.getName() );
 
-        if ( isScheduleFromBuildJob( schedule ) )
+            activateBuildSchedule( schedule, continuum );
+
+            activatePurgeSchedule( schedule, continuum );
+        }
+    }
+
+    public void activateBuildSchedule( Schedule schedule, Continuum continuum )
+        throws SchedulesActivationException
+    {
+        if ( schedule != null && schedule.isActive() && isScheduleFromBuildJob( schedule ) )
         {
-            schedule( schedule, continuum, ContinuumBuildJob.class );
+            schedule( schedule, continuum, ContinuumBuildJob.class, ContinuumBuildJob.BUILD_GROUP );
         }
+    }
 
-        if ( isScheduleFromPurgeJob( schedule ) )
+    public void activatePurgeSchedule( Schedule schedule, Continuum continuum )
+        throws SchedulesActivationException
+    {
+        if ( schedule != null && schedule.isActive() && isScheduleFromPurgeJob( schedule ) )
         {
-            schedule( schedule, continuum, ContinuumPurgeJob.class );
+            schedule( schedule, continuum, ContinuumPurgeJob.class, ContinuumPurgeJob.PURGE_GROUP );
         }
     }
 
@@ -156,16 +156,50 @@ public class DefaultSchedulesActivator
     {
         log.info( "Deactivating schedule " + schedule.getName() );
 
-        unschedule( schedule );
+        unactivateBuildSchedule( schedule );
+        unactivatePurgeSchedule( schedule );
+    }
+
+    public void unactivateOrphanBuildSchedule( Schedule schedule )
+        throws SchedulesActivationException
+    {
+        if ( schedule != null && !isScheduleFromBuildJob( schedule ) )
+        {
+            unactivateBuildSchedule( schedule );
+        }
     }
 
-    protected void schedule( Schedule schedule, Continuum continuum, Class jobClass )
+    public void unactivateOrphanPurgeSchedule( Schedule schedule )
         throws SchedulesActivationException
     {
-        if ( !schedule.isActive() )
+        if ( schedule != null && !isScheduleFromPurgeJob( schedule ) )
         {
-            log.info( "Schedule \"" + schedule.getName() + "\" is disabled." );
+            unactivatePurgeSchedule( schedule );
+        }
+    }
+
+    private void unactivateBuildSchedule( Schedule schedule )
+        throws SchedulesActivationException
+    {
+        log.debug( "Deactivating schedule " + schedule.getName() + " for Build Process" );
 
+        unschedule( schedule, ContinuumBuildJob.BUILD_GROUP );
+    }
+
+    private void unactivatePurgeSchedule( Schedule schedule )
+        throws SchedulesActivationException
+    {
+        log.debug( "Deactivating schedule " + schedule.getName() + " for Purge Process" );
+
+        unschedule( schedule, ContinuumPurgeJob.PURGE_GROUP );
+    }
+
+    protected void schedule( Schedule schedule, Continuum continuum, Class jobClass, String group )
+        throws SchedulesActivationException
+    {
+        if ( StringUtils.isEmpty( schedule.getCronExpression() ) )
+        {
+            log.info( "Not scheduling " + schedule.getName() );
             return;
         }
 
@@ -177,9 +211,9 @@ public class DefaultSchedulesActivator
 
         dataMap.put( ContinuumSchedulerConstants.SCHEDULE, schedule );
 
-        //the name + group makes the job unique
+        // the name + group makes the job unique
 
-        JobDetail jobDetail = new JobDetail( schedule.getName(), org.quartz.Scheduler.DEFAULT_GROUP, jobClass );
+        JobDetail jobDetail = new JobDetail( schedule.getName(), group, jobClass );
 
         jobDetail.setJobDataMap( dataMap );
 
@@ -189,7 +223,7 @@ public class DefaultSchedulesActivator
 
         trigger.setName( schedule.getName() );
 
-        trigger.setGroup( org.quartz.Scheduler.DEFAULT_GROUP );
+        trigger.setGroup( group );
 
         Date startTime = new Date( System.currentTimeMillis() + delay * 1000 );
 
@@ -218,7 +252,7 @@ public class DefaultSchedulesActivator
         }
     }
 
-    private void unschedule( Schedule schedule )
+    private void unschedule( Schedule schedule, String group )
         throws SchedulesActivationException
     {
         try
@@ -227,10 +261,10 @@ public class DefaultSchedulesActivator
             {
                 log.info( "Stopping active schedule \"" + schedule.getName() + "\"." );
 
-                scheduler.interruptSchedule( schedule.getName(), org.quartz.Scheduler.DEFAULT_GROUP );
+                scheduler.interruptSchedule( schedule.getName(), group );
             }
 
-            scheduler.unscheduleJob( schedule.getName(), org.quartz.Scheduler.DEFAULT_GROUP );
+            scheduler.unscheduleJob( schedule.getName(), group );
         }
         catch ( SchedulerException e )
         {
@@ -241,7 +275,9 @@ public class DefaultSchedulesActivator
     private boolean isScheduleFromBuildJob( Schedule schedule )
     {
         List<BuildDefinition> buildDef = buildDefinitionDao.getBuildDefinitionsBySchedule( schedule.getId() );
-
+        // Take account templateBuildDefinition too.
+        // A improvement will be add schedule only for active buildDefinition, but it would need activate
+        // schedule job in add project and add group process
         return buildDef.size() > 0;
 
     }
@@ -249,9 +285,9 @@ public class DefaultSchedulesActivator
     private boolean isScheduleFromPurgeJob( Schedule schedule )
     {
         List<RepositoryPurgeConfiguration> repoPurgeConfigs =
-            repositoryPurgeConfigurationDao.getRepositoryPurgeConfigurationsBySchedule( schedule.getId() );
+            repositoryPurgeConfigurationDao.getEnableRepositoryPurgeConfigurationsBySchedule( schedule.getId() );
         List<DirectoryPurgeConfiguration> dirPurgeConfigs =
-            directoryPurgeConfigurationDao.getDirectoryPurgeConfigurationsBySchedule( schedule.getId() );
+            directoryPurgeConfigurationDao.getEnableDirectoryPurgeConfigurationsBySchedule( schedule.getId() );
 
         return repoPurgeConfigs.size() > 0 || dirPurgeConfigs.size() > 0;
 

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildContext.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildContext.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildContext.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildContext.java Thu May  6 09:23:13 2010
@@ -19,6 +19,7 @@ package org.apache.maven.continuum.build
  * under the License.
  */
 
+import org.apache.continuum.utils.build.BuildTrigger;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
@@ -51,7 +52,7 @@ public class BuildContext
 
     private ScmResult scmResult;
 
-    private int trigger;
+    private BuildTrigger buildTrigger;
 
     private BuildResult buildResult;
 
@@ -138,14 +139,14 @@ public class BuildContext
         return actionContext;
     }
 
-    public int getTrigger()
+    public BuildTrigger getBuildTrigger()
     {
-        return trigger;
+    	return buildTrigger;
     }
 
-    public void setTrigger( int trigger )
+    public void setBuildTrigger( BuildTrigger buildTrigger )
     {
-        this.trigger = trigger;
+    	this.buildTrigger = buildTrigger;
     }
 
     public List<ProjectDependency> getModifiedDependencies()

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildController.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildController.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildController.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildController.java Thu May  6 09:23:13 2010
@@ -19,6 +19,7 @@ package org.apache.maven.continuum.build
  * under the License.
  */
 
+import org.apache.continuum.utils.build.BuildTrigger;
 import org.apache.maven.continuum.model.scm.ScmResult;
 import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
 
@@ -30,6 +31,6 @@ public interface BuildController
 {
     String ROLE = BuildController.class.getName();
 
-    void build( int projectId, int buildDefinitionId, int trigger, ScmResult scmResult )
+    void build( int projectId, int buildDefinitionId, BuildTrigger buildTrigger, ScmResult scmResult )
         throws TaskExecutionException;
 }

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutor.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutor.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutor.java Thu May  6 09:23:13 2010
@@ -46,6 +46,6 @@ public class BuildProjectTaskExecutor
         BuildProjectTask buildProjectTask = (BuildProjectTask) task;
 
         controller.build( buildProjectTask.getProjectId(), buildProjectTask.getBuildDefinitionId(), buildProjectTask
-            .getTrigger(), buildProjectTask.getScmResult() );
+        		.getBuildTrigger(), buildProjectTask.getScmResult() );
     }
 }

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java Thu May  6 09:23:13 2010
@@ -27,11 +27,12 @@ import java.util.Map;
 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.utils.ContinuumUtils;
+import org.apache.continuum.utils.build.BuildTrigger;
 import org.apache.maven.continuum.core.action.AbstractContinuumAction;
+import org.apache.maven.continuum.core.action.ExecuteBuilderContinuumAction;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
 import org.apache.maven.continuum.execution.manager.BuildExecutorManager;
@@ -39,7 +40,6 @@ import org.apache.maven.continuum.model.
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectDependency;
-import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.model.scm.ChangeFile;
 import org.apache.maven.continuum.model.scm.ChangeSet;
 import org.apache.maven.continuum.model.scm.ScmResult;
@@ -84,11 +84,6 @@ public class DefaultBuildController
     /**
      * @plexus.requirement
      */
-    private ProjectGroupDao projectGroupDao;
-
-    /**
-     * @plexus.requirement
-     */
     private ProjectScmRootDao projectScmRootDao;
 
     /**
@@ -118,14 +113,15 @@ public class DefaultBuildController
     /**
      * @param projectId
      * @param buildDefinitionId
-     * @param trigger
+     * @param buildTrigger
+     * @param scmResult
      * @throws TaskExecutionException
      */
-    public void build( int projectId, int buildDefinitionId, int trigger, ScmResult scmResult )
+    public void build( int projectId, int buildDefinitionId, BuildTrigger buildTrigger, ScmResult scmResult )
         throws TaskExecutionException
     {
         log.info( "Initializing build" );
-        BuildContext context = initializeBuildContext( projectId, buildDefinitionId, trigger, scmResult );
+        BuildContext context = initializeBuildContext( projectId, buildDefinitionId, buildTrigger, scmResult );
 
         // ignore this if AlwaysBuild ?
         if ( !checkScmResult( context ) )
@@ -164,9 +160,9 @@ public class DefaultBuildController
 
             performAction( "deploy-artifact", context );
 
-            context.setCancelled( (Boolean) actionContext.get( AbstractContinuumAction.KEY_CANCELLED ) );
+            context.setCancelled( ExecuteBuilderContinuumAction.isCancelled( actionContext ) );
 
-            String s = AbstractContinuumAction.getBuildId( actionContext );
+            String s = AbstractContinuumAction.getBuildId( actionContext, null );
 
             if ( s != null && !context.isCancelled() )
             {
@@ -214,19 +210,14 @@ public class DefaultBuildController
             {
                 try
                 {
-                    String s = AbstractContinuumAction.getBuildId( context.getActionContext() );
+                    String s = AbstractContinuumAction.getBuildId( context.getActionContext(), null );
 
                     if ( s != null )
                     {
                         BuildResult buildResult = buildResultDao.getBuildResult( Integer.valueOf( s ) );
                         project.setState( buildResult.getState() );
+                        projectDao.updateProject( project );
                     }
-                    else
-                    {
-                        project.setState( ContinuumProjectState.ERROR );
-                    }
-
-                    projectDao.updateProject( project );
                 }
                 catch ( ContinuumStoreException e )
                 {
@@ -325,11 +316,12 @@ public class DefaultBuildController
      *
      * @param projectId
      * @param buildDefinitionId
-     * @param trigger
+     * @param buildTrigger
+     * @param scmResult
      * @return
      * @throws TaskExecutionException
      */
-    protected BuildContext initializeBuildContext( int projectId, int buildDefinitionId, int trigger,
+    protected BuildContext initializeBuildContext( int projectId, int buildDefinitionId, BuildTrigger buildTrigger,
                                                    ScmResult scmResult )
         throws TaskExecutionException
     {
@@ -337,10 +329,8 @@ public class DefaultBuildController
 
         context.setStartTime( System.currentTimeMillis() );
 
-        context.setTrigger( trigger );
+        context.setBuildTrigger( buildTrigger );
 
-        Map<String, Object> actionContext = context.getActionContext();
-        
         try
         {
             Project project = projectDao.getProject( projectId );
@@ -357,37 +347,6 @@ public class DefaultBuildController
             context.setOldBuildResult( oldBuildResult );
 
             context.setScmResult( scmResult );
-            
-            // CONTINUUM-2193
-            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.contains( projectScmRoot.getScmRootAddress() ) )
-                {                    
-                    actionContext.put( AbstractContinuumAction.KEY_PROJECT_SCM_ROOT_URL, projectScmRoot.getScmRootAddress() );                    
-                    break;
-                }
-            }
-            
-            if( project.isCheckedOutInSingleDirectory() )
-            {
-                List<Project> projectsInGroup =
-                    projectGroupDao.getProjectGroupWithProjects( projectGroup.getId() ).getProjects(); 
-                List<Project> projectsWithCommonScmRoot = new ArrayList<Project>();            
-                for( Project projectInGroup : projectsInGroup )
-                {
-                    if( projectInGroup.getScmUrl().contains( projectScmRootAddress ) )
-                    {
-                        projectsWithCommonScmRoot.add( projectInGroup );
-                    }
-                }            
-                actionContext.put( AbstractContinuumAction.KEY_PROJECTS_IN_GROUP_WITH_COMMON_SCM_ROOT, projectsWithCommonScmRoot );
-            }
 
             // CONTINUUM-1871 olamy if continuum is killed during building oldBuildResult will have a endTime 0
             // this means all changes since the project has been loaded in continuum will be in memory
@@ -403,23 +362,23 @@ public class DefaultBuildController
             throw new TaskExecutionException( "Error initializing the build context", e );
         }
 
-        actionContext.put( AbstractContinuumAction.KEY_PROJECT_ID, projectId );
+        Map<String, Object> actionContext = context.getActionContext();
+
+        AbstractContinuumAction.setProjectId( actionContext, projectId );
 
-        actionContext.put( AbstractContinuumAction.KEY_PROJECT, context.getProject() );
+        AbstractContinuumAction.setProject( actionContext, context.getProject() );
 
-        actionContext.put( AbstractContinuumAction.KEY_BUILD_DEFINITION_ID, buildDefinitionId );
+        AbstractContinuumAction.setBuildDefinitionId( actionContext, buildDefinitionId );
 
-        actionContext.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, context.getBuildDefinition() );
+        AbstractContinuumAction.setBuildDefinition( actionContext, context.getBuildDefinition() );
 
-        actionContext.put( AbstractContinuumAction.KEY_TRIGGER, trigger );
+        AbstractContinuumAction.setBuildTrigger( actionContext, buildTrigger );
 
-        actionContext.put( AbstractContinuumAction.KEY_FIRST_RUN, context.getOldBuildResult() == null );
+        AbstractContinuumAction.setScmResult( actionContext, context.getScmResult() );
 
-        actionContext.put( AbstractContinuumAction.KEY_SCM_RESULT, context.getScmResult() );
-        
         if ( context.getOldBuildResult() != null )
         {
-            actionContext.put( AbstractContinuumAction.KEY_OLD_BUILD_ID, context.getOldBuildResult().getId() );
+            AbstractContinuumAction.setOldBuildId( actionContext, context.getOldBuildResult().getId() );
         }
 
         return context;
@@ -495,7 +454,7 @@ public class DefaultBuildController
         }
         if ( context.getOldBuildResult() == null )
         {
-            log.info( "The project was never be built with the current build definition, building" );
+            log.info( "The project has never been built with the current build definition, building" );
             return true;
         }
 
@@ -509,7 +468,7 @@ public class DefaultBuildController
             return true;
         }
 
-        if ( context.getTrigger() == ContinuumProjectState.TRIGGER_FORCED )
+        if ( context.getBuildTrigger().getTrigger() == ContinuumProjectState.TRIGGER_FORCED )
         {
             log.info( "The project build is forced, building" );
             return true;
@@ -521,15 +480,18 @@ public class DefaultBuildController
 
         if ( project.getOldState() != ContinuumProjectState.NEW &&
             project.getOldState() != ContinuumProjectState.CHECKEDOUT &&
-            context.getTrigger() != ContinuumProjectState.TRIGGER_FORCED &&
+            context.getBuildTrigger().getTrigger() != ContinuumProjectState.TRIGGER_FORCED &&
             project.getState() != ContinuumProjectState.NEW && project.getState() != ContinuumProjectState.CHECKEDOUT )
         {
             // Check SCM changes
-            allChangesUnknown = checkAllChangesUnknown( context.getScmResult().getChanges() );
+            if ( context.getScmResult() != null )
+            {
+                allChangesUnknown = checkAllChangesUnknown( context.getScmResult().getChanges() );
+            }
 
             if ( allChangesUnknown )
             {
-                if ( !context.getScmResult().getChanges().isEmpty() )
+                if ( context.getScmResult() != null && !context.getScmResult().getChanges().isEmpty() )
                 {
                     log.info(
                         "The project was not built because all changes are unknown (maybe local modifications or ignored files not defined in your SCM tool." );
@@ -550,19 +512,24 @@ public class DefaultBuildController
         }
 
         // Check changes
-        if ( !shouldBuild && ( ( !allChangesUnknown && !context.getScmResult().getChanges().isEmpty() ) ||
+        if ( !shouldBuild && ( ( !allChangesUnknown && context.getScmResult() != null && !context.getScmResult().getChanges().isEmpty() ) ||
             project.getExecutorId().equals( ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR ) ) )
         {
             try
             {
                 ContinuumBuildExecutor executor = buildExecutorManager.getBuildExecutor( project.getExecutorId() );
-                
-                Map<String, Object> actionContext = context.getActionContext();                
-                List<Project> projectsWithCommonScmRoot = AbstractContinuumAction.getListOfProjectsInGroupWithCommonScmRoot( actionContext );
-                String projectScmRootUrl = AbstractContinuumAction.getString( actionContext, AbstractContinuumAction.KEY_PROJECT_SCM_ROOT_URL, project.getScmUrl() );
 
-                shouldBuild = executor.shouldBuild( context.getScmResult().getChanges(), project, 
-                       workingDirectoryService.getWorkingDirectory( project, projectScmRootUrl, projectsWithCommonScmRoot ), context.getBuildDefinition() );                
+                if ( executor == null )
+                {
+                    log.warn( "No continuum build executor found for project " + project.getId() + 
+                              " with executor '" + project.getExecutorId() + "'" );
+                }
+                else if ( context.getScmResult() != null )
+                {
+                    shouldBuild = executor.shouldBuild( context.getScmResult().getChanges(), project,
+                                                        workingDirectoryService.getWorkingDirectory( project ),
+                                                        context.getBuildDefinition() );
+                }
             }
             catch ( Exception e )
             {
@@ -644,7 +611,7 @@ public class DefaultBuildController
 
         try
         {
-            Project project = projectDao.getProjectWithAllDetails( context.getProject().getId() );
+            Project project = projectDao.getProjectWithDependencies( context.getProject().getId() );
             List<ProjectDependency> dependencies = project.getDependencies();
 
             if ( dependencies == null )
@@ -671,10 +638,9 @@ public class DefaultBuildController
 
                 if ( dependencyProject != null )
                 {
-                    List<BuildResult> buildResults =
-                        buildResultDao.getBuildResultsInSuccessForProject( dependencyProject.getId(),
-                                                                           context.getOldBuildResult().getEndTime() );
-                    if ( buildResults != null && !buildResults.isEmpty() )
+                    long nbBuild = buildResultDao.getNbBuildResultsInSuccessForProject( dependencyProject.getId(),
+                                                                                        context.getOldBuildResult().getEndTime() );
+                    if ( nbBuild > 0 )
                     {
                         log.debug( "Dependency changed: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" +
                             dep.getVersion() );
@@ -694,7 +660,7 @@ public class DefaultBuildController
             }
 
             context.setModifiedDependencies( modifiedDependencies );
-            context.getActionContext().put( AbstractContinuumAction.KEY_UPDATE_DEPENDENCIES, modifiedDependencies );
+            AbstractContinuumAction.setUpdatedDependencies( context.getActionContext(), modifiedDependencies );
         }
         catch ( ContinuumStoreException e )
         {
@@ -716,7 +682,9 @@ public class DefaultBuildController
 
         build.setState( ContinuumProjectState.ERROR );
 
-        build.setTrigger( context.getTrigger() );
+        build.setTrigger( context.getBuildTrigger().getTrigger() );
+        
+        build.setUsername( context.getBuildTrigger().getUsername() );
 
         build.setStartTime( context.getStartTime() );
 

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java Thu May  6 09:23:13 2010
@@ -195,6 +195,7 @@ public class DefaultBuildDefinitionServi
             storedBuildDefinition.setProfile( buildDefinition.getProfile() );
             storedBuildDefinition.setSchedule( buildDefinition.getSchedule() );
             storedBuildDefinition.setType( buildDefinition.getType() );
+            storedBuildDefinition.setUpdatePolicy( buildDefinition.getUpdatePolicy() );
             buildDefinitionDao.storeBuildDefinition( storedBuildDefinition );
         }
         catch ( ContinuumStoreException e )
@@ -248,6 +249,7 @@ public class DefaultBuildDefinitionServi
         cloned.setSchedule( buildDefinition.getSchedule() );
         cloned.setType( buildDefinition.getType() );
         cloned.setTemplate( buildDefinition.isTemplate() );
+        cloned.setUpdatePolicy( buildDefinition.getUpdatePolicy() );
         return cloned;
     }
 
@@ -489,15 +491,20 @@ public class DefaultBuildDefinitionServi
     {
         try
         {
-            BuildDefinitionTemplate stored = getBuildDefinitionTemplate( buildDefinitionTemplate.getId() );
-            stored.setName( buildDefinitionTemplate.getName() );
-            stored.setBuildDefinitions( buildDefinitionTemplate.getBuildDefinitions() );
-            return buildDefinitionTemplateDao.updateBuildDefinitionTemplate( stored );
+            if ( !hasDuplicateTemplateName( buildDefinitionTemplate ) )
+            {
+                BuildDefinitionTemplate stored = getBuildDefinitionTemplate( buildDefinitionTemplate.getId() );
+                stored.setName( buildDefinitionTemplate.getName() );
+                stored.setBuildDefinitions( buildDefinitionTemplate.getBuildDefinitions() );
+                return buildDefinitionTemplateDao.updateBuildDefinitionTemplate( stored );
+            }
         }
         catch ( ContinuumStoreException e )
         {
             throw new BuildDefinitionServiceException( e.getMessage(), e );
         }
+        
+        return null;
     }
 
     public BuildDefinitionTemplate addBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
@@ -505,12 +512,17 @@ public class DefaultBuildDefinitionServi
     {
         try
         {
-            return buildDefinitionTemplateDao.addBuildDefinitionTemplate( buildDefinitionTemplate );
+            if ( !hasDuplicateTemplateName( buildDefinitionTemplate ) )
+            {
+                return buildDefinitionTemplateDao.addBuildDefinitionTemplate( buildDefinitionTemplate );
+            }
         }
         catch ( ContinuumStoreException e )
         {
             throw new BuildDefinitionServiceException( e.getMessage(), e );
         }
+        
+        return null;
     }
 
     public BuildDefinitionTemplate addBuildDefinitionInTemplate( BuildDefinitionTemplate buildDefinitionTemplate,
@@ -645,4 +657,22 @@ public class DefaultBuildDefinitionServi
             throw new BuildDefinitionServiceException( e.getMessage(), e );
         }
     }
+    
+    private boolean hasDuplicateTemplateName( BuildDefinitionTemplate buildDefinitionTemplate )
+        throws BuildDefinitionServiceException
+    {
+        boolean isDuplicate = false;
+        List<BuildDefinitionTemplate> allBuildDefinitionTemplate = this.getAllBuildDefinitionTemplate();
+    
+        for ( BuildDefinitionTemplate template : allBuildDefinitionTemplate )
+        {
+            String name = buildDefinitionTemplate.getName();
+            if ( ( template.getId() != buildDefinitionTemplate.getId() ) && ( template.getName().equals( name ) ) )
+            {
+                isDuplicate = true;
+                break;
+            }
+        }
+        return isDuplicate;
+    }
 }

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/evaluator/BuildProjectTaskViabilityEvaluator.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/evaluator/BuildProjectTaskViabilityEvaluator.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/evaluator/BuildProjectTaskViabilityEvaluator.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/evaluator/BuildProjectTaskViabilityEvaluator.java Thu May  6 09:23:13 2010
@@ -117,7 +117,7 @@ public class BuildProjectTaskViabilityEv
                 // If this build is forces, don't remove it
                 // ----------------------------------------------------------------------
 
-                if ( task.getTrigger() == ContinuumProjectState.TRIGGER_FORCED )
+                if ( task.getBuildTrigger().getTrigger() == ContinuumProjectState.TRIGGER_FORCED )
                 {
                     continue;
                 }

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java Thu May  6 09:23:13 2010
@@ -170,6 +170,7 @@ public abstract class AbstractBuildDefin
                 storedDefinition.setArguments( buildDefinition.getArguments() );
                 storedDefinition.setBuildFile( buildDefinition.getBuildFile() );
                 storedDefinition.setBuildFresh( buildDefinition.isBuildFresh() );
+                storedDefinition.setUpdatePolicy( buildDefinition.getUpdatePolicy() );
 
                 // special case of this is resolved in the resolveDefaultBuildDefinitionsForProjectGroup method
                 storedDefinition.setDefaultForProject( buildDefinition.isDefaultForProject() );

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java Thu May  6 09:23:13 2010
@@ -20,11 +20,11 @@ package org.apache.maven.continuum.core.
  */
 
 import java.io.File;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.continuum.model.project.ProjectScmRoot;
+import org.apache.continuum.utils.build.BuildTrigger;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
 import org.apache.maven.continuum.model.project.Project;
@@ -44,78 +44,43 @@ public abstract class AbstractContinuumA
     // Keys for the values that can be in the context
     // ----------------------------------------------------------------------
 
-    public static final String KEY_PROJECT_ID = "project-id";
+    private static final String KEY_PROJECT_ID = "project-id";
 
-    public static final String KEY_PROJECT = "project";
+    private static final String KEY_PROJECT = "project";
 
-    public static final String KEY_PROJECTS = "projects";
+    private static final String KEY_PROJECTS = "projects";
 
-    public static final String KEY_PROJECTS_BUILD_DEFINITIONS_MAP = "projects-build-definitions";
+    private static final String KEY_PROJECTS_BUILD_DEFINITIONS_MAP = "projects-build-definitions";
 
-    public static final String KEY_BUILD_DEFINITION_TEMPLATE = "build-definition-template";
+    private static final String KEY_BUILD_DEFINITION_TEMPLATE = "build-definition-template";
 
-    public static final String KEY_BUILD_DEFINITION = "build-definition";
+    private static final String KEY_BUILD_DEFINITION = "build-definition";
 
-    public static final String KEY_BUILD_DEFINITION_ID = "build-definition-id";
+    private static final String KEY_BUILD_DEFINITION_ID = "build-definition-id";
 
-    public static final String KEY_UNVALIDATED_PROJECT = "unvalidated-project";
+    private static final String KEY_UNVALIDATED_PROJECT = "unvalidated-project";
 
-    public static final String KEY_PROJECT_GROUP_ID = "project-group-id";
+    private static final String KEY_PROJECT_GROUP_ID = "project-group-id";
 
-    public static final String KEY_UNVALIDATED_PROJECT_GROUP = "unvalidated-project-group";
+    private static final String KEY_UNVALIDATED_PROJECT_GROUP = "unvalidated-project-group";
 
-    public static final String KEY_BUILD_ID = "build-id";
+    private static final String KEY_BUILD_ID = "build-id";
 
-    public static final String KEY_WORKING_DIRECTORY = "working-directory";
+    private static final String KEY_WORKING_DIRECTORY = "working-directory";
 
-    public static final String KEY_WORKING_DIRECTORY_EXISTS = "working-directory-exists";
+    private static final String KEY_UPDATE_DEPENDENCIES = "update-dependencies";
 
-    public static final String KEY_CHECKOUT_SCM_RESULT = "checkout-result";
+    private static final String KEY_BUILD_TRIGGER = "buildTrigger";
 
-    public static final String KEY_UPDATE_SCM_RESULT = "update-result";
+    private static final String KEY_SCM_RESULT = "scmResult";
 
-    public static final String KEY_UPDATE_DEPENDENCIES = "update-dependencies";
+    private static final String KEY_OLD_SCM_RESULT = "old-scmResult";
 
-    public static final String KEY_TRIGGER = "trigger";
+    private static final String KEY_PROJECT_SCM_ROOT = "projectScmRoot";
 
-    public static final String KEY_FIRST_RUN = "first-run";
+    private static final String KEY_OLD_BUILD_ID = "old-buildResult-id";
 
-    public static final String KEY_PROJECT_RELATIVE_PATH = "project-relative-path";
-
-    public static final String KEY_SCM_USE_CREDENTIALS_CACHE = "useCredentialsCache";
-
-    public static final String KEY_SCM_USERNAME = "scmUserName";
-
-    public static final String KEY_SCM_PASSWORD = "scmUserPassword";
-
-    public static final String KEY_SCM_RESULT = "scmResult";
-
-    public static final String KEY_OLD_SCM_RESULT = "old-scmResult";
-
-    public static final String KEY_PROJECT_SCM_ROOT = "projectScmRoot";
-    
-    /**
-     * SCM root url. Used in these actions add-project-to-checkout-queue, checkout-project, clean-working-directory,
-     *      create-projects-from-metadata, update-project-from-working-directory, 
-     *      update-working-directory-from-scm
-     */
-    public static final String KEY_PROJECT_SCM_ROOT_URL = "projectScmRootUrl";
-
-    public static final String KEY_OLD_BUILD_ID = "old-buildResult-id";
-
-    public static final String KEY_CANCELLED = "cancelled";
-
-    public static final String KEY_SCM_RESULT_MAP = "scm-result-map";
-    
-    /**
-     * Metadata url for adding projects.
-     */
-    public static final String KEY_URL = "url";
-    
-    /**
-     * List of projects in a project group with a common scm root url.
-     */
-    public static final String KEY_PROJECTS_IN_GROUP_WITH_COMMON_SCM_ROOT = "projects-in-group-with-common-scm-root";
+    private static final String KEY_SCM_RESULT_MAP = "scm-result-map";
 
     // ----------------------------------------------------------------------
     //
@@ -126,39 +91,90 @@ public abstract class AbstractContinuumA
         return getInteger( context, KEY_PROJECT_ID );
     }
 
+    public static void setProjectId( Map<String, Object> context, int projectId )
+    {
+        context.put( KEY_PROJECT_ID, projectId );
+    }
+
     public static Project getProject( Map<String, Object> context )
     {
         return (Project) getObject( context, KEY_PROJECT );
     }
 
+    public static Project getProject( Map<String, Object> context, Project defaultValue )
+    {
+        return (Project) getObject( context, KEY_PROJECT, defaultValue );
+    }
+
+    public static void setProject( Map<String, Object> context, Project p )
+    {
+        context.put( KEY_PROJECT, p );
+    }
+
     public static int getProjectGroupId( Map<String, Object> context )
     {
         return getInteger( context, KEY_PROJECT_GROUP_ID );
     }
 
+    public static void setProjectGroupId( Map<String, Object> context, int projectGroupId )
+    {
+        context.put( KEY_PROJECT_GROUP_ID, projectGroupId );
+    }
+
     public static BuildDefinitionTemplate getBuildDefinitionTemplate( Map<String, Object> context )
     {
         return (BuildDefinitionTemplate) getObject( context, KEY_BUILD_DEFINITION_TEMPLATE, null );
     }
 
+    public static void setBuildDefinitionTemplate( Map<String, Object> context, BuildDefinitionTemplate bdt )
+    {
+        context.put( KEY_BUILD_DEFINITION_TEMPLATE, bdt );
+    }
+
     public static BuildDefinition getBuildDefinition( Map<String, Object> context )
     {
         return (BuildDefinition) getObject( context, KEY_BUILD_DEFINITION, null );
     }
 
+    public static void setBuildDefinition( Map<String, Object> context, BuildDefinition bd )
+    {
+        context.put( KEY_BUILD_DEFINITION, bd );
+    }
+
     public static int getBuildDefinitionId( Map<String, Object> context )
     {
         return getInteger( context, KEY_BUILD_DEFINITION_ID );
     }
 
+    public static void setBuildDefinitionId( Map<String, Object> context, int buildDefintionId )
+    {
+        context.put( KEY_BUILD_DEFINITION_ID, buildDefintionId );
+    }
+
     public static String getBuildId( Map<String, Object> context )
     {
         return getString( context, KEY_BUILD_ID );
     }
 
-    public static int getTrigger( Map<String, Object> context )
+    public static String getBuildId( Map<String, Object> context, String defaultValue )
+    {
+        return getString( context, KEY_BUILD_ID, defaultValue );
+    }
+
+    public static void setBuildId( Map<String, Object> context, String buildId )
+    {
+        context.put( KEY_BUILD_ID, buildId );
+    }
+
+    public static BuildTrigger getBuildTrigger( Map<String, Object> context )
     {
-        return getInteger( context, KEY_TRIGGER );
+    	BuildTrigger defaultValue = new BuildTrigger( 0, "" );
+    	return (BuildTrigger) getObject( context, KEY_BUILD_TRIGGER, defaultValue );
+    }
+
+    public static void setBuildTrigger( Map<String, Object> context, BuildTrigger buildTrigger )
+    {
+    	context.put( KEY_BUILD_TRIGGER, buildTrigger );
     }
 
     public static Project getUnvalidatedProject( Map<String, Object> context )
@@ -166,29 +182,29 @@ public abstract class AbstractContinuumA
         return (Project) getObject( context, KEY_UNVALIDATED_PROJECT );
     }
 
-    public static ProjectGroup getUnvalidatedProjectGroup( Map<String, Object> context )
+    public static void setUnvalidatedProject( Map<String, Object> context, Project p )
     {
-        return (ProjectGroup) getObject( context, KEY_UNVALIDATED_PROJECT_GROUP );
+        context.put( KEY_UNVALIDATED_PROJECT, p );
     }
 
-    public static File getWorkingDirectory( Map<String, Object> context )
+    public static ProjectGroup getUnvalidatedProjectGroup( Map<String, Object> context )
     {
-        return new File( getString( context, KEY_WORKING_DIRECTORY ) );
+        return (ProjectGroup) getObject( context, KEY_UNVALIDATED_PROJECT_GROUP );
     }
 
-    public static ScmResult getCheckoutResult( Map<String, Object> context, Object defaultValue )
+    public static void setUnvalidatedProjectGroup( Map<String, Object> context, ProjectGroup pg )
     {
-        return (ScmResult) getObject( context, KEY_CHECKOUT_SCM_RESULT, defaultValue );
+        context.put( KEY_UNVALIDATED_PROJECT_GROUP, pg );
     }
 
-    public static ScmResult getUpdateScmResult( Map<String, Object> context )
+    public static File getWorkingDirectory( Map<String, Object> context )
     {
-        return getUpdateScmResult( context, null );
+        return new File( getString( context, KEY_WORKING_DIRECTORY ) );
     }
 
-    public static ScmResult getUpdateScmResult( Map<String, Object> context, ScmResult defaultValue )
+    public static void setWorkingDirectory( Map<String, Object> context, String workingDirectory )
     {
-        return (ScmResult) getObject( context, KEY_UPDATE_SCM_RESULT, defaultValue );
+        context.put( KEY_WORKING_DIRECTORY, workingDirectory );
     }
 
     public static List<ProjectDependency> getUpdatedDependencies( Map<String, Object> context )
@@ -202,6 +218,11 @@ public abstract class AbstractContinuumA
         return (List<ProjectDependency>) getObject( context, KEY_UPDATE_DEPENDENCIES, defaultValue );
     }
 
+    public static void setUpdatedDependencies( Map<String, Object> context, List<ProjectDependency> dependencies )
+    {
+        context.put( KEY_UPDATE_DEPENDENCIES, dependencies );
+    }
+
     public static ScmResult getScmResult( Map<String, Object> context )
     {
         return getScmResult( context, null );
@@ -212,6 +233,11 @@ public abstract class AbstractContinuumA
         return (ScmResult) getObject( context, KEY_SCM_RESULT, defaultValue );
     }
 
+    public static void setScmResult( Map<String, Object> context, ScmResult scmResult )
+    {
+        context.put( KEY_SCM_RESULT, scmResult );
+    }
+
     public static ScmResult getOldScmResult( Map<String, Object> context )
     {
         return getOldScmResult( context, null );
@@ -222,47 +248,72 @@ public abstract class AbstractContinuumA
         return (ScmResult) getObject( context, KEY_OLD_SCM_RESULT, defaultValue );
     }
 
+    public static void setOldScmResult( Map<String, Object> context, ScmResult oldScmResult )
+    {
+        context.put( KEY_OLD_SCM_RESULT, oldScmResult );
+    }
+
     public static ProjectScmRoot getProjectScmRoot( Map<String, Object> context )
     {
         return (ProjectScmRoot) getObject( context, KEY_PROJECT_SCM_ROOT );
     }
 
+    public static void setProjectScmRoot( Map<String, Object> context, ProjectScmRoot projectScmRoot )
+    {
+        context.put( KEY_PROJECT_SCM_ROOT, projectScmRoot );
+    }
+
     public static int getOldBuildId( Map<String, Object> context )
     {
         return getInteger( context, KEY_OLD_BUILD_ID );
     }
 
+    public static void setOldBuildId( Map<String, Object> context, int oldBuildId )
+    {
+        context.put( KEY_OLD_BUILD_ID, oldBuildId );
+    }
+
     public static List<Project> getListOfProjects( Map<String, Object> context )
     {
         return (List<Project>) getObject( context, KEY_PROJECTS );
     }
 
+    public static void setListOfProjects( Map<String, Object> context, List<Project> projects )
+    {
+        context.put( KEY_PROJECTS, projects );
+    }
+
     public static Map<Integer, BuildDefinition> getProjectsBuildDefinitionsMap( Map<String, Object> context )
     {
         return (Map<Integer, BuildDefinition>) getObject( context, KEY_PROJECTS_BUILD_DEFINITIONS_MAP );
     }
 
+    public static void setProjectsBuildDefinitionsMap( Map<String, Object> context,
+                                                       Map<Integer, BuildDefinition> projectsBuildDefinitionsMap )
+    {
+        context.put( KEY_PROJECTS_BUILD_DEFINITIONS_MAP, projectsBuildDefinitionsMap );
+    }
+
     public static Map<Integer, ScmResult> getScmResultMap( Map<String, Object> context )
     {
         return (Map<Integer, ScmResult>) getObject( context, KEY_SCM_RESULT_MAP );
     }
-    
-    public static List<Project> getListOfProjectsInGroupWithCommonScmRoot( Map<String, Object> context )
+
+    public static void setScmResultMap( Map<String, Object> context, Map<Integer, ScmResult> scmResultMap )
     {
-        return (List<Project>) getObject( context, KEY_PROJECTS_IN_GROUP_WITH_COMMON_SCM_ROOT, new ArrayList<Integer>() );
+        context.put( KEY_SCM_RESULT_MAP, scmResultMap );
     }
-    
-    
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
 
-    public static String getString( Map<String, Object> context, String key )
+    protected static String getString( Map<String, Object> context, String key )
     {
         return (String) getObject( context, key );
     }
 
-    public static String getString( Map<String, Object> context, String key, String defaultValue )
+    protected static String getString( Map<String, Object> context, String key, String defaultValue )
     {
         return (String) getObject( context, key, defaultValue );
     }

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddAssignableRolesAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddAssignableRolesAction.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddAssignableRolesAction.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddAssignableRolesAction.java Thu May  6 09:23:13 2010
@@ -19,6 +19,8 @@ package org.apache.maven.continuum.core.
  * under the License.
  */
 
+import java.util.Map;
+
 import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -26,8 +28,6 @@ import org.apache.maven.continuum.store.
 import org.codehaus.plexus.redback.role.RoleManager;
 import org.codehaus.plexus.redback.role.RoleManagerException;
 
-import java.util.Map;
-
 /**
  * AddAssignableRolesAction:
  *

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectAction.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectAction.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectAction.java Thu May  6 09:23:13 2010
@@ -39,13 +39,13 @@ public class AddBuildDefinitionToProject
      */
     private ProjectDao projectDao;
 
-    public void execute( Map map )
+    public void execute( Map context )
         throws Exception
     {
-        int projectId = getProjectId( map );
+        int projectId = getProjectId( context );
         Project project = projectDao.getProjectWithAllDetails( projectId );
 
-        BuildDefinitionTemplate buildDefinitionTemplate = getBuildDefinitionTemplate( map );
+        BuildDefinitionTemplate buildDefinitionTemplate = getBuildDefinitionTemplate( context );
 
         if ( buildDefinitionTemplate != null )
         {
@@ -55,23 +55,23 @@ public class AddBuildDefinitionToProject
 
                 project.addBuildDefinition( buildDefinition );
 
-                projectDao.updateProject( project );
                 if ( buildDefinition.isDefaultForProject() )
                 {
-                    map.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, buildDefinition );
+                    AbstractContinuumAction.setBuildDefinition( context, buildDefinition );
                 }
             }
         }
         else
         {
-            BuildDefinition buildDefinition = getBuildDefinition( map );
+            BuildDefinition buildDefinition = getBuildDefinition( context );
             resolveDefaultBuildDefinitionsForProject( buildDefinition, project );
 
             project.addBuildDefinition( buildDefinition );
 
-            projectDao.updateProject( project );
-            map.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, buildDefinition );
+            AbstractContinuumAction.setBuildDefinition( context, buildDefinition );
         }
 
+        // Save the project
+        projectDao.updateProject( project );
     }
 }

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectGroupAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectGroupAction.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectGroupAction.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectGroupAction.java Thu May  6 09:23:13 2010
@@ -44,12 +44,12 @@ public class AddBuildDefinitionToProject
     private ProjectGroupDao projectGroupDao;
 
 
-    public void execute( Map map )
+    public void execute( Map context )
         throws Exception
     {
-        int projectGroupId = getProjectGroupId( map );
+        int projectGroupId = getProjectGroupId( context );
         ProjectGroup projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
-        BuildDefinitionTemplate buildDefinitionTemplate = getBuildDefinitionTemplate( map );
+        BuildDefinitionTemplate buildDefinitionTemplate = getBuildDefinitionTemplate( context );
         if ( buildDefinitionTemplate != null )
         {
             for ( BuildDefinition buildDefinition : (List<BuildDefinition>) buildDefinitionTemplate.getBuildDefinitions() )
@@ -57,20 +57,20 @@ public class AddBuildDefinitionToProject
                 resolveDefaultBuildDefinitionsForProjectGroup( buildDefinition, projectGroup );
 
                 projectGroup.addBuildDefinition( buildDefinition );
-
-                projectGroupDao.updateProjectGroup( projectGroup );
             }
         }
         else
         {
-            BuildDefinition buildDefinition = getBuildDefinition( map );
+            BuildDefinition buildDefinition = getBuildDefinition( context );
 
             resolveDefaultBuildDefinitionsForProjectGroup( buildDefinition, projectGroup );
 
             projectGroup.addBuildDefinition( buildDefinition );
-
-            projectGroupDao.updateProjectGroup( projectGroup );
         }
+
+        // Save the project group
+        projectGroupDao.updateProjectGroup( projectGroup );
+
         //map.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, buildDefinition );
     }
 }

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java Thu May  6 09:23:13 2010
@@ -21,6 +21,7 @@ package org.apache.maven.continuum.core.
 
 import java.util.Map;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.continuum.buildmanager.BuildsManager;
 import org.apache.continuum.dao.ProjectDao;
 import org.apache.maven.continuum.model.project.BuildDefinition;
@@ -55,18 +56,28 @@ public class AddProjectToCheckOutQueueAc
     public void execute( Map context )
         throws Exception
     {
-        Project project = (Project) getObject( context, KEY_PROJECT, null );
+        Project project = getProject( context, null );
         if ( project == null )
         {
             project = projectDao.getProject( getProjectId( context ) );
         }
 
-        String scmRootUrl = getString( context, KEY_PROJECT_SCM_ROOT_URL, null );
+        String scmUsername = project.getScmUsername();
+        String scmPassword = project.getScmPassword();
+        
+        if( scmUsername == null || StringUtils.isEmpty( scmUsername ) )
+        {
+            scmUsername = CheckoutProjectContinuumAction.getScmUsername( context, null );
+        }
+        
+        if( scmPassword == null || StringUtils.isEmpty( scmPassword ) )
+        {
+            scmPassword = CheckoutProjectContinuumAction.getScmPassword( context, null );
+        }
         
         BuildDefinition defaultBuildDefinition = getBuildDefinition( context );
         parallelBuildsManager.checkoutProject( project.getId(), project.getName(),
                                                workingDirectoryService.getWorkingDirectory( project ),
-                                               scmRootUrl, project.getScmUsername(),
-                                               project.getScmPassword(), defaultBuildDefinition, getListOfProjectsInGroupWithCommonScmRoot( context ) );
+                                               scmUsername, scmPassword, defaultBuildDefinition );
     }
 }

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckWorkingDirectoryAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckWorkingDirectoryAction.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckWorkingDirectoryAction.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckWorkingDirectoryAction.java Thu May  6 09:23:13 2010
@@ -20,10 +20,10 @@ package org.apache.maven.continuum.core.
  */
 
 import java.io.File;
-import java.util.List;
 import java.util.Map;
 
 import org.apache.continuum.dao.ProjectDao;
+import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.utils.WorkingDirectoryService;
 
@@ -35,7 +35,9 @@ import org.apache.maven.continuum.utils.
  */
 public class CheckWorkingDirectoryAction
     extends AbstractContinuumAction
-{   
+{
+    private static final String KEY_WORKING_DIRECTORY_EXISTS = "working-directory-exists";
+
     /**
      * @plexus.requirement
      */
@@ -50,22 +52,36 @@ public class CheckWorkingDirectoryAction
         throws Exception
     {
         Project project = projectDao.getProject( getProjectId( context ) );
-        List<Project> projectsWithCommonScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context );
-        String projectScmRootUrl = getString( context, KEY_PROJECT_SCM_ROOT_URL, project.getScmUrl() );
-       
-        File workingDirectory =
-            workingDirectoryService.getWorkingDirectory( project, projectScmRootUrl,
-                                                         projectsWithCommonScmRoot );
-        
+
+        File workingDirectory = workingDirectoryService.getWorkingDirectory( project );
+
         if ( !workingDirectory.exists() )
         {
-            context.put( KEY_WORKING_DIRECTORY_EXISTS, Boolean.FALSE );
+            setWorkingDirectoryExist( context, false );
 
             return;
         }
 
         File[] files = workingDirectory.listFiles();
 
-        context.put( KEY_WORKING_DIRECTORY_EXISTS, files.length > 0 );
+        if ( files == null )
+        {
+            //workingDirectory isn't a directory but a file. Not possible in theory.
+            String msg = workingDirectory.getAbsolutePath() + " isn't a directory but a file.";
+            getLogger().error( msg );
+            throw new ContinuumException( msg );
+        }
+
+        setWorkingDirectoryExist( context, files.length > 0 );
+    }
+
+    public static boolean isWorkingDirectoryExist( Map<String, Object> context )
+    {
+        return getBoolean( context, KEY_WORKING_DIRECTORY_EXISTS );
+    }
+
+    private static void setWorkingDirectoryExist( Map<String, Object> context, boolean exists )
+    {
+        context.put( KEY_WORKING_DIRECTORY_EXISTS, exists );
     }
 }

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java Thu May  6 09:23:13 2010
@@ -49,6 +49,14 @@ import org.codehaus.plexus.util.StringUt
 public class CheckoutProjectContinuumAction
     extends AbstractContinuumAction
 {
+    private static final String KEY_SCM_USERNAME = "scmUserName";
+
+    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";
+
     /**
      * @plexus.requirement
      */
@@ -71,7 +79,7 @@ public class CheckoutProjectContinuumAct
 
     public void execute( Map context )
         throws ContinuumStoreException
-    {
+    {   
         Project project = projectDao.getProject( getProject( context ).getId() );
 
         BuildDefinition buildDefinition = getBuildDefinition( context );
@@ -81,6 +89,8 @@ public class CheckoutProjectContinuumAct
             buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinition.getId() );
         }
 
+        int originalState = project.getState();
+
         project.setState( ContinuumProjectState.CHECKING_OUT );
 
         projectDao.updateProject( project );
@@ -93,16 +103,12 @@ public class CheckoutProjectContinuumAct
 
         ScmResult result;
 
-        List<Project> projectsWithSimilarScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context );
-        
         try
         {
-            String scmUserName = getString( context, KEY_SCM_USERNAME, project.getScmUsername() );
-            String scmPassword = getString( context, KEY_SCM_PASSWORD, project.getScmPassword() );
-            String scmRootUrl = getString( context, KEY_PROJECT_SCM_ROOT_URL, project.getScmUrl() );            
-            
+            String scmUserName = getScmUsername( context, project.getScmUsername() );
+            String scmPassword = getScmPassword( context, project.getScmPassword() );
             ContinuumScmConfiguration config =
-                createScmConfiguration( project, workingDirectory, scmUserName, scmPassword, scmRootUrl );
+                createScmConfiguration( project, workingDirectory, scmUserName, scmPassword );
 
             String tag = config.getTag();
             getLogger().info(
@@ -110,13 +116,11 @@ public class CheckoutProjectContinuumAct
                     workingDirectory + "'" + ( tag != null ? " with branch/tag " + tag + "." : "." ) );
 
             CheckOutScmResult checkoutResult = scm.checkout( config );
-            
             if ( StringUtils.isNotEmpty( checkoutResult.getRelativePathProjectDirectory() ) )
             {
-                context.put( AbstractContinuumAction.KEY_PROJECT_RELATIVE_PATH,
-                             checkoutResult.getRelativePathProjectDirectory() );
+                context.put( KEY_PROJECT_RELATIVE_PATH, checkoutResult.getRelativePathProjectDirectory() );
             }
-            
+
             if ( !checkoutResult.isSuccess() )
             {
                 // TODO: is it more appropriate to return this in the converted result so that it can be presented to
@@ -182,41 +186,37 @@ public class CheckoutProjectContinuumAct
         }
         finally
         {
-            String relativePath = (String) getObject( context, KEY_PROJECT_RELATIVE_PATH, "" );
+            String relativePath = getString( context, KEY_PROJECT_RELATIVE_PATH, "" );
             if ( StringUtils.isNotEmpty( relativePath ) )
             {
                 project.setRelativePath( relativePath );
             }
 
             project = projectDao.getProject( project.getId() );
-            
-            project.setState( ContinuumProjectState.CHECKEDOUT );
 
-            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 : projectsWithSimilarScmRoot )
+            if ( originalState == ContinuumProjectState.NEW )
             {
-                projectWithCommonScmRoot = projectDao.getProject( projectWithCommonScmRoot.getId() );
-                if( projectWithCommonScmRoot != null && projectWithCommonScmRoot.getId() != project.getId() )
-                {
-                    projectWithCommonScmRoot.setState( ContinuumProjectState.CHECKEDOUT );
-                    projectDao.updateProject( projectWithCommonScmRoot );                    
-                }
+                project.setState( ContinuumProjectState.CHECKEDOUT );
+            }
+            else
+            {
+                project.setState( originalState );
             }
+
+            projectDao.updateProject( project );
+
             notifier.checkoutComplete( project, buildDefinition );
         }
 
-        context.put( KEY_CHECKOUT_SCM_RESULT, result );
-        context.put( KEY_PROJECT, project );
+        setCheckoutResult( context, result );
+        setProject( context, project );
     }
 
     private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory,
-                                                              String scmUserName, String scmPassword, String scmRootUrl )
+                                                              String scmUserName, String scmPassword )
     {
         ContinuumScmConfiguration config = new ContinuumScmConfiguration();
-        config.setUrl( scmRootUrl );
+        config.setUrl( project.getScmUrl() );
         config.setUsername( scmUserName );
         config.setPassword( scmPassword );
         config.setUseCredentialsCache( project.isScmUseCache() );
@@ -282,4 +282,34 @@ public class CheckoutProjectContinuumAct
         }
         return message.toString();
     }
+
+    public static String getScmUsername( Map<String, Object> context, String defaultValue )
+    {
+        return getString( context, KEY_SCM_USERNAME, defaultValue );
+    }
+
+    public static void setScmUsername( Map<String, Object> context, String scmUsername )
+    {
+        context.put( KEY_SCM_USERNAME, scmUsername );
+    }
+
+    public static String getScmPassword( Map<String, Object> context, String defaultValue )
+    {
+        return getString( context, KEY_SCM_PASSWORD, defaultValue );
+    }
+
+    public static void setScmPassword( Map<String, Object> context, String scmPassword )
+    {
+        context.put( KEY_SCM_PASSWORD, scmPassword );
+    }
+
+    public static ScmResult getCheckoutResult( Map<String, Object> context, Object defaultValue )
+    {
+        return (ScmResult) getObject( context, KEY_CHECKOUT_SCM_RESULT, defaultValue );
+    }
+
+    public static void setCheckoutResult( Map<String, Object> context, ScmResult checkoutResult )
+    {
+        context.put( KEY_CHECKOUT_SCM_RESULT, checkoutResult );
+    }
 }

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CleanWorkingDirectoryAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CleanWorkingDirectoryAction.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CleanWorkingDirectoryAction.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CleanWorkingDirectoryAction.java Thu May  6 09:23:13 2010
@@ -26,7 +26,6 @@ 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;
 
 /**
@@ -52,12 +51,8 @@ public class CleanWorkingDirectoryAction
         throws Exception
     {
         Project project = projectDao.getProject( getProjectId( context ) );
-        List<Project> projectsWithCommonScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context );        
-        String projectScmRootUrl = getString( context, KEY_PROJECT_SCM_ROOT_URL, project.getScmUrl() );
 
-        File workingDirectory =
-            workingDirectoryService.getWorkingDirectory( project, projectScmRootUrl,
-                                                         projectsWithCommonScmRoot );
+        File workingDirectory = workingDirectoryService.getWorkingDirectory( project );
 
         if ( workingDirectory.exists() )
         {

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java Thu May  6 09:23:13 2010
@@ -25,6 +25,7 @@ import java.util.Map;
 
 import org.apache.continuum.buildmanager.BuildsManager;
 import org.apache.continuum.dao.ProjectDao;
+import org.apache.continuum.utils.build.BuildTrigger;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
 import org.apache.maven.continuum.execution.manager.BuildExecutorManager;
 import org.apache.maven.continuum.model.project.BuildDefinition;
@@ -50,28 +51,28 @@ public class CreateBuildProjectTaskActio
      * @plexus.requirement
      */
     private ProjectDao projectDao;
-    
+
     /**
      * @plexus.requirement role-hint="parallel"
      */
     private BuildsManager parallelBuildsManager;
-    
+
     public synchronized void execute( Map context )
         throws Exception
     {
         List<Project> projects = AbstractContinuumAction.getListOfProjects( context );
         Map<Integer, BuildDefinition> projectsBuildDefinitionsMap =
             AbstractContinuumAction.getProjectsBuildDefinitionsMap( context );
-        Map<Integer, ScmResult> scmResultMap = 
-            AbstractContinuumAction.getScmResultMap( context );
+        Map<Integer, ScmResult> scmResultMap = AbstractContinuumAction.getScmResultMap( context );
         List<Project> projectsToBeBuilt = new ArrayList<Project>();
-        int trigger = AbstractContinuumAction.getTrigger( context );
-        
+        BuildTrigger buildTrigger = AbstractContinuumAction.getBuildTrigger( context );
+        int projectGroupId = AbstractContinuumAction.getProjectGroupId( context );
+
         // update state of each project first
-        for( Project project : projects )
-        {   
+        for ( Project project : projects )
+        {
             BuildDefinition buildDefinition = projectsBuildDefinitionsMap.get( project.getId() );
-            
+
             if ( parallelBuildsManager.isInAnyBuildQueue( project.getId(), buildDefinition.getId() ) )
             {
                 return;
@@ -81,12 +82,13 @@ public class CreateBuildProjectTaskActio
             {
                 parallelBuildsManager.removeProjectFromCheckoutQueue( project.getId() );
             }
-            
+
             try
             {
                 if ( project.getState() != ContinuumProjectState.NEW &&
                     project.getState() != ContinuumProjectState.CHECKEDOUT &&
-                    project.getState() != ContinuumProjectState.OK && project.getState() != ContinuumProjectState.FAILED &&
+                    project.getState() != ContinuumProjectState.OK &&
+                    project.getState() != ContinuumProjectState.FAILED &&
                     project.getState() != ContinuumProjectState.ERROR )
                 {
                     ContinuumBuildExecutor executor = executorManager.getBuildExecutor( project.getExecutorId() );
@@ -100,25 +102,16 @@ public class CreateBuildProjectTaskActio
                     }
                     else
                     {
-                        project.setOldState( project.getState() );
-
                         project.setState( ContinuumProjectState.ERROR );
-
-                        projectDao.updateProject( project );
-
-                        project = projectDao.getProject( project.getId() );
                     }
                 }
-                else
-                {
-                    project.setOldState( project.getState() );
+                project.setOldState( project.getState() );
 
-                    projectDao.updateProject( project );
+                projectDao.updateProject( project );
 
-                    project = projectDao.getProject( project.getId() );
-                }
+                project = projectDao.getProject( project.getId() );
 
-                projectsToBeBuilt.add( project );                                
+                projectsToBeBuilt.add( project );
             }
             catch ( ContinuumStoreException e )
             {
@@ -126,7 +119,8 @@ public class CreateBuildProjectTaskActio
                 //throw new ContinuumException( "Error while creating build object.", e );
             }
         }
-        
-        parallelBuildsManager.buildProjects( projectsToBeBuilt, projectsBuildDefinitionsMap, trigger, scmResultMap );      
+
+        parallelBuildsManager.buildProjects( projectsToBeBuilt, projectsBuildDefinitionsMap, buildTrigger, scmResultMap,
+                                             projectGroupId );
     }
 }

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java Thu May  6 09:23:13 2010
@@ -61,6 +61,14 @@ import org.codehaus.plexus.util.xml.pull
 public class CreateProjectsFromMetadataAction
     extends AbstractContinuumAction
 {
+    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_LOAD_RECURSIVE_PROJECTS = "loadRecursiveProjects";
+
     /**
      * @plexus.requirement
      */
@@ -70,30 +78,20 @@ public class CreateProjectsFromMetadataA
      * @plexus.requirement
      */
     private MavenSettingsBuilder mavenSettingsBuilder;
-    
+
     /**
      * @plexus.requirement role-hint="continuumUrl"
      */
-    private ContinuumUrlValidator urlValidator;    
-
-    public static final String KEY_PROJECT_BUILDER_ID = "builderId";
-
-    public static final String KEY_PROJECT_BUILDING_RESULT = "projectBuildingResult";
-
-    public static final String KEY_LOAD_RECURSIVE_PROJECTS = "loadRecursiveProjects";
-    
-    public static final String KEY_CHECKOUT_PROJECTS_IN_SINGLE_DIRECTORY = "checkoutProjectsInSingleDirectory";
+    private ContinuumUrlValidator urlValidator;
 
     public void execute( Map context )
         throws ContinuumException, ContinuumProjectBuilderManagerException, ContinuumProjectBuilderException
     {
-        String projectBuilderId = getString( context, KEY_PROJECT_BUILDER_ID );
+        String projectBuilderId = getProjectBuilderId( context );
 
-        boolean loadRecursiveProjects = getBoolean( context, KEY_LOAD_RECURSIVE_PROJECTS );
-        
-        boolean checkoutProjectsInSingleDirectory = getBoolean( context, KEY_CHECKOUT_PROJECTS_IN_SINGLE_DIRECTORY );
+        boolean loadRecursiveProjects = isLoadRecursiveProject( context );
 
-        String curl = getString( context, KEY_URL );
+        String curl = getUrl( context );
 
         URL url;
 
@@ -107,13 +105,13 @@ public class CreateProjectsFromMetadataA
             if ( buildDefinitionTemplate == null )
             {
                 buildDefinitionTemplate = projectBuilder.getDefaultBuildDefinitionTemplate();
-            }            
+            }
             if ( !curl.startsWith( "http" ) )
             {
                 url = new URL( curl );
 
                 result = projectBuilder.buildProjectsFromMetadata( url, null, null, loadRecursiveProjects,
-                                                                   buildDefinitionTemplate, checkoutProjectsInSingleDirectory );
+                                                                   buildDefinitionTemplate );
 
             }
             else
@@ -152,7 +150,7 @@ public class CreateProjectsFromMetadataA
                 {
 
                     result = projectBuilder.buildProjectsFromMetadata( url, username, password, loadRecursiveProjects,
-                                                                       buildDefinitionTemplate, checkoutProjectsInSingleDirectory );
+                                                                       buildDefinitionTemplate );
 
                 }
                 else
@@ -162,11 +160,11 @@ public class CreateProjectsFromMetadataA
                     result.addError( ContinuumProjectBuildingResult.ERROR_MALFORMED_URL );
                 }
             }
-     
+
             if ( result.getProjects() != null )
             {
                 String scmRootUrl = getScmRootUrl( result.getProjects() );
-                
+
                 if ( scmRootUrl == null || scmRootUrl.equals( "" ) )
                 {
                     if ( curl.indexOf( "pom.xml" ) > 0 )
@@ -178,8 +176,8 @@ public class CreateProjectsFromMetadataA
                         scmRootUrl = curl;
                     }
                 }
-                
-                context.put( KEY_PROJECT_SCM_ROOT_URL, scmRootUrl );
+
+                setUrl( context, scmRootUrl );
             }
         }
         catch ( MalformedURLException e )
@@ -195,7 +193,7 @@ public class CreateProjectsFromMetadataA
             result.addError( ContinuumProjectBuildingResult.ERROR_MALFORMED_URL );
         }
 
-        context.put( KEY_PROJECT_BUILDING_RESULT, result );
+        setProjectBuildingResult( context, result );
     }
 
     private String hidePasswordInUrl( String url )
@@ -235,14 +233,14 @@ public class CreateProjectsFromMetadataA
     private String getScmRootUrl( List<Project> projects )
     {
         String scmRootUrl = "";
-        
+
         for ( Project project : projects )
         {
             String scmUrl = project.getScmUrl();
-            
+
             scmRootUrl = getCommonPath( scmUrl, scmRootUrl );
         }
-        
+
         return scmRootUrl;
     }
 
@@ -255,7 +253,19 @@ public class CreateProjectsFromMetadataA
         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;
         }
     }
 
@@ -288,4 +298,44 @@ 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 );
+    }
+
+    public static void setUrl( Map<String, Object> context, String url )
+    {
+        context.put( KEY_URL, url );
+    }
+
+    public static String getProjectBuilderId( Map<String, Object> context )
+    {
+        return getString( context, KEY_PROJECT_BUILDER_ID );
+    }
+
+    public static void setProjectBuilderId( Map<String, Object> context, String projectBuilderId )
+    {
+        context.put( KEY_PROJECT_BUILDER_ID, projectBuilderId );
+    }
+
+    public static boolean isLoadRecursiveProject( Map<String, Object> context )
+    {
+        return getBoolean( context, KEY_LOAD_RECURSIVE_PROJECTS );
+    }
+
+    public static void setLoadRecursiveProject( Map<String, Object> context, boolean loadRecursiveProject )
+    {
+        context.put( KEY_LOAD_RECURSIVE_PROJECTS, loadRecursiveProject );
+    }
 }

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java Thu May  6 09:23:13 2010
@@ -19,6 +19,10 @@ package org.apache.maven.continuum.core.
  * under the License.
  */
 
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.deployer.ArtifactDeployer;
@@ -35,11 +39,6 @@ import org.apache.maven.continuum.model.
 import org.apache.maven.continuum.project.ContinuumProjectState;
 import org.apache.maven.continuum.utils.WorkingDirectoryService;
 
-import java.io.File;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 /**
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @version $Id$
@@ -103,19 +102,16 @@ public class DeployArtifactContinuumActi
             {
                 BuildDefinition buildDefinition = getBuildDefinition( context );
 
-                String projectScmRootUrl = getString( context, KEY_PROJECT_SCM_ROOT_URL, project.getScmUrl() );
-                List<Project> projectsWithCommonScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context );
-                
                 List<Artifact> artifacts = buildExecutor.getDeployableArtifacts( project,
-                                           workingDirectoryService.getWorkingDirectory(
-                                               project, projectScmRootUrl, projectsWithCommonScmRoot ), buildDefinition );
+                                                                                 workingDirectoryService.getWorkingDirectory(
+                                                                                     project ), buildDefinition );
 
                 LocalRepository repository = project.getProjectGroup().getLocalRepository();
-                
+
                 builderHelper.setLocalRepository( repository );
-                
+
                 ArtifactRepository localRepository = builderHelper.getLocalRepository();
-                
+
                 for ( Artifact artifact : artifacts )
                 {
                     ArtifactRepositoryLayout repositoryLayout = new DefaultRepositoryLayout();



Mime
View raw message