continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r734099 [1/3] - in /continuum/trunk: ./ continuum-api/src/main/java/org/apache/continuum/buildmanager/ continuum-api/src/main/java/org/apache/continuum/buildqueue/ continuum-api/src/main/java/org/apache/continuum/configuration/ continuum-ap...
Date Tue, 13 Jan 2009 11:05:10 GMT
Author: oching
Date: Tue Jan 13 03:00:41 2009
New Revision: 734099

URL: http://svn.apache.org/viewvc?rev=734099&view=rev
Log:
merge from parallel builds branch -r 722321:734072 to trunk

Added:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/buildmanager/
      - copied from r734072, continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildmanager/
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildManagerException.java
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildManagerException.java
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/buildqueue/
      - copied from r734072, continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildqueue/
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/buildqueue/BuildQueueService.java
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildqueue/BuildQueueService.java
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/buildqueue/BuildQueueServiceException.java
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildqueue/BuildQueueServiceException.java
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/BuildQueueDao.java
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/dao/BuildQueueDao.java
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/OverallBuildQueue.java
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/OverallBuildQueue.java
    continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/buildqueue/
      - copied from r734072, continuum/branches/continuum-parallel-builds/continuum-commons/src/main/java/org/apache/continuum/buildqueue/
    continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/buildqueue/DefaultBuildQueueService.java
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-commons/src/main/java/org/apache/continuum/buildqueue/DefaultBuildQueueService.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/buildmanager/
      - copied from r734072, continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueue.java
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueue.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueueexecutor/
      - copied from r734072, continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueueexecutor/
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueueexecutor/ParallelBuildsThreadedTaskQueueExecutor.java
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueueexecutor/ParallelBuildsThreadedTaskQueueExecutor.java
    continuum/trunk/continuum-core/src/test/java/org/apache/continuum/buildmanager/
      - copied from r734072, continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/
    continuum/trunk/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
    continuum/trunk/continuum-core/src/test/java/org/apache/continuum/taskqueue/
    continuum/trunk/continuum-core/src/test/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueueTest.java
    continuum/trunk/continuum-docs/src/site/apt/administrator_guides/parallelBuilds.apt
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-docs/src/site/apt/administrator_guides/parallelBuilds.apt
    continuum/trunk/continuum-docs/src/site/resources/images/addBuildQueue.png
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-docs/src/site/resources/images/addBuildQueue.png
    continuum/trunk/continuum-docs/src/site/resources/images/allowedBuildQueue.png
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-docs/src/site/resources/images/allowedBuildQueue.png
    continuum/trunk/continuum-docs/src/site/resources/images/buildQueue.png
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-docs/src/site/resources/images/buildQueue.png
    continuum/trunk/continuum-docs/src/site/resources/images/listBuildQueue.png
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-docs/src/site/resources/images/listBuildQueue.png
    continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/BuildQueueDaoImpl.java
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-store/src/main/java/org/apache/continuum/dao/BuildQueueDaoImpl.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildQueueAction.java
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildQueueAction.java
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editParallelBuilds.jsp
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editParallelBuilds.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/parallelbuilds.jsp
      - copied unchanged from r734072, continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/parallelbuilds.jsp
Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
    continuum/trunk/continuum-base/continuum-configuration/pom.xml
    continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
    continuum/trunk/continuum-base/continuum-configuration/src/main/mdo/continuum-configuration.xml
    continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
    continuum/trunk/continuum-commons/src/main/resources/META-INF/spring-context.xml
    continuum/trunk/continuum-core/pom.xml
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
    continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
    continuum/trunk/continuum-core/src/main/resources/META-INF/spring-context.xml
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
    continuum/trunk/continuum-docs/src/site/apt/administrator_guides/index.apt
    continuum/trunk/continuum-docs/src/site/site.xml
    continuum/trunk/continuum-model/pom.xml
    continuum/trunk/continuum-model/src/main/mdo/continuum.xml
    continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/configuration/ConfigurationServiceMock.java
    continuum/trunk/continuum-webapp/pom.xml
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/startup/ContinuumStartup.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractBuildAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/CancelBuildAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ScheduleAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigurationAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
    continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    continuum/trunk/continuum-webapp/src/main/resources/struts.xml
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/buildQueueView.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/configuration.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/configurationEdit.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/editSchedule.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/navigations/Menu.jsp
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
    continuum/trunk/pom.xml

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java?rev=734099&r1=734098&r2=734099&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java Tue Jan 13 03:00:41 2009
@@ -41,6 +41,8 @@
     private ProxyConfiguration proxyConfiguration;
     
     private File releaseOutputDirectory;
+    
+    private int numberOfBuildsInParallel = 1;
 
     public GeneralConfiguration()
     {
@@ -113,4 +115,13 @@
         this.releaseOutputDirectory = releaseOutputDirectory;
     }
 
+    public int getNumberOfBuildsInParallel()
+    {
+        return numberOfBuildsInParallel;
+    }
+
+    public void setNumberOfBuildsInParallel( int numberOfBuildsInParallel )
+    {
+        this.numberOfBuildsInParallel = numberOfBuildsInParallel;
+    }
 }

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java?rev=734099&r1=734098&r2=734099&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java Tue Jan 13 03:00:41 2009
@@ -1,68 +1,35 @@
 package org.apache.continuum.taskqueue.manager;
 
-import java.util.List;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 
-import org.apache.maven.continuum.buildqueue.BuildProjectTask;
-import org.codehaus.plexus.taskqueue.TaskQueue;
-import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
+import org.codehaus.plexus.taskqueue.TaskQueue;;
 
 /**
  * @author <a href="mailto:ctan@apache.org">Maria Catherine Tan</a>
  */
 public interface TaskQueueManager
-{
+{            
     String ROLE = TaskQueueManager.class.getName();
-
-    boolean buildInProgress()
-        throws TaskQueueManagerException;
-
-    void cancelBuildTask( int projectId )
-        throws TaskQueueManagerException;
-
-    boolean cancelCheckout( int projectId )
-        throws TaskQueueManagerException;
-
-    boolean cancelCurrentBuild()
-        throws TaskQueueManagerException;
-
-    TaskQueue getBuildQueue();
-
-    TaskQueueExecutor getBuildTaskQueueExecutor()
-        throws TaskQueueManagerException;
-
-    TaskQueue getCheckoutQueue();
-
-    List /* CheckOutTask */getCheckOutTasksInQueue()
-        throws TaskQueueManagerException;
-
-    int getCurrentProjectIdBuilding()
-        throws TaskQueueManagerException;
-
-    TaskQueue getPrepareBuildQueue();
-
-    TaskQueueExecutor getPrepareBuildTaskQueueExecutor()
-        throws TaskQueueManagerException;
-
-    public List<BuildProjectTask> getProjectsInBuildQueue()
-        throws TaskQueueManagerException;
-
+    
     TaskQueue getPurgeQueue();
 
-    boolean isInBuildingQueue( int projectId )
-        throws TaskQueueManagerException;
-
-    boolean isInBuildingQueue( int projectId, int buildDefinitionId )
-        throws TaskQueueManagerException;
-
-    boolean isInCheckoutQueue( int projectId )
-        throws TaskQueueManagerException;
-
-    boolean isInCurrentPrepareBuildTask( int projectId )
-        throws TaskQueueManagerException;
-
-    boolean isInPrepareBuildQueue( int projectId )
-        throws TaskQueueManagerException;
-
     boolean isInPurgeQueue( int purgeConfigurationId )
         throws TaskQueueManagerException;
 
@@ -86,15 +53,19 @@
     boolean isRepositoryInUse( int repositoryId )
         throws TaskQueueManagerException;
 
+    /**
+     * Check whether a project is in the release stage based on the given releaseId.
+     * 
+     * @param releaseId
+     * @return
+     * @throws TaskQueueManagerException
+     */
+    boolean isProjectInReleaseStage( String releaseId )
+        throws TaskQueueManagerException;        
+    
     boolean releaseInProgress()
         throws TaskQueueManagerException;
-
-    boolean removeFromBuildingQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
-        throws TaskQueueManagerException;
-
-    boolean removeFromPrepareBuildQueue( int projectGroupId, String scmRootAddress )
-        throws TaskQueueManagerException;
-
+    
     /**
      * Remove local repository from the purge queue
      * 
@@ -115,25 +86,6 @@
     boolean removeFromPurgeQueue( int[] purgeConfigIds )
         throws TaskQueueManagerException;
 
-    boolean removeProjectFromBuildingQueue( int projectId )
-        throws TaskQueueManagerException;
-
-    boolean removeProjectsFromBuildingQueue( int[] projectsId )
-        throws TaskQueueManagerException;
-
-    /**
-     * @param hashCodes BuildProjectTask hashCodes
-     * @throws TaskQueueManagerException
-     */
-    void removeProjectsFromBuildingQueueWithHashCodes( int[] hashCodes )
-        throws TaskQueueManagerException;
-
-    boolean removeProjectFromCheckoutQueue( int projectId )
-        throws TaskQueueManagerException;
-
-    boolean removeProjectsFromCheckoutQueue( int[] projectId )
-        throws TaskQueueManagerException;
-
     /**
      * Remove local repository from the purge queue
      * 
@@ -142,11 +94,4 @@
      */
     void removeRepositoryFromPurgeQueue( int repositoryId )
         throws TaskQueueManagerException;
-
-    /**
-     * @param hashCodes CheckOutTask hashCodes
-     * @throws TaskQueueManagerException
-     */
-    void removeTasksFromCheckoutQueueWithHashCodes( int[] hashCodes )
-        throws TaskQueueManagerException;
 }

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=734099&r1=734098&r2=734099&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java Tue Jan 13 03:00:41 2009
@@ -24,6 +24,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.continuum.buildmanager.BuildsManager;
 import org.apache.continuum.model.release.ContinuumReleaseResult;
 import org.apache.continuum.model.project.ProjectScmRoot;
 import org.apache.continuum.purge.ContinuumPurgeManager;
@@ -31,10 +32,10 @@
 import org.apache.continuum.repository.RepositoryService;
 import org.apache.continuum.taskqueue.manager.TaskQueueManager;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
-import org.apache.maven.continuum.buildqueue.BuildProjectTask;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.installation.InstallationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -44,7 +45,6 @@
 import org.apache.maven.continuum.profile.ProfileService;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.continuum.release.ContinuumReleaseManager;
-import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
 import org.codehaus.plexus.util.dag.CycleDetectedException;
 
 /**
@@ -630,6 +630,33 @@
     // ----------------------------------------------------------------------
     TaskQueueManager getTaskQueueManager();
 
+    // ----------------------------------------------------------------------
+    // Builds Manager
+    // ----------------------------------------------------------------------
+    BuildsManager getBuildsManager();    
+    
+    // ----------------------------------------------------------------------
+    // Build Queue
+    // ----------------------------------------------------------------------
+    
+    BuildQueue addBuildQueue( BuildQueue buildQueue )
+        throws ContinuumException;
+
+    BuildQueue getBuildQueue( int buildQueueId )
+        throws ContinuumException;
+
+    BuildQueue getBuildQueueByName( String buildQueueName )
+        throws ContinuumException;
+
+    void removeBuildQueue( BuildQueue buildQueue )
+        throws ContinuumException;
+
+    BuildQueue storeBuildQueue( BuildQueue buildQueue )
+        throws ContinuumException;
+
+    List<BuildQueue> getAllBuildQueues()
+        throws ContinuumException;
+    
     public void startup()
         throws ContinuumException;
     

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java?rev=734099&r1=734098&r2=734099&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java Tue Jan 13 03:00:41 2009
@@ -19,7 +19,9 @@
  * under the License.
  */
 
+import org.apache.continuum.buildqueue.BuildQueueServiceException;
 import org.apache.continuum.configuration.ContinuumConfigurationException;
+import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 
@@ -34,6 +36,8 @@
     String ROLE = ConfigurationService.class.getName();
 
     public static final String DEFAULT_SCHEDULE_NAME = "DEFAULT_SCHEDULE";
+    
+    public static final String DEFAULT_BUILD_QUEUE_NAME = "DEFAULT_BUILD_QUEUE";
 
     // ----------------------------------------------------------------------
     //
@@ -83,6 +87,13 @@
 
     String getReleaseOutput( int projectGroupId, String releaseName )
         throws ConfigurationException;
+    
+    int getNumberOfBuildsInParallel();
+    
+    void setNumberOfBuildsInParallel( int num );
+    
+    BuildQueue getDefaultBuildQueue()
+        throws BuildQueueServiceException;
 
     // ----------------------------------------------------------------------
     //
@@ -103,5 +114,5 @@
         throws ConfigurationStoringException, ContinuumConfigurationException;
 
     Schedule getDefaultSchedule()
-        throws ContinuumStoreException, ConfigurationLoadingException, ContinuumConfigurationException;
+        throws ContinuumStoreException, ConfigurationLoadingException, ContinuumConfigurationException, BuildQueueServiceException;
 }

Modified: continuum/trunk/continuum-base/continuum-configuration/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/pom.xml?rev=734099&r1=734098&r2=734099&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/pom.xml (original)
+++ continuum/trunk/continuum-base/continuum-configuration/pom.xml Tue Jan 13 03:00:41 2009
@@ -35,7 +35,7 @@
           <models>
             <model>src/main/mdo/continuum-configuration.xml</model>
           </models>
-          <version>1.0.0</version>
+          <version>1.1.0</version>
         </configuration>
         <executions>
           <execution>
@@ -101,6 +101,19 @@
       <groupId>org.apache.continuum</groupId>
       <artifactId>continuum-test</artifactId>
       <scope>test</scope>
+    </dependency>
+    <dependency> <!-- added since depMgt doesn't override imported dependencies -->
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus.registry</groupId>
+      <artifactId>plexus-registry-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus.registry</groupId>
+      <artifactId>plexus-registry-commons</artifactId>
+      <scope>runtime</scope>
     </dependency>        
   </dependencies>
 </project>

Modified: continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java?rev=734099&r1=734098&r2=734099&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java (original)
+++ continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java Tue Jan 13 03:00:41 2009
@@ -29,6 +29,7 @@
 import org.apache.continuum.configuration.model.ContinuumConfigurationModel;
 import org.apache.continuum.configuration.model.io.xpp3.ContinuumConfigurationModelXpp3Reader;
 import org.apache.continuum.configuration.model.io.xpp3.ContinuumConfigurationModelXpp3Writer;
+import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -40,12 +41,14 @@
  */
 public class DefaultContinuumConfiguration
     implements ContinuumConfiguration
-{
+{ 
     private Logger log = LoggerFactory.getLogger( getClass() );
 
     private File configurationFile;
 
     private GeneralConfiguration generalConfiguration;
+    
+    public static final String CONFIGURATION_FILE = "continuum.xml";
 
     //----------------------------------------------------
     //  Initialize method configured in the Spring xml 
@@ -117,6 +120,8 @@
                 .read( new InputStreamReader( new FileInputStream( file ) ) );
 
             this.generalConfiguration = new GeneralConfiguration();
+            
+            this.generalConfiguration.setNumberOfBuildsInParallel( configuration.getNumberOfBuildsInParallel() );
             this.generalConfiguration.setBaseUrl( configuration.getBaseUrl() );
             if ( StringUtils.isNotEmpty( configuration.getBuildOutputDirectory() ) )
             {
@@ -149,6 +154,7 @@
                 this.generalConfiguration.setReleaseOutputDirectory( new File( configuration
                     .getReleaseOutputDirectory() ) );
             }
+            
         }
         catch ( IOException e )
         {
@@ -170,12 +176,15 @@
         {
             ContinuumConfigurationModel configurationModel = new ContinuumConfigurationModel();
             configurationModel.setBaseUrl( this.generalConfiguration.getBaseUrl() );
+            configurationModel.setNumberOfBuildsInParallel( this.generalConfiguration.getNumberOfBuildsInParallel() );
+                        
             // normally not null but NPE free is better !
             if ( this.generalConfiguration.getBuildOutputDirectory() != null )
             {
                 configurationModel.setBuildOutputDirectory( this.generalConfiguration.getBuildOutputDirectory()
-                    .getPath() );
+                    .getPath() );                
             }
+                        
             if ( this.generalConfiguration.getWorkingDirectory() != null )
             {
                 configurationModel.setWorkingDirectory( this.generalConfiguration.getWorkingDirectory().getPath() );
@@ -208,7 +217,7 @@
                 configurationModel.setReleaseOutputDirectory( this.generalConfiguration.getReleaseOutputDirectory()
                     .getPath() );
             }
-
+            
             ContinuumConfigurationModelXpp3Writer writer = new ContinuumConfigurationModelXpp3Writer();
             FileWriter fileWriter = new FileWriter( file );
             writer.write( fileWriter, configurationModel );
@@ -225,7 +234,7 @@
     //  Spring injection
     // ----------------------------------------
 
-
+    
     public File getConfigurationFile()
     {
         return configurationFile;

Modified: continuum/trunk/continuum-base/continuum-configuration/src/main/mdo/continuum-configuration.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/src/main/mdo/continuum-configuration.xml?rev=734099&r1=734098&r2=734099&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/src/main/mdo/continuum-configuration.xml (original)
+++ continuum/trunk/continuum-base/continuum-configuration/src/main/mdo/continuum-configuration.xml Tue Jan 13 03:00:41 2009
@@ -31,31 +31,31 @@
   <classes>
     <class rootElement="true" xml.tagName="continuum-configuration">
       <name>ContinuumConfigurationModel</name>
-      <version>1.0.0+</version>
+      <version>1.1.0+</version>
       <fields>
         <field>
           <name>baseUrl</name>
-          <version>1.0.0+</version>
+          <version>1.1.0+</version>
           <type>String</type>
         </field>
         <field>
           <name>buildOutputDirectory</name>
-          <version>1.0.0+</version>
+          <version>1.1.0+</version>
           <type>String</type>
         </field>
         <field>
           <name>deploymentRepositoryDirectory</name>
-          <version>1.0.0+</version>
+          <version>1.1.0+</version>
           <type>String</type>
         </field>   
         <field>
           <name>workingDirectory</name>
-          <version>1.0.0+</version>
+          <version>1.1.0+</version>
           <type>String</type>
         </field>
         <field>
           <name>proxyConfiguration</name>
-          <version>1.0.0+</version>
+          <version>1.1.0+</version>
           <association>
             <type>ProxyConfiguration</type>
             <multiplicity>1</multiplicity>
@@ -63,33 +63,38 @@
         </field>     
         <field>
           <name>releaseOutputDirectory</name>
-          <version>1.0.0+</version>
+          <version>1.1.0+</version>
           <type>String</type>
-        </field>                
+        </field>    
+        <field>
+          <name>numberOfBuildsInParallel</name>
+          <version>1.1.0+</version>
+          <type>int</type>
+        </field>            
       </fields>
     </class>
     <class xml.tagName="proxy-configuration">
       <name>ProxyConfiguration</name>
-      <version>1.0.0+</version>
+      <version>1.1.0+</version>
       <fields>
         <field>
           <name>proxyHost</name>
-          <version>1.0.0+</version>
+          <version>1.1.0+</version>
           <type>String</type>
         </field>
         <field>
           <name>proxyPort</name>
-          <version>1.0.0+</version>
+          <version>1.1.0+</version>
           <type>int</type>
         </field>
         <field>
           <name>proxyUser</name>
-          <version>1.0.0+</version>
+          <version>1.1.0+</version>
           <type>String</type>
         </field>   
         <field>
           <name>proxyPassword</name>
-          <version>1.0.0+</version>
+          <version>1.1.0+</version>
           <type>String</type>
         </field>                     
       </fields>

Modified: continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java?rev=734099&r1=734098&r2=734099&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java (original)
+++ continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java Tue Jan 13 03:00:41 2009
@@ -19,11 +19,14 @@
  * under the License.
  */
 
+import org.apache.continuum.buildqueue.BuildQueueService;
+import org.apache.continuum.buildqueue.BuildQueueServiceException;
 import org.apache.continuum.configuration.ContinuumConfiguration;
 import org.apache.continuum.configuration.ContinuumConfigurationException;
 import org.apache.continuum.configuration.GeneralConfiguration;
 import org.apache.continuum.dao.ScheduleDao;
 import org.apache.continuum.dao.SystemConfigurationDao;
+import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.model.system.SystemConfiguration;
 import org.apache.maven.continuum.store.ContinuumStoreException;
@@ -46,7 +49,7 @@
 {
     private Logger log = LoggerFactory.getLogger( this.getClass() );
 
-    // when adding requirement the template in application.xml must be updated CONTINUUM-1207
+    // when adding a requirement, the template in spring-context.xml must be updated CONTINUUM-1207
 
     /**
      * @plexus.configuration default-value="${plexus.home}"
@@ -58,6 +61,9 @@
 
     @Resource
     private SystemConfigurationDao systemConfigurationDao;
+        
+    @Resource
+    private BuildQueueService buildQueueService;
 
     @Resource
     private ContinuumConfiguration configuration;
@@ -91,7 +97,17 @@
     {
         this.scheduleDao = scheduleDao;
     }
+    
+    public BuildQueueService getBuildQueueService()
+    {
+        return buildQueueService;
+    }
 
+    public void setBuildQueueService( BuildQueueService buildQueueService )
+    {
+        this.buildQueueService = buildQueueService;
+    }
+    
     public SystemConfigurationDao getSystemConfigurationDao()
     {
         return systemConfigurationDao;
@@ -376,7 +392,17 @@
             return null;
         }
     }
-
+    
+    public int getNumberOfBuildsInParallel()
+    {
+        return generalConfiguration.getNumberOfBuildsInParallel();
+    }
+    
+    public void setNumberOfBuildsInParallel( int num )
+    {
+        generalConfiguration.setNumberOfBuildsInParallel( num );
+    }
+    
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -467,7 +493,7 @@
     }
 
     public Schedule getDefaultSchedule()
-        throws ContinuumStoreException, ConfigurationLoadingException, ContinuumConfigurationException
+        throws ContinuumStoreException, ConfigurationLoadingException, ContinuumConfigurationException, BuildQueueServiceException
     {
         // Schedule
         Schedule defaultSchedule = scheduleDao.getScheduleByName( DEFAULT_SCHEDULE_NAME );
@@ -481,13 +507,28 @@
 
         return defaultSchedule;
     }
-
+    
+    public BuildQueue getDefaultBuildQueue()
+        throws BuildQueueServiceException
+    {     
+        BuildQueue defaultBuildQueue = buildQueueService.getBuildQueueByName( DEFAULT_BUILD_QUEUE_NAME );
+    
+        if ( defaultBuildQueue == null )
+        {
+            defaultBuildQueue = createDefaultBuildQueue();
+            
+            defaultBuildQueue = buildQueueService.addBuildQueue( defaultBuildQueue );
+        }
+    
+        return defaultBuildQueue;
+    }
+    
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
 
     private Schedule createDefaultSchedule()
-        throws ConfigurationLoadingException, ContinuumConfigurationException
+        throws ConfigurationLoadingException, ContinuumConfigurationException, ContinuumStoreException, BuildQueueServiceException
     {
 
         log.info( "create Default Schedule" );
@@ -507,8 +548,22 @@
         schedule.setCronExpression( systemConf.getDefaultScheduleCronExpression() );
 
         schedule.setActive( true );
+        
+        BuildQueue buildQueue = getDefaultBuildQueue();
+        
+        schedule.addBuildQueue( buildQueue );
 
         return schedule;
     }
-
+    
+    private BuildQueue createDefaultBuildQueue()
+    {
+        log.info( "create Default Build Queue" );
+        
+        BuildQueue buildQueue = new BuildQueue();
+        
+        buildQueue.setName( DEFAULT_BUILD_QUEUE_NAME );        
+        
+        return buildQueue;
+    }
 }

Modified: continuum/trunk/continuum-commons/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/main/resources/META-INF/spring-context.xml?rev=734099&r1=734098&r2=734099&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/main/resources/META-INF/spring-context.xml (original)
+++ continuum/trunk/continuum-commons/src/main/resources/META-INF/spring-context.xml Tue Jan 13 03:00:41 2009
@@ -36,5 +36,6 @@
         init-method="initialize">
     <property name="applicationHome" value="data"/>
   </bean> 
-  <bean id="shellCommandHelper" class="org.apache.continuum.utils.shell.DefaultShellCommandHelper"/>  
+  <bean id="shellCommandHelper" class="org.apache.continuum.utils.shell.DefaultShellCommandHelper"/>
+  <bean id="buildQueueService" class="org.apache.continuum.buildqueue.DefaultBuildQueueService"/>
 </beans>
\ No newline at end of file

Modified: continuum/trunk/continuum-core/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/pom.xml?rev=734099&r1=734098&r2=734099&view=diff
==============================================================================
--- continuum/trunk/continuum-core/pom.xml (original)
+++ continuum/trunk/continuum-core/pom.xml Tue Jan 13 03:00:41 2009
@@ -130,6 +130,10 @@
       <artifactId>jpox</artifactId>
     </dependency>
     <dependency>
+      <groupId>javax.annotation</groupId>
+      <artifactId>jsr250-api</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.continuum</groupId>
       <artifactId>continuum-store</artifactId>
     </dependency>
@@ -255,6 +259,21 @@
       <artifactId>jmock-junit3</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.jmock</groupId>
+      <artifactId>jmock-legacy</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>cglib</groupId>
+      <artifactId>cglib-nodep</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.objenesis</groupId>
+      <artifactId>objenesis</artifactId>    
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java?rev=734099&r1=734098&r2=734099&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java Tue Jan 13 03:00:41 2009
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.buildmanager.BuildsManager;
 import org.apache.continuum.dao.ProjectDao;
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.LocalRepository;
@@ -27,11 +28,6 @@
 import org.apache.continuum.taskqueue.manager.TaskQueueManager;
 import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
 import org.apache.maven.continuum.model.project.Schedule;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.context.Context;
-import org.codehaus.plexus.context.ContextException;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
 
 import java.util.List;
@@ -62,6 +58,11 @@
      */
     private TaskQueueManager taskQueueManager;
     
+    /**
+     * @plexus.requirement role-hint="parallel"
+     */
+    private BuildsManager parallelBuildsManager;
+    
     public void purge( Schedule schedule )
         throws ContinuumPurgeManagerException
     {
@@ -129,7 +130,7 @@
             else if ( "buildOutput".equals( dirPurge.getDirectoryType() ) )
             {
                 // do not purge if build in progress
-                if ( !taskQueueManager.buildInProgress() && 
+                if ( !parallelBuildsManager.isBuildInProgress() && 
                      !taskQueueManager.isInPurgeQueue( dirPurge.getId() ) )
                 {
                     taskQueueManager.getPurgeQueue().put( new PurgeTask( dirPurge.getId() ) );

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java?rev=734099&r1=734098&r2=734099&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java Tue Jan 13 03:00:41 2009
@@ -21,22 +21,17 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 import org.apache.commons.lang.ArrayUtils;
-import org.apache.continuum.dao.BuildDefinitionDao;
 import org.apache.continuum.dao.ProjectDao;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.continuum.purge.PurgeConfigurationService;
 import org.apache.continuum.purge.task.PurgeTask;
 import org.apache.maven.continuum.buildqueue.BuildProjectTask;
-import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.release.tasks.PerformReleaseProjectTask;
-import org.apache.maven.continuum.scm.queue.CheckOutTask;
-import org.apache.maven.continuum.scm.queue.PrepareBuildProjectsTask;
+import org.apache.maven.continuum.release.tasks.PrepareReleaseProjectTask;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.codehaus.plexus.PlexusConstants;
 import org.codehaus.plexus.PlexusContainer;
@@ -48,7 +43,6 @@
 import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
 import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
-import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -59,22 +53,7 @@
 public class DefaultTaskQueueManager
     implements TaskQueueManager, Contextualizable
 {
-    private Logger log = LoggerFactory.getLogger( DefaultTaskQueueManager.class );
-
-    /**
-     * @plexus.requirement role-hint="build-project"
-     */
-    private TaskQueue buildQueue;
-
-    /**
-     * @plexus.requirement role-hint="check-out-project"
-     */
-    private TaskQueue checkoutQueue;
-
-    /**
-     * @plexus.requirement role-hint="prepare-build-project"
-     */
-    private TaskQueue prepareBuildQueue;
+	private Logger log = LoggerFactory.getLogger( DefaultTaskQueueManager.class );
 
     /**
      * @plexus.requirement role-hint="purge"
@@ -82,9 +61,14 @@
     private TaskQueue purgeQueue;
     
     /**
-     * @plexus.requirement
+     * @plexus.requirement role-hint="prepare-release"
+     */
+    private TaskQueue prepareReleaseQueue;
+    
+    /**
+     * @plexus.requirement role-hint="perform-release"
      */
-    private BuildDefinitionDao buildDefinitionDao;
+    private TaskQueue performReleaseQueue;
     
     /**
      * @plexus.requirement
@@ -98,311 +82,10 @@
     
     private PlexusContainer container;
 
-    public boolean buildInProgress()
-        throws TaskQueueManagerException
-    {
-        Task task = getCurrentTask( "build-project" );
-    
-        if ( task != null && task instanceof BuildProjectTask )
-        {
-            return true;
-        }
-    
-        return false;
-    }
-    
-    public void cancelBuildTask( int projectId )
-        throws TaskQueueManagerException
-    {
-        Task currentTask = getBuildTaskQueueExecutor().getCurrentTask();
-        
-        if ( currentTask != null )
-        {
-            if ( currentTask instanceof BuildProjectTask )
-            {
-                if ( ( (BuildProjectTask) currentTask ).getProjectId() == projectId )
-                {
-                    log.info( "Cancelling task for project " + projectId );
-                    getBuildTaskQueueExecutor().cancelTask( currentTask );
-                }
-                else
-                {
-                    log.warn( "Current task is not for the given projectId (" + projectId + "): "
-                                          + ( (BuildProjectTask) currentTask ).getProjectId() + "; not cancelling" );
-                }
-            }
-            else
-            {
-                log.warn( "Current task not a BuildProjectTask - not cancelling" );
-            }
-        }
-        else
-        {
-            log.warn( "No task running - not cancelling" );
-        }
-    }
-
-    public boolean cancelCheckout( int projectId )
-        throws TaskQueueManagerException
-    {
-        Task task = getCheckoutTaskQueueExecutor().getCurrentTask();
-
-        if ( task != null )
-        {
-            if ( task instanceof CheckOutTask )
-            {
-                if ( ( (CheckOutTask) task ).getProjectId() == projectId )
-                {
-                    log.info( "Cancelling checkout for project " + projectId );
-                    return getCheckoutTaskQueueExecutor().cancelTask( task );
-                }
-                else
-                {
-                    log.warn( "Current task is not for the given projectId (" + projectId + "): "
-                                          + ( (CheckOutTask) task ).getProjectId() + "; not cancelling checkout" );
-                }
-            }
-            else
-            {
-                log.warn( "Current task not a CheckOutTask - not cancelling checkout" );
-            }
-        }
-        else
-        {
-            log.warn( "No task running - not cancelling checkout" );
-        }
-        return false;
-    }
-
-    public boolean cancelCurrentBuild()
-        throws TaskQueueManagerException
-    {
-        Task task = getBuildTaskQueueExecutor().getCurrentTask();
-        
-        if ( task != null )
-        {
-            if ( task instanceof BuildProjectTask )
-            {
-                log.info( "Cancelling current build task" );
-                return getBuildTaskQueueExecutor().cancelTask( task );
-            }
-            else
-            {
-                log.warn( "Current task not a BuildProjectTask - not cancelling" );
-            }
-        }
-        else
-        {
-            log.warn( "No task running - not cancelling" );
-        }
-        return false;
-    }
-
-    public TaskQueue getBuildQueue()
-    {
-        return buildQueue;
-    }
-
-    public TaskQueueExecutor getBuildTaskQueueExecutor()
-        throws TaskQueueManagerException
-    {
-        try
-        {
-            return (TaskQueueExecutor) container.lookup( TaskQueueExecutor.class, "build-project" );
-        }
-        catch ( ComponentLookupException e )
-        {
-            throw new TaskQueueManagerException( e.getMessage(), e );
-        }
-    }
-
-    public TaskQueueExecutor getCheckoutTaskQueueExecutor()
-        throws TaskQueueManagerException
-    {
-        try
-        {
-            return (TaskQueueExecutor) container.lookup( TaskQueueExecutor.class, "check-out-project" );
-        }
-        catch ( ComponentLookupException e )
-        {
-            throw new TaskQueueManagerException( e.getMessage(), e );
-        }
-    }
-
-    public TaskQueue getCheckoutQueue()
-    {
-        return checkoutQueue;
-    }
-    
-    public List<CheckOutTask> getCheckOutTasksInQueue()
-        throws TaskQueueManagerException
-    {
-        try
-        {
-            return checkoutQueue.getQueueSnapshot();
-        }
-        catch ( TaskQueueException e )
-        {
-            throw new TaskQueueManagerException( "Error while getting the checkout queue.", e );
-        }
-    }
-
-    public int getCurrentProjectIdBuilding()
-        throws TaskQueueManagerException
-    {
-        Task task = getBuildTaskQueueExecutor().getCurrentTask();
-        if ( task != null )
-        {
-            if ( task instanceof BuildProjectTask )
-            {
-                return ( (BuildProjectTask) task ).getProjectId();
-            }
-        }
-        return -1;
-    }
-
-    public TaskQueue getPrepareBuildQueue()
-    {
-        return prepareBuildQueue;
-    }   
-
-    public TaskQueueExecutor getPrepareBuildTaskQueueExecutor()
-        throws TaskQueueManagerException
-    {
-        try
-        {
-            return (TaskQueueExecutor) container.lookup( TaskQueueExecutor.class, "prepare-build-project" );
-        }
-        catch ( ComponentLookupException e )
-        {
-            throw new TaskQueueManagerException( e.getMessage(), e );
-        }
-    }
-
-    public List<BuildProjectTask> getProjectsInBuildQueue()
-        throws TaskQueueManagerException
-    {
-        try
-        {
-            return buildQueue.getQueueSnapshot();
-        }
-        catch ( TaskQueueException e )
-        {
-            throw new TaskQueueManagerException( "Error while getting the building queue.", e );
-        }
-    }
-    
     public TaskQueue getPurgeQueue()
     {
         return purgeQueue;
-    }
-    
-    public boolean isInBuildingQueue( int projectId )
-        throws TaskQueueManagerException
-    {
-        return isInBuildingQueue( projectId, -1 );
-    }
-    
-    public boolean isInBuildingQueue( int projectId, int buildDefinitionId )
-        throws TaskQueueManagerException
-    {
-        List<BuildProjectTask> queue = getProjectsInBuildQueue();
-    
-        for ( BuildProjectTask task : queue )
-        {
-            if ( task != null )
-            {
-                if ( buildDefinitionId < 0 )
-                {
-                    if ( task.getProjectId() == projectId )
-                    {
-                        return true;
-                    }
-                }
-                else
-                {
-                    if ( task.getProjectId() == projectId && task.getBuildDefinitionId() == buildDefinitionId )
-                    {
-                        return true;
-                    }
-                }
-            }
-        }
-    
-        return false;
-    }
-    
-    public boolean isInCheckoutQueue( int projectId )
-        throws TaskQueueManagerException
-    {
-        List<CheckOutTask> queue = getCheckOutTasksInQueue();
-    
-        for ( CheckOutTask task : queue )
-        {
-            if ( task != null && task.getProjectId() == projectId )
-            {
-                return true;
-            }
-        }
-    
-        return false;
-    }
-
-    public boolean isInCurrentPrepareBuildTask( int projectId )
-        throws TaskQueueManagerException
-    {
-        Task task = getPrepareBuildTaskQueueExecutor().getCurrentTask();
-
-        if ( task != null &&  task instanceof PrepareBuildProjectsTask )
-        {
-            Map<Integer, Integer> map = ( (PrepareBuildProjectsTask) task).getProjectsBuildDefinitionsMap();
-            
-            if ( map.size() > 0 )
-            {
-                Set<Integer> projectIds = map.keySet();
-                
-                if ( projectIds.contains( new Integer( projectId ) ) )
-                {
-                    return true;
-                }
-            }
-        }
-        
-        return false;
-    }
-    
-    public boolean isInPrepareBuildQueue( int projectId )
-        throws TaskQueueManagerException
-    {
-        try
-        {
-            List<PrepareBuildProjectsTask> queue = prepareBuildQueue.getQueueSnapshot();
-            
-            for ( PrepareBuildProjectsTask task : queue )
-            {
-                if ( task != null )
-                {
-                    Map<Integer, Integer> map = ( (PrepareBuildProjectsTask) task).getProjectsBuildDefinitionsMap();
-                    
-                    if ( map.size() > 0 )
-                    {
-                        Set<Integer> projectIds = map.keySet();
-                        
-                        if ( projectIds.contains( new Integer( projectId ) ) )
-                        {
-                            return true;
-                        }
-                    }
-                }
-            }
-            
-            return false;
-        }
-        catch ( TaskQueueException e )
-        {
-            throw new TaskQueueManagerException( "Error while getting the tasks in prepare build queue", e );
-        }
-    }
+    }    
     
     public boolean isInPurgeQueue( int purgeConfigId )
         throws TaskQueueManagerException
@@ -461,6 +144,68 @@
             throw new TaskQueueManagerException( e.getMessage(), e );
         }
     }
+    
+    public boolean isProjectInReleaseStage( String releaseId )
+        throws TaskQueueManagerException
+    {
+        Task prepareTask = getCurrentTask( "prepare-release" );        
+        if( prepareTask != null && prepareTask instanceof PrepareReleaseProjectTask )
+        {
+            if( ( ( PrepareReleaseProjectTask ) prepareTask ).getReleaseId().equals( releaseId ) )
+            {
+                return true;
+            }
+            else
+            {
+                try
+                {
+                    // check if in queue
+                    List<Task> tasks = prepareReleaseQueue.getQueueSnapshot();
+                    for( Task prepareReleaseTask : tasks )
+                    {
+                        if( ( ( PrepareReleaseProjectTask) prepareReleaseTask ).getReleaseId().equals( releaseId ) ) 
+                        {
+                            return true;
+                        }
+                    }
+                }
+                catch ( TaskQueueException e )
+                {
+                    throw new TaskQueueManagerException( e );
+                }
+            }
+        }
+        
+        Task performTask = getCurrentTask( "perform-release" );        
+        if( performTask != null && performTask instanceof PerformReleaseProjectTask )
+        {
+            if( ( ( PerformReleaseProjectTask ) performTask ).getReleaseId().equals( releaseId ) )
+            {
+                return true;
+            }
+            else
+            {
+                try
+                {
+                    // check if in queue
+                    List<Task> tasks = performReleaseQueue.getQueueSnapshot();
+                    for( Task performReleaseTask : tasks )
+                    {
+                        if( ( ( PerformReleaseProjectTask) performReleaseTask ).getReleaseId().equals( releaseId ) ) 
+                        {
+                            return true;
+                        }
+                    }
+                }
+                catch ( TaskQueueException e )
+                {
+                    throw new TaskQueueManagerException( e );
+                }
+            }
+        }
+                
+        return false;
+    }
 
     public boolean releaseInProgress()
         throws TaskQueueManagerException
@@ -475,30 +220,6 @@
         return false;
     }
 
-    public boolean removeFromBuildingQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
-        throws TaskQueueManagerException
-    {
-        BuildDefinition buildDefinition;
-        
-        try
-        {
-            buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
-        }
-        catch ( ContinuumStoreException e )
-        {
-            throw new TaskQueueManagerException( "Error while removing project from build queue: " + projectName, e );
-        }
-        
-        String buildDefinitionLabel = buildDefinition.getDescription();
-        if ( StringUtils.isEmpty( buildDefinitionLabel ) )
-        {
-            buildDefinitionLabel = buildDefinition.getGoals();
-        }
-        BuildProjectTask buildProjectTask =
-            new BuildProjectTask( projectId, buildDefinitionId, trigger, projectName, buildDefinitionLabel );
-        return this.buildQueue.remove( buildProjectTask );
-    }
-
     public boolean removeFromPurgeQueue( int purgeConfigId )
         throws TaskQueueManagerException
     {
@@ -514,7 +235,6 @@
         return false;
     }
 
-
     public boolean removeFromPurgeQueue( int[] purgeConfigIds )
         throws TaskQueueManagerException
     {
@@ -551,122 +271,6 @@
         return false;
     }
     
-    public boolean removeProjectsFromBuildingQueue( int[] projectsId )
-        throws TaskQueueManagerException
-    {
-        if ( projectsId == null )
-        {
-            return false;
-        }
-        if ( projectsId.length < 1 )
-        {
-            return false;
-        }
-        List<BuildProjectTask> queue = getProjectsInBuildQueue();
-    
-        List<BuildProjectTask> tasks = new ArrayList<BuildProjectTask>();
-    
-        for ( BuildProjectTask task : queue )
-        {
-            if ( task != null )
-            {
-                if ( ArrayUtils.contains( projectsId, task.getProjectId() ) )
-                {
-                    tasks.add( task );
-                }
-            }
-        }
-
-        for ( BuildProjectTask buildProjectTask : tasks )
-        {
-            log.info( "cancel build for project " + buildProjectTask.getProjectId() );
-        }
-        if ( !tasks.isEmpty() )
-        {
-            return buildQueue.removeAll( tasks );
-        }
-    
-        return false;
-    }
-    
-    public boolean removeProjectFromBuildingQueue( int projectId )
-        throws TaskQueueManagerException
-    {
-        List<BuildProjectTask> queue = getProjectsInBuildQueue();
-    
-        for ( BuildProjectTask task : queue )
-        {
-            if ( task != null && task.getProjectId() == projectId )
-            {
-                return buildQueue.remove( task );
-            }
-        }
-    
-        return false;
-    }
-    
-    public boolean removeProjectsFromCheckoutQueue( int[] projectsId )
-        throws TaskQueueManagerException
-    {
-        if ( projectsId == null )
-        {
-            return false;
-        }
-        if ( projectsId.length < 1 )
-        {
-            return false;
-        }
-        List<CheckOutTask> queue = getCheckOutTasksInQueue();
-    
-        List<CheckOutTask> tasks = new ArrayList<CheckOutTask>();
-    
-        for ( CheckOutTask task : queue )
-        {
-            if ( task != null )
-            {
-                if ( ArrayUtils.contains( projectsId, task.getProjectId() ) )
-                {
-                    tasks.add( task );
-                }
-            }
-        }
-        if ( !tasks.isEmpty() )
-        {
-            return checkoutQueue.removeAll( tasks );
-        }
-        return false;
-    }
-    
-    public void removeProjectsFromBuildingQueueWithHashCodes( int[] hashCodes )
-        throws TaskQueueManagerException
-    {
-        List<BuildProjectTask> queue = getProjectsInBuildQueue();
-    
-        for ( BuildProjectTask task : queue )
-        {
-            if ( ArrayUtils.contains( hashCodes, task.hashCode() ) )
-            {
-                buildQueue.remove( task );
-            }
-        }
-    }
-    
-    public boolean removeProjectFromCheckoutQueue( int projectId )
-        throws TaskQueueManagerException
-    {
-        List<CheckOutTask> queue = getCheckOutTasksInQueue();
-    
-        for ( CheckOutTask task : queue )
-        {
-            if ( task != null && task.getProjectId() == projectId )
-            {
-                return checkoutQueue.remove( task );
-            }
-        }
-    
-        return false;
-    }
-    
     public void removeRepositoryFromPurgeQueue( int repositoryId )
         throws TaskQueueManagerException
     {
@@ -678,42 +282,6 @@
             removeFromPurgeQueue( repoPurge.getId() );
         }
     }
-
-    public void removeTasksFromCheckoutQueueWithHashCodes( int[] hashCodes )
-        throws TaskQueueManagerException
-    {
-        List<CheckOutTask> queue = getCheckOutTasksInQueue();
-    
-        for ( CheckOutTask task : queue )
-        {
-            if ( ArrayUtils.contains( hashCodes, task.hashCode() ) )
-            {
-                checkoutQueue.remove( task );
-            }
-        }
-    }
-
-    public boolean removeFromPrepareBuildQueue( int projectGroupId, String scmRootAddress )
-        throws TaskQueueManagerException
-    {
-        try
-        {
-            List<PrepareBuildProjectsTask> queue = prepareBuildQueue.getQueueSnapshot();
-            
-            for ( PrepareBuildProjectsTask task : queue )
-            {
-                if ( task != null && task.getProjectGroupId() == projectGroupId && task.getScmRootAddress().equals( scmRootAddress ) )
-                {
-                    return prepareBuildQueue.remove( task );
-                }
-            }
-            return false;
-        }
-        catch ( TaskQueueException e )
-        {
-            throw new TaskQueueManagerException( "Error while getting the prepare build projects task in queue", e );
-        }
-    }
     
     public void contextualize( Context context )
         throws ContextException
@@ -746,5 +314,5 @@
         {
             throw new TaskQueueManagerException( "Unable to lookup current task", e );
         }
-    }
+    }    
 }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=734099&r1=734098&r2=734099&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java Tue Jan 13 03:00:41 2009
@@ -33,6 +33,10 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.continuum.buildmanager.BuildManagerException;
+import org.apache.continuum.buildmanager.BuildsManager;
+import org.apache.continuum.buildqueue.BuildQueueService;
+import org.apache.continuum.buildqueue.BuildQueueServiceException;
 import org.apache.continuum.configuration.ContinuumConfigurationException;
 import org.apache.continuum.dao.BuildDefinitionDao;
 import org.apache.continuum.dao.BuildResultDao;
@@ -66,6 +70,7 @@
 import org.apache.maven.continuum.installation.InstallationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
+import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -79,7 +84,6 @@
 import org.apache.maven.continuum.project.builder.maven.MavenOneContinuumProjectBuilder;
 import org.apache.maven.continuum.project.builder.maven.MavenTwoContinuumProjectBuilder;
 import org.apache.maven.continuum.release.ContinuumReleaseManager;
-import org.apache.maven.continuum.scm.queue.PrepareBuildProjectsTask;
 import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.apache.maven.continuum.utils.ContinuumUrlValidator;
@@ -98,7 +102,6 @@
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException;
-import org.codehaus.plexus.taskqueue.TaskQueueException;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.dag.CycleDetectedException;
@@ -222,7 +225,6 @@
 
     private PlexusContainer container;
 
-
     /**
      * @plexus.requirement role-hint="continuumUrl"
      */
@@ -249,6 +251,16 @@
      * @plexus.requirement
      */
     private TaskQueueManager taskQueueManager;
+    
+    /**
+     * @plexus.requirement role-hint="parallel"
+     */
+    private BuildsManager parallelBuildsManager;
+        
+    /**
+     * @plexus.requirement
+     */
+    private BuildQueueService buildQueueService;
 
     public DefaultContinuum()
     {
@@ -302,6 +314,11 @@
     {
         return purgeConfigurationService;
     }
+    
+    public BuildsManager getBuildsManager()
+    {
+        return parallelBuildsManager;
+    }
 
     // ----------------------------------------------------------------------
     // Project Groups
@@ -355,10 +372,35 @@
         ProjectGroup projectGroup = getProjectGroupWithProjects( projectGroupId );
 
         if ( projectGroup != null )
-        {
-            for ( Object o : projectGroup.getProjects() )
+        {   
+            List<Project> projects = projectGroup.getProjects();
+            int[] projectIds = new int[projects.size()];
+            
+            int idx = 0;
+            for( Project project : projects )
+            {
+                projectIds[idx] = project.getId();
+                idx++;
+            }
+            
+            // check if any project is still being checked out
+            // canceling the checkout and proceeding with the delete results to a cannot delete directory error!
+            try
+            {            
+                if( parallelBuildsManager.isAnyProjectCurrentlyBeingCheckedOut( projectIds ) )
+                {
+                    throw new ContinuumException(
+                                                  "Unable to delete group. At least one project in group is still being checked out." );
+                }
+            }
+            catch ( BuildManagerException e )
+            {
+                throw new ContinuumException( "Unable to delete group.", e );
+            }
+        
+            for ( int i = 0; i < projectIds.length; i++ )
             {
-                removeProject( ( (Project) o ).getId() );
+                removeProject( projectIds[i] );
             }
 
             List<ProjectScmRoot> projectScmRoots = getProjectScmRootByProjectGroup( projectGroupId );
@@ -605,24 +647,16 @@
             log.info( "Remove project " + project.getName() + "(" + projectId + ")" );
 
             try
-            {
-                if ( taskQueueManager.isInCheckoutQueue( projectId ) )
-                {
-                    taskQueueManager.removeProjectFromCheckoutQueue( projectId );
-                }
+            {                
+                parallelBuildsManager.removeProjectFromCheckoutQueue( projectId );
                 
-                if ( taskQueueManager.isInBuildingQueue( projectId ) )
-                {
-                    taskQueueManager.removeProjectFromBuildingQueue( projectId );
-                }
+                parallelBuildsManager.removeProjectFromBuildQueue( projectId );                
                 
-                // cancel if currently building
-                if ( taskQueueManager.getCurrentProjectIdBuilding() == projectId )
-                {
-                    taskQueueManager.cancelBuildTask( projectId );
-                }
+                //parallelBuildsManager.cancelCheckout( projectId );
+                
+                parallelBuildsManager.cancelBuild( projectId );                
             }
-            catch ( TaskQueueManagerException e )
+            catch ( BuildManagerException e )
             {
                 throw new ContinuumException( e.getMessage(), e );
             }
@@ -666,7 +700,17 @@
 
         context.put( AbstractContinuumAction.KEY_PROJECT_ID, new Integer( projectId ) );
 
-        executeAction( "add-project-to-checkout-queue", context );
+        try
+        {
+            BuildDefinition buildDefinition = buildDefinitionDao.getDefaultBuildDefinition( projectId );
+            context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, buildDefinition );
+            
+            executeAction( "add-project-to-checkout-queue", context );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumException( e.getMessage(), e );
+        }
     }
 
     public Project getProject( int projectId )
@@ -720,13 +764,17 @@
     public void buildProjectsWithBuildDefinition( List<Project> projects, List<BuildDefinition> bds )
         throws ContinuumException
     {
-        prepareBuildProjects( projects, bds, true, ContinuumProjectState.TRIGGER_FORCED );
+        Collection<Project> filteredProjectsList = getProjectsNotInReleaseStage( projects );
+        
+        prepareBuildProjects( filteredProjectsList, bds, true, ContinuumProjectState.TRIGGER_FORCED );
     }
 
     public void buildProjectsWithBuildDefinition( List<Project> projects, int buildDefinitionId )
         throws ContinuumException
     {
-        prepareBuildProjects( projects, buildDefinitionId, ContinuumProjectState.TRIGGER_FORCED );
+        Collection<Project> filteredProjectsList = getProjectsNotInReleaseStage( projects );
+        
+        prepareBuildProjects( filteredProjectsList, buildDefinitionId, ContinuumProjectState.TRIGGER_FORCED );
     }
 
     /**
@@ -750,8 +798,10 @@
 
             projectsList = getProjects();
         }
-
-        prepareBuildProjects( projectsList, null, true, trigger );
+        
+        Collection<Project> filteredProjectsList = getProjectsNotInReleaseStage( projectsList );    
+        
+        prepareBuildProjects( filteredProjectsList, null, true, trigger );
     }
 
     /**
@@ -777,7 +827,9 @@
             projectsList = getProjects();
         }
 
-        prepareBuildProjects( projectsList, buildDefinitionId, trigger );
+        Collection<Project> filteredProjectsList = getProjectsNotInReleaseStage( projectsList );
+        
+        prepareBuildProjects( filteredProjectsList, buildDefinitionId, trigger );
     }
 
     /**
@@ -790,10 +842,13 @@
         throws ContinuumException
     {
         List<BuildDefinition> groupDefaultBDs = null;
+        
+        if( !isAnyProjectInGroupInReleaseStage( projectGroupId ) )
+        {
+            groupDefaultBDs = getDefaultBuildDefinitionsForProjectGroup( projectGroupId );
 
-        groupDefaultBDs = getDefaultBuildDefinitionsForProjectGroup( projectGroupId );
-
-        buildProjectGroupWithBuildDefinition( projectGroupId, groupDefaultBDs, true );
+            buildProjectGroupWithBuildDefinition( projectGroupId, groupDefaultBDs, true );
+        }
     }
 
     /**
@@ -806,13 +861,16 @@
     public void buildProjectGroupWithBuildDefinition( int projectGroupId, int buildDefinitionId )
         throws ContinuumException
     {
-        List<BuildDefinition> bds = new ArrayList<BuildDefinition>();
-        BuildDefinition bd = getBuildDefinition( buildDefinitionId );
-        if ( bd != null )
+        if( !isAnyProjectInGroupInReleaseStage( projectGroupId ) )
         {
-            bds.add( bd );
+            List<BuildDefinition> bds = new ArrayList<BuildDefinition>();
+            BuildDefinition bd = getBuildDefinition( buildDefinitionId );
+            if ( bd != null )
+            {
+                bds.add( bd );
+            }
+            buildProjectGroupWithBuildDefinition( projectGroupId, bds, false );
         }
-        buildProjectGroupWithBuildDefinition( projectGroupId, bds, false );
     }
 
     /**
@@ -825,20 +883,23 @@
                                                        boolean checkDefaultBuildDefinitionForProject )
         throws ContinuumException
     {
-        Collection<Project> projectsList;
-
-        try
-        {
-            projectsList = getProjectsInBuildOrder( projectDao.getProjectsWithDependenciesByGroupId( projectGroupId ) );
-        }
-        catch ( CycleDetectedException e )
+        if( !isAnyProjectInGroupInReleaseStage( projectGroupId ) )
         {
-            log.warn( "Cycle detected while sorting projects for building, falling back to unsorted build." );
-
-            projectsList = getProjects();
+            Collection<Project> projectsList;
+    
+            try
+            {
+                projectsList = getProjectsInBuildOrder( projectDao.getProjectsWithDependenciesByGroupId( projectGroupId ) );
+            }
+            catch ( CycleDetectedException e )
+            {
+                log.warn( "Cycle detected while sorting projects for building, falling back to unsorted build." );
+    
+                projectsList = getProjects();
+            }
+            
+            prepareBuildProjects( projectsList, bds, checkDefaultBuildDefinitionForProject, ContinuumProjectState.TRIGGER_FORCED );
         }
-
-        prepareBuildProjects( projectsList, bds, checkDefaultBuildDefinitionForProject, ContinuumProjectState.TRIGGER_FORCED );
     }
 
     /**
@@ -855,7 +916,7 @@
         Collection<Project> projectsList;
 
         Map projectsMap = null;
-
+        
         try
         {
             projectsMap = daoUtils.getAggregatedProjectIdsAndBuildDefinitionIdsBySchedule( schedule.getId() );
@@ -892,8 +953,8 @@
                 {
                     try
                     {
-                        if ( buildDefId != null && !taskQueueManager.isInBuildingQueue( project.getId(), buildDefId.intValue() ) &&
-                            !taskQueueManager.isInCheckoutQueue( project.getId() ) && !taskQueueManager.isInPrepareBuildQueue( project.getId() ) )
+                        if ( buildDefId != null && !parallelBuildsManager.isInAnyBuildQueue( project.getId(), buildDefId.intValue() ) &&
+                                !parallelBuildsManager.isInAnyCheckoutQueue( project.getId() ) && !parallelBuildsManager.isInPrepareBuildQueue( project.getId() ) )
                         {
                             ProjectScmRoot scmRoot = getProjectScmRootByProject( project.getId() );
                             
@@ -909,7 +970,7 @@
                             map.put( scmRoot, projectsAndBuildDefinitionsMap );
                         }
                     } 
-                    catch ( TaskQueueManagerException e )
+                    catch ( BuildManagerException e )
                     {
                         throw new ContinuumException( e.getMessage(), e );
                     }
@@ -935,6 +996,12 @@
     public void buildProject( int projectId, int trigger )
         throws ContinuumException
     {
+        Project project = getProject( projectId );        
+        if( isProjectInReleaseStage( project ) )
+        {
+            throw new ContinuumException( "Project (id=" + projectId + ") is currently in release stage." );
+        }
+            
         BuildDefinition buildDef = getDefaultBuildDefinition( projectId );
 
         if ( buildDef == null )
@@ -944,14 +1011,14 @@
 
         try
         {
-            if ( taskQueueManager.isInBuildingQueue( projectId, buildDef.getId() ) || 
-                 taskQueueManager.isInCheckoutQueue( projectId ) ||
-                 taskQueueManager.isInPrepareBuildQueue( projectId ))
+            if ( parallelBuildsManager.isInAnyBuildQueue( projectId, buildDef.getId() ) || 
+                            parallelBuildsManager.isInAnyCheckoutQueue( projectId ) ||
+                            parallelBuildsManager.isInPrepareBuildQueue( projectId ) )           
             {
                 return;
             }
         }
-        catch ( TaskQueueManagerException e )
+        catch ( BuildManagerException e )
         {
             throw new ContinuumException( e.getMessage(), e );
         }
@@ -966,16 +1033,22 @@
     public void buildProject( int projectId, int buildDefinitionId, int trigger )
         throws ContinuumException
     {
+        Project project = getProject( projectId );
+        if( isProjectInReleaseStage( project ) )
+        {
+            throw new ContinuumException( "Project (id=" + projectId + ") is currently in release stage." );
+        }
+        
         try
         {
-            if ( taskQueueManager.isInBuildingQueue( projectId, buildDefinitionId ) || 
-                 taskQueueManager.isInCheckoutQueue( projectId ) ||
-                 taskQueueManager.isInPrepareBuildQueue( projectId ))
+            if ( parallelBuildsManager.isInAnyBuildQueue( projectId, buildDefinitionId ) || 
+                            parallelBuildsManager.isInAnyCheckoutQueue( projectId ) ||
+                            parallelBuildsManager.isInPrepareBuildQueue( projectId ))
             {
                 return;
             }
         }
-        catch ( TaskQueueManagerException e )
+        catch ( BuildManagerException e )
         {
             throw new ContinuumException( e.getMessage(), e );
         }
@@ -1421,6 +1494,9 @@
         context.put( AbstractContinuumAction.KEY_UNVALIDATED_PROJECT_GROUP, projectGroup );
 
         context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, new Integer( projectGroup.getId() ) );
+        
+     // used by BuildManager to determine on which build queue will the project be put
+        context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, ( BuildDefinition ) project.getBuildDefinitions().get( 0 ) );
 
         executeAction( "validate-project", context );
 
@@ -1663,6 +1739,20 @@
                 // olamy  : read again the project to have values because store.updateProjectGroup( projectGroup ); 
                 // remove object data -> we don't display the project name in the build queue
                 context.put( AbstractContinuumAction.KEY_PROJECT, projectDao.getProject( project.getId() ) );
+                
+                BuildDefinition defaultBuildDefinition = null;
+                if( projectBuilderId.equals( MavenTwoContinuumProjectBuilder.ID ) )
+                {
+                    defaultBuildDefinition = ( BuildDefinition ) buildDefinitionService.getDefaultMavenTwoBuildDefinitionTemplate().getBuildDefinitions().get( 0 );
+                }
+                else if( projectBuilderId.equals( MavenOneContinuumProjectBuilder.ID ) )
+                {
+                    defaultBuildDefinition = ( BuildDefinition ) buildDefinitionService.getDefaultMavenOneBuildDefinitionTemplate().getBuildDefinitions().get( 0 );
+                }
+                    
+                // used by BuildManager to determine on which build queue will the project be put
+                context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, defaultBuildDefinition );
+                
                 executeAction( "add-project-to-checkout-queue", context );
             }
         }
@@ -3210,6 +3300,78 @@
         }
         return null;
     }
+    
+    public BuildQueue addBuildQueue( BuildQueue buildQueue ) throws ContinuumException
+    {
+        try
+        {            
+            return buildQueueService.addBuildQueue( buildQueue );
+        }
+        catch ( BuildQueueServiceException e )
+        {
+            throw new ContinuumException( "Error adding build queue to the database.", e );
+        }
+    }
+    
+    public BuildQueue getBuildQueue( int buildQueueId ) throws ContinuumException
+    {
+        try
+        {
+            return buildQueueService.getBuildQueue( buildQueueId );
+        }
+        catch ( BuildQueueServiceException e )
+        {
+            throw new ContinuumException( "Error retrieving build queue.", e );
+        }
+    }
+    
+    public BuildQueue getBuildQueueByName( String buildQueueName ) throws ContinuumException
+    {
+        try
+        {            
+            return buildQueueService.getBuildQueueByName( buildQueueName );
+        }
+        catch ( BuildQueueServiceException e )
+        {
+            throw new ContinuumException( "Error retrieving build queue.", e );
+        }
+    }
+    
+    public void removeBuildQueue( BuildQueue buildQueue ) throws ContinuumException
+    {
+        try
+        {            
+            buildQueueService.removeBuildQueue( buildQueue );
+        }
+        catch ( BuildQueueServiceException e )
+        {
+            throw new ContinuumException( "Error deleting build queue from database.", e );
+        }
+    }
+    
+    public BuildQueue storeBuildQueue( BuildQueue buildQueue ) throws ContinuumException
+    {
+        try
+        {            
+            return buildQueueService.updateBuildQueue( buildQueue );
+        }
+        catch ( BuildQueueServiceException e )
+        {
+            throw new ContinuumException( "Error updating build queue.", e );
+        }
+    }
+    
+    public List<BuildQueue> getAllBuildQueues() throws ContinuumException
+    {
+        try
+        {            
+            return buildQueueService.getAllBuildQueues();
+        }
+        catch ( BuildQueueServiceException e )
+        {
+            throw new ContinuumException( "Error adding build queue.", e );
+        }
+    }
    
     private void prepareBuildProjects( Collection<Project> projects, List<BuildDefinition> bds,
                                       boolean checkDefaultBuildDefinitionForProject, int trigger )
@@ -3224,17 +3386,17 @@
             try
             {
                 // check if project already in queue
-                if ( taskQueueManager.isInBuildingQueue( projectId ) || taskQueueManager.getCurrentProjectIdBuilding() == projectId )
+                if ( parallelBuildsManager.isInAnyBuildQueue( projectId ) || parallelBuildsManager.isProjectInAnyCurrentBuild( projectId ) )
                 {
                     continue;
                 }
                 
-                if ( taskQueueManager.isInCheckoutQueue( projectId ) )
+                if ( parallelBuildsManager.isInAnyCheckoutQueue( projectId ) )
                 {
-                    taskQueueManager.removeProjectFromCheckoutQueue( projectId );
+                    parallelBuildsManager.removeProjectFromCheckoutQueue( projectId );
                 }
             }
-            catch ( TaskQueueManagerException e )
+            catch ( BuildManagerException e )
             {
                 throw new ContinuumException( e.getMessage(), e );
             }
@@ -3314,14 +3476,14 @@
             try
             {
                 // check if project already in queue
-                if ( taskQueueManager.isInBuildingQueue( projectId ) || taskQueueManager.getCurrentProjectIdBuilding() == projectId )
+                if ( parallelBuildsManager.isInAnyBuildQueue( projectId ) || parallelBuildsManager.isProjectInAnyCurrentBuild( projectId ) )
                 {
                     continue;
                 }
                 
-                if ( taskQueueManager.isInCheckoutQueue( projectId ) )
+                if ( parallelBuildsManager.isInAnyCheckoutQueue( projectId ) )
                 {
-                    taskQueueManager.removeProjectFromCheckoutQueue( projectId );
+                    parallelBuildsManager.removeProjectFromCheckoutQueue( projectId );
                 }
                 
                 ProjectScmRoot scmRoot = getProjectScmRootByProject( projectId );
@@ -3337,7 +3499,7 @@
                 
                 map.put( scmRoot, projectsAndBuildDefinitionsMap );
             }
-            catch ( TaskQueueManagerException e )
+            catch ( BuildManagerException e )
             {
                 throw new ContinuumException( e.getMessage(), e );
             }
@@ -3360,12 +3522,12 @@
         throws ContinuumException
     {
         try
-        {
-            PrepareBuildProjectsTask task = new PrepareBuildProjectsTask( projectsBuildDefinitionsMap, trigger,
-                                                                          projectGroupId, scmRootAddress );
-            taskQueueManager.getPrepareBuildQueue().put( task );
+        {     
+        	parallelBuildsManager.prepareBuildProjects(
+					projectsBuildDefinitionsMap, trigger, projectGroupId,
+					scmRootAddress);
         }
-        catch ( TaskQueueException e )
+        catch( BuildManagerException e )
         {
             throw logAndCreateException( "Error while creating enqueuing object.", e );
         }
@@ -3423,4 +3585,68 @@
             throw new ContinuumException( "Error while creating project scm root with scm root address:" + url );
         }
     }
+    
+    private boolean isProjectInReleaseStage( Project project ) throws ContinuumException
+    {           
+        String releaseId = project.getGroupId() + ":" + project.getArtifactId();        
+        try
+        {
+            if( taskQueueManager.isProjectInReleaseStage( releaseId ) )
+            {
+                return true;
+            }
+            return false;
+        }
+        catch ( TaskQueueManagerException e )
+        {
+            throw new ContinuumException( "Error occurred while checking if project is currently being released.",  e );
+        }
+    }
+    
+    private boolean isAnyProjectInGroupInReleaseStage( int projectGroupId )
+        throws ContinuumException
+    {
+        Collection<Project> projects = getProjectsInGroup( projectGroupId );
+        for( Project project : projects )
+        {
+            if( isProjectInReleaseStage( project ) )
+            {
+                throw new ContinuumException( "Cannot build project group. Project (id=" + project.getId() +
+                    ") in group is currently in release stage." );
+            }
+        }        
+        return false;
+    }
+    
+    private Collection<Project> getProjectsNotInReleaseStage( Collection<Project> projectsList )
+        throws ContinuumException
+    {
+        // filter the projects to be built
+        // projects that are in the release stage will not be built
+        Collection<Project> filteredProjectsList = new ArrayList<Project>();
+        for( Project project : projectsList )
+        {
+            if( !isProjectInReleaseStage( project ) )
+            {
+                filteredProjectsList.add( project );
+            }
+            else
+            {
+                log.warn(
+                                  "Project (id=" + project.getId() +
+                                      ") will not be built. It is currently in the release stage." );
+            }
+        }
+        return filteredProjectsList;
+    }
+    
+    void setTaskQueueManager( TaskQueueManager taskQueueManager )
+    {
+        this.taskQueueManager = taskQueueManager;
+    }
+    
+    void setProjectDao( ProjectDao  projectDao )
+    {
+        this.projectDao = projectDao;
+    }
 }



Mime
View raw message