continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r751433 [2/4] - in /continuum/trunk: continuum-api/ continuum-api/src/main/java/org/apache/continuum/release/ continuum-api/src/main/java/org/apache/continuum/release/distributed/ continuum-api/src/main/java/org/apache/continuum/release/dis...
Date Sun, 08 Mar 2009 14:41:35 GMT
Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java?rev=751433&r1=751432&r2=751433&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java Sun Mar  8 14:41:33 2009
@@ -21,30 +21,11 @@
 
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
-import org.apache.continuum.buildagent.buildcontext.BuildContext;
 import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationService;
-import org.apache.continuum.buildagent.taskqueue.manager.BuildAgentTaskQueueManager;
-import org.apache.continuum.buildagent.utils.BuildContextToBuildDefinition;
-import org.apache.continuum.buildagent.utils.BuildContextToProject;
-import org.apache.continuum.buildagent.utils.ContinuumBuildAgentUtil;
 import org.apache.continuum.distributed.transport.master.MasterBuildAgentTransportClient;
-import org.apache.continuum.taskqueue.BuildProjectTask;
-import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
 import org.apache.maven.continuum.ContinuumException;
-import org.apache.maven.continuum.model.project.BuildDefinition;
-import org.apache.maven.continuum.model.project.Project;
-import org.apache.maven.continuum.model.scm.ChangeSet;
-import org.apache.maven.continuum.model.scm.ScmResult;
-import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.codehaus.plexus.action.ActionManager;
-import org.codehaus.plexus.action.ActionNotFoundException;
-import org.codehaus.plexus.taskqueue.TaskQueueException;
-import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -59,84 +40,8 @@
     /**
      * @plexus.requirement
      */
-    private ActionManager actionManager;
-
-    /**
-     * @plexus.requirement
-     */
     private BuildAgentConfigurationService buildAgentConfigurationService;
 
-    /**
-     * @plexus.requirement
-     */
-    private BuildAgentTaskQueueManager buildAgentTaskQueueManager;
-
-    public void prepareBuildProjects( List<BuildContext> buildContexts)
-        throws ContinuumException
-    {
-        Map<String, Object> context = null;
-
-        if ( buildContexts != null && buildContexts.size() > 0 )
-        {
-            try
-            {
-                for ( BuildContext buildContext : buildContexts )
-                {
-                    BuildDefinition buildDef = BuildContextToBuildDefinition.getBuildDefinition( buildContext );
-        
-                    log.info( "Check scm root state" );
-                    if ( !checkProjectScmRoot( context ) )
-                    {
-                        break;
-                    }
-                    
-                    log.info( "Starting prepare build" );
-                    startPrepareBuild( buildContext );
-                    
-                    log.info( "Initializing prepare build" );
-                    initializeActionContext( buildContext );
-                    
-                    try
-                    {
-                        if ( buildDef.isBuildFresh() )
-                        {
-                            log.info( "Clean up working directory" );
-                            cleanWorkingDirectory( buildContext );
-                        }
-            
-                        log.info( "Updating working directory" );
-                        updateWorkingDirectory( buildContext );
-
-                        log.info( "Merging SCM results" );
-                        //CONTINUUM-1393
-                        if ( !buildDef.isBuildFresh() )
-                        {
-                            mergeScmResults( buildContext );
-                        }
-                    }
-                    finally
-                    {
-                        endProjectPrepareBuild( buildContext );
-                        context = buildContext.getActionContext();
-                    }
-                }
-            }
-            finally
-            {
-                endPrepareBuild( context );
-            }
-
-            if ( checkProjectScmRoot( context ) )
-            {
-                buildProjects( buildContexts );
-            }
-        }
-        else
-        {
-            throw new ContinuumException( "No project build context" );
-        }
-    }
-
     public void startProjectBuild( int projectId )
         throws ContinuumException
     {
@@ -242,337 +147,43 @@
         }
     }
 
-    private void startPrepareBuild( BuildContext buildContext )
-        throws ContinuumException
-    {
-        Map<String, Object> actionContext = buildContext.getActionContext();
-        
-        if ( actionContext == null || !( ContinuumBuildAgentUtil.getScmRootState( actionContext ) == ContinuumProjectState.UPDATING ) ) 
-        {
-            Map<String, Object> map = new HashMap<String, Object>();
-            map.put( ContinuumBuildAgentUtil.KEY_PROJECT_GROUP_ID, new Integer( buildContext.getProjectGroupId() ) );
-            map.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_ADDRESS, buildContext.getScmRootAddress() );
-            
-            try
-            {
-                MasterBuildAgentTransportClient client = new MasterBuildAgentTransportClient(
-                    new URL( buildAgentConfigurationService.getContinuumServerUrl() ) );
-                client.startPrepareBuild( map );
-            }
-            catch ( MalformedURLException e )
-            {
-                log.error( "Invalid continuum server URL '" + buildAgentConfigurationService.getContinuumServerUrl() + "'" );
-                throw new ContinuumException( "Invalid continuum server URL '" + buildAgentConfigurationService.getContinuumServerUrl() + "'", e );
-            }
-            catch ( Exception e )
-            {
-                log.error( "Error starting prepare build", e );
-                throw new ContinuumException( "Error starting prepare build", e );
-            }
-        }
-    }
-
-    private void initializeActionContext( BuildContext buildContext )
-    {
-        Map<String, Object> actionContext = new HashMap<String, Object>();
-
-        actionContext.put( ContinuumBuildAgentUtil.KEY_PROJECT_ID, buildContext.getProjectId() );
-        actionContext.put( ContinuumBuildAgentUtil.KEY_PROJECT, BuildContextToProject.getProject( buildContext ) );
-        actionContext.put( ContinuumBuildAgentUtil.KEY_BUILD_DEFINITION, BuildContextToBuildDefinition.getBuildDefinition( buildContext ) );
-        actionContext.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_STATE, ContinuumProjectState.UPDATING );
-        actionContext.put( ContinuumBuildAgentUtil.KEY_PROJECT_GROUP_ID, buildContext.getProjectGroupId() );
-        actionContext.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_ADDRESS, buildContext.getScmRootAddress() );
-        actionContext.put( ContinuumBuildAgentUtil.KEY_OLD_SCM_RESULT, buildContext.getOldScmResult() );
-        actionContext.put( ContinuumBuildAgentUtil.KEY_LATEST_UPDATE_DATE, buildContext.getLatestUpdateDate() );
-
-        buildContext.setActionContext( actionContext );
-    }
-
-    private boolean checkProjectScmRoot( Map context )
-    {
-        if ( context != null && ContinuumBuildAgentUtil.getScmRootState( context ) == ContinuumProjectState.ERROR )
-        {
-            return false;
-        }
-
-        return true;
-    }
-
-    private void cleanWorkingDirectory( BuildContext buildContext )
-        throws ContinuumException
-    {
-        performAction( "clean-agent-working-directory", buildContext );
-    }
-
-    private void updateWorkingDirectory( BuildContext buildContext )
-        throws ContinuumException
-    {
-        Map<String, Object> actionContext = buildContext.getActionContext();
-
-        performAction( "check-agent-working-directory", buildContext );
-        
-        boolean workingDirectoryExists =
-            ContinuumBuildAgentUtil.getBoolean( actionContext, ContinuumBuildAgentUtil.KEY_WORKING_DIRECTORY_EXISTS );
-    
-        ScmResult scmResult;
-
-        Date date = null;
-
-        if ( workingDirectoryExists )
-        {
-            performAction( "update-agent-working-directory", buildContext );
-    
-            scmResult = ContinuumBuildAgentUtil.getUpdateScmResult( actionContext, null );
-
-            date = ContinuumBuildAgentUtil.getLatestUpdateDate( actionContext );
-
-            if ( date == null )
-            {
-                // try to get latest update date from change log because sometimes date in the changefile is 0
-                performAction( "changelog-agent-project", buildContext );
-
-                date = ContinuumBuildAgentUtil.getLatestUpdateDate( actionContext );
-            }
-        }
-        else
-        {
-            Project project = ContinuumBuildAgentUtil.getProject( actionContext );
-    
-            actionContext.put( ContinuumBuildAgentUtil.KEY_WORKING_DIRECTORY,
-                               buildAgentConfigurationService.getWorkingDirectory( project.getId() ).getAbsolutePath() );
-
-            performAction( "checkout-agent-project", buildContext );
-
-            scmResult = ContinuumBuildAgentUtil.getCheckoutScmResult( actionContext, null );
-
-            performAction( "changelog-agent-project", buildContext );
-
-            date = ContinuumBuildAgentUtil.getLatestUpdateDate( actionContext );
-        }
-
-        buildContext.setScmResult( scmResult );
-        buildContext.setLatestUpdateDate( date );
-        actionContext.put( ContinuumBuildAgentUtil.KEY_SCM_RESULT, scmResult );
-    }
-
-    private void endProjectPrepareBuild( BuildContext buildContext )
+    public void startPrepareBuild( Map context )
         throws ContinuumException
     {
-        Map<String, Object> context = buildContext.getActionContext();
-
-        ScmResult scmResult = ContinuumBuildAgentUtil.getScmResult( context, null );
-
-        if ( scmResult == null || !scmResult.isSuccess() )
-        {
-            context.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_STATE, ContinuumProjectState.ERROR );
-        }
-        else
-        {
-            buildContext.setScmResult( scmResult );
-        }
-    }
-
-    private void endPrepareBuild( Map context )
-        throws ContinuumException
-    {
-        if ( context != null )
-        {
-            Map<String, Object> result = new HashMap<String, Object>();
-            result.put( ContinuumBuildAgentUtil.KEY_PROJECT_GROUP_ID, new Integer( ContinuumBuildAgentUtil.getProjectGroupId( context ) ) );
-            result.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_ADDRESS, ContinuumBuildAgentUtil.getScmRootAddress( context ) );
-            result.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_STATE, new Integer( ContinuumBuildAgentUtil.getScmRootState( context ) ) );
-            
-            if ( ContinuumBuildAgentUtil.getScmRootState( context ) == ContinuumProjectState.ERROR )
-            {
-                String error = convertScmResultToError( ContinuumBuildAgentUtil.getScmResult( context, null ) );
-                
-                if ( StringUtils.isEmpty( error ) )
-                {
-                    result.put( ContinuumBuildAgentUtil.KEY_SCM_ERROR, "" );
-                }
-                else
-                {
-                    result.put( ContinuumBuildAgentUtil.KEY_SCM_ERROR, error );
-                }
-            }
-            else
-            {
-                result.put( ContinuumBuildAgentUtil.KEY_SCM_ERROR, "" );
-            }
-
-            // connect to continuum server (master)
-            try
-            {
-                MasterBuildAgentTransportClient client = new MasterBuildAgentTransportClient(
-                     new URL( buildAgentConfigurationService.getContinuumServerUrl() ) );
-                client.prepareBuildFinished( result );
-            }
-            catch ( MalformedURLException e )
-            {
-                throw new ContinuumException( "Invalid Continuum Server URL '" + buildAgentConfigurationService.getContinuumServerUrl() + "'" );
-            }
-            catch ( Exception e )
-            {
-                throw new ContinuumException( "Error while finishing prepare build", e );
-            }
-        }
-        else
+        try
         {
-            throw new ContinuumException( "No project build context" );
+            MasterBuildAgentTransportClient client = new MasterBuildAgentTransportClient(
+                new URL( buildAgentConfigurationService.getContinuumServerUrl() ) );
+            client.startPrepareBuild( context );
         }
-    }
-
-    private String convertScmResultToError( ScmResult result )
-    {
-        String error = "";
-
-        if ( result == null )
+        catch ( MalformedURLException e )
         {
-            error = "Scm result is null.";
+            log.error( "Invalid continuum server URL '" + buildAgentConfigurationService.getContinuumServerUrl() + "'" );
+            throw new ContinuumException( "Invalid continuum server URL '" + buildAgentConfigurationService.getContinuumServerUrl() + "'", e );
         }
-        else
+        catch ( Exception e )
         {
-            if ( result.getCommandLine() != null )
-            {
-                error = "Command line: " + StringUtils.clean( result.getCommandLine() ) +
-                    System.getProperty( "line.separator" );
-            }
-
-            if ( result.getProviderMessage() != null )
-            {
-                error = "Provider message: " + StringUtils.clean( result.getProviderMessage() ) +
-                    System.getProperty( "line.separator" );
-            }
-
-            if ( result.getCommandOutput() != null )
-            {
-                error += "Command output: " + System.getProperty( "line.separator" );
-                error += "-------------------------------------------------------------------------------" +
-                    System.getProperty( "line.separator" );
-                error += StringUtils.clean( result.getCommandOutput() ) + System.getProperty( "line.separator" );
-                error += "-------------------------------------------------------------------------------" +
-                    System.getProperty( "line.separator" );
-            }
-
-            if ( result.getException() != null )
-            {
-                error += "Exception:" + System.getProperty( "line.separator" );
-                error += result.getException();
-            }
+            log.error( "Error starting prepare build", e );
+            throw new ContinuumException( "Error starting prepare build", e );
         }
-
-        return error;
     }
 
-    private void performAction( String actionName, BuildContext buildContext )
+    public void endPrepareBuild( Map context )
         throws ContinuumException
     {
-        ContinuumException exception = null;
-    
         try
         {
-            log.info( "Performing action " + actionName );
-            actionManager.lookup( actionName ).execute( buildContext.getActionContext() );
-            return;
+            MasterBuildAgentTransportClient client = new MasterBuildAgentTransportClient(
+                 new URL( buildAgentConfigurationService.getContinuumServerUrl() ) );
+            client.prepareBuildFinished( context );
         }
-        catch ( ActionNotFoundException e )
+        catch ( MalformedURLException e )
         {
-            exception = new ContinuumException( "Error looking up action '" + actionName + "'", e );
+            throw new ContinuumException( "Invalid Continuum Server URL '" + buildAgentConfigurationService.getContinuumServerUrl() + "'" );
         }
         catch ( Exception e )
         {
-            exception = new ContinuumException( "Error executing action '" + actionName + "'", e );
-        }
-        
-        ScmResult result = new ScmResult();
-        
-        result.setSuccess( false );
-        
-        result.setException( ContinuumBuildAgentUtil.throwableToString( exception ) );
-
-        buildContext.setScmResult( result );
-        buildContext.getActionContext().put( ContinuumBuildAgentUtil.KEY_UPDATE_SCM_RESULT, result );
-        
-        throw exception;
-    }
-    
-    private void buildProjects( List<BuildContext> buildContexts )
-        throws ContinuumException
-    {
-        for ( BuildContext buildContext : buildContexts )
-        {
-            BuildProjectTask buildProjectTask = new BuildProjectTask( buildContext.getProjectId(),
-                                                                      buildContext.getBuildDefinitionId(),
-                                                                      buildContext.getTrigger(),
-                                                                      buildContext.getProjectName(),
-                                                                      "", 
-                                                                      buildContext.getScmResult() );
-
-            try
-            {
-                if ( !buildAgentTaskQueueManager.isProjectInBuildQueue( buildProjectTask.getProjectId() ) )
-                {
-                    buildAgentTaskQueueManager.getBuildQueue().put( buildProjectTask );
-                }
-            }
-            catch ( TaskQueueException e )
-            {
-                log.error( "Error while enqueing build task for project " + buildContext.getProjectId(), e );
-                throw new ContinuumException( "Error while enqueuing build task for project " + buildContext.getProjectId(), e );
-            }
-            catch ( TaskQueueManagerException e )
-            {
-                log.error( "Error while checking if project " + buildContext.getProjectId() + " is in build queue", e );
-                throw new ContinuumException( "Error while checking if project " + buildContext.getProjectId() + " is in build queue", e );
-            }
-        }
-
-        try
-        {
-            boolean stop = false;
-            while ( !stop )
-            {
-                if ( buildAgentTaskQueueManager.getCurrentProjectInBuilding() <= 0 && 
-                                !buildAgentTaskQueueManager.hasBuildTaskInQueue()  )
-                {
-                    stop = true;
-                }
-            }
-        }
-        catch ( TaskQueueManagerException e )
-        {
-            throw new ContinuumException( e.getMessage(), e );
-        }
-    }
-
-    private void mergeScmResults( BuildContext buildContext )
-    {
-        Map context = buildContext.getActionContext();
-        ScmResult oldScmResult = ContinuumBuildAgentUtil.getOldScmResult( context, null );
-        ScmResult newScmResult = ContinuumBuildAgentUtil.getScmResult( context, null );
-
-        if ( oldScmResult != null )
-        {
-            if ( newScmResult == null )
-            {
-                context.put( ContinuumBuildAgentUtil.KEY_SCM_RESULT, oldScmResult );
-            }
-            else
-            {
-                List<ChangeSet> oldChanges = oldScmResult.getChanges();
-
-                List<ChangeSet> newChanges = newScmResult.getChanges();
-
-                for ( ChangeSet change : newChanges )
-                {
-                    if ( !oldChanges.contains( change ) )
-                    {
-                        oldChanges.add( change );
-                    }
-                }
-
-                newScmResult.setChanges( oldChanges );
-            }
+            throw new ContinuumException( "Error while finishing prepare build", e );
         }
     }
 }

Added: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentReleaseManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentReleaseManager.java?rev=751433&view=auto
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentReleaseManager.java (added)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentReleaseManager.java Sun Mar  8 14:41:33 2009
@@ -0,0 +1,313 @@
+package org.apache.continuum.buildagent.manager;
+
+/*
+ * 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 java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationService;
+import org.apache.continuum.buildagent.installation.BuildAgentInstallationService;
+import org.apache.continuum.buildagent.utils.ContinuumBuildAgentUtil;
+import org.apache.continuum.model.repository.LocalRepository;
+import org.apache.continuum.release.config.ContinuumReleaseDescriptor;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.release.ContinuumReleaseException;
+import org.apache.maven.continuum.release.ContinuumReleaseManager;
+import org.apache.maven.continuum.release.ContinuumReleaseManagerListener;
+import org.apache.maven.continuum.release.DefaultReleaseManagerListener;
+import org.apache.maven.shared.release.ReleaseResult;
+import org.apache.maven.shared.release.config.ReleaseDescriptor;
+import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @plexus.component role="org.apache.continuum.buildagent.manager.BuildAgentReleaseManager" role-hint="default"
+ */
+public class DefaultBuildAgentReleaseManager
+    implements BuildAgentReleaseManager
+{
+    private Logger log = LoggerFactory.getLogger( this.getClass() );
+
+    /**
+     * @plexus.requirement
+     */
+    ContinuumReleaseManager releaseManager;
+
+    /**
+     * @plexus.requirement
+     */
+    BuildAgentConfigurationService buildAgentConfigurationService;
+
+    /**
+     * @plexus.requirement
+     */
+    BuildAgentInstallationService buildAgentInstallationService;
+
+    public String releasePrepare( Map projectMap, Map properties, Map releaseVersion, Map developmentVersion, Map<String, String> environments )
+        throws ContinuumReleaseException
+    {
+        Project project = getProject( projectMap );
+
+        Properties releaseProperties = getReleaseProperties( properties );
+
+        ContinuumReleaseManagerListener listener = new DefaultReleaseManagerListener();
+
+        String workingDirectory = buildAgentConfigurationService.getWorkingDirectory( project.getId() ).getPath();
+
+        String executable = buildAgentInstallationService.getExecutorConfigurator( BuildAgentInstallationService.MAVEN2_TYPE ).getExecutable();
+
+        if ( environments != null )
+        {
+            String m2Home = environments.get( buildAgentInstallationService.getEnvVar( BuildAgentInstallationService.MAVEN2_TYPE ) );
+            if ( StringUtils.isNotEmpty( m2Home ) )
+            {
+                executable = m2Home + File.separator + "bin" + File.separator + executable;
+            }
+        }
+
+        try
+        {
+            return releaseManager.prepare( project, releaseProperties, releaseVersion, developmentVersion, listener,
+                                           workingDirectory, environments, executable );
+        }
+        catch ( ContinuumReleaseException e )
+        {
+            log.error( "Error while preparing release" );
+            throw e;
+        }
+    }
+
+    public ReleaseResult getReleaseResult( String releaseId )
+    {
+        return (ReleaseResult) releaseManager.getReleaseResults().get( releaseId );
+    }
+
+    public Map getListener( String releaseId )
+    {
+        ContinuumReleaseManagerListener listener = (ContinuumReleaseManagerListener) releaseManager.getListeners().get( releaseId );
+
+        Map map = new HashMap();
+
+        if ( listener != null )
+        { 
+            map.put( ContinuumBuildAgentUtil.KEY_RELEASE_STATE, new Integer( listener.getState() ) );
+            if ( listener.getPhases() != null )
+            {
+                map.put( ContinuumBuildAgentUtil.KEY_RELEASE_PHASES, listener.getPhases() );
+            }
+            if ( listener.getCompletedPhases() != null )
+            {
+                map.put( ContinuumBuildAgentUtil.KEY_COMPLETED_RELEASE_PHASES, listener.getCompletedPhases() );
+            }
+            if ( listener.getInProgress() != null )
+            {
+                map.put( ContinuumBuildAgentUtil.KEY_RELEASE_IN_PROGRESS, listener.getInProgress() );
+            }
+            if ( listener.getError() != null )
+            {
+                map.put( ContinuumBuildAgentUtil.KEY_RELEASE_ERROR, listener.getError() );
+            }
+        }
+
+        return map;
+    }
+
+    public void removeListener( String releaseId )
+    {
+        releaseManager.getListeners().remove( releaseId );
+    }
+
+    public String getPreparedReleaseName( String releaseId )
+    {
+        Map preparedReleases = releaseManager.getPreparedReleases();
+
+        if ( preparedReleases.containsKey( releaseId ) )
+        {
+            ReleaseDescriptor descriptor = (ReleaseDescriptor) preparedReleases.get( releaseId );
+            return descriptor.getReleaseVersions().get( releaseId ).toString();
+        }
+
+        return "";
+    }
+
+    public void releasePerform( String releaseId, String goals, String arguments, boolean useReleaseProfile, Map repository )
+        throws ContinuumReleaseException
+    {
+        ContinuumReleaseManagerListener listener = new DefaultReleaseManagerListener();
+
+        LocalRepository repo = null;
+
+        if ( !repository.isEmpty() )
+        {
+            repo = new LocalRepository();
+            repo.setLayout( ContinuumBuildAgentUtil.getLocalRepositoryLayout( repository ) );
+            repo.setName( ContinuumBuildAgentUtil.getLocalRepositoryName( repository ) );
+            repo.setLocation( ContinuumBuildAgentUtil.getLocalRepository( repository ) );
+        }
+
+        File performDirectory = new File( buildAgentConfigurationService.getWorkingDirectory(),
+                                          "releases-" + System.currentTimeMillis() );
+        performDirectory.mkdirs();
+
+        releaseManager.perform( releaseId, performDirectory, goals, arguments, useReleaseProfile, listener, repo );
+    }
+
+    public void releasePerformFromScm( String goals, String arguments, boolean useReleaseProfile, Map repository, String scmUrl, String scmUsername, 
+                                String scmPassword, String scmTag, String scmTagBase, Map<String, String> environments )
+        throws ContinuumReleaseException
+    {
+        ContinuumReleaseDescriptor descriptor = new ContinuumReleaseDescriptor();
+        descriptor.setScmSourceUrl( scmUrl );
+        descriptor.setScmUsername( scmUsername );
+        descriptor.setScmPassword( scmPassword );
+        descriptor.setScmReleaseLabel( scmTag );
+        descriptor.setScmTagBase( scmTagBase );
+        descriptor.setEnvironments( environments );
+
+        String releaseId = "";
+
+        do
+        {
+            releaseId = String.valueOf( System.currentTimeMillis() );
+        }
+        while ( releaseManager.getPreparedReleases().containsKey( releaseId ) );
+
+        releaseManager.getPreparedReleases().put( releaseId, descriptor );
+
+        releasePerform( releaseId, goals, arguments, useReleaseProfile, repository );
+    }
+
+    public String releaseCleanup( String releaseId )
+    {
+        releaseManager.getReleaseResults().remove( releaseId );
+
+        ContinuumReleaseManagerListener listener =
+            (ContinuumReleaseManagerListener) releaseManager.getListeners().remove( releaseId );
+
+        if ( listener != null )
+        {
+            return listener.getGoalName() + "Finished";
+        }
+        else
+        {
+            return "";
+        }
+    }
+
+    private Project getProject( Map context )
+    {
+        Project project = new Project();
+
+        project.setId( ContinuumBuildAgentUtil.getProjectId( context ) );
+        project.setGroupId( ContinuumBuildAgentUtil.getGroupId( context ) );
+        project.setArtifactId( ContinuumBuildAgentUtil.getArtifactId( context ) );
+        project.setScmUrl( ContinuumBuildAgentUtil.getScmUrl( context ) );
+
+        ProjectGroup group = new ProjectGroup();
+
+        String localRepo = ContinuumBuildAgentUtil.getLocalRepository( context );
+        if ( StringUtils.isBlank( localRepo ) )
+        {
+            group.setLocalRepository( null );
+        }
+        else
+        {
+            LocalRepository localRepository = new LocalRepository();
+            localRepository.setLocation( localRepo );
+            group.setLocalRepository( localRepository );
+        }
+
+        project.setProjectGroup( group );
+
+        return project;
+    }
+
+    private Properties getReleaseProperties( Map context )
+    {
+        Properties props = new Properties();
+
+        String prop = ContinuumBuildAgentUtil.getScmUsername( context );
+        if ( StringUtils.isNotBlank( prop ) )
+        {
+            props.put( "username", prop );
+        }
+
+        prop = ContinuumBuildAgentUtil.getScmPassword( context );
+        if ( StringUtils.isNotBlank( prop ) )
+        {
+            props.put( "password", prop );
+        }
+
+        prop = ContinuumBuildAgentUtil.getScmTagBase( context );
+        if ( StringUtils.isNotBlank( prop ) )
+        {
+            props.put( "tagBase", prop );
+        }
+
+        prop = ContinuumBuildAgentUtil.getScmCommentPrefix( context );
+        if ( StringUtils.isNotBlank( prop ) );
+        {
+            props.put( "commentPrefix", prop );
+        }
+
+        prop = ContinuumBuildAgentUtil.getScmTag( context );
+        if ( StringUtils.isNotBlank( prop ) )
+        {
+            props.put( "tag", prop );
+        }
+        
+        prop = ContinuumBuildAgentUtil.getPrepareGoals( context );
+        if ( StringUtils.isNotBlank( prop ) )
+        {
+            props.put( "prepareGoals", prop );
+        }
+
+        prop = ContinuumBuildAgentUtil.getArguments( context );
+        if ( StringUtils.isNotBlank( prop ) )
+        {
+            props.put( "arguments", prop );
+        }
+
+        prop = ContinuumBuildAgentUtil.getUseEditMode( context );
+        if ( StringUtils.isNotBlank( prop ) )
+        {
+            props.put( "useEditMode", prop );
+        }
+
+        prop = ContinuumBuildAgentUtil.getAddSchema( context );
+        if ( StringUtils.isNotBlank( prop ) )
+        {
+            props.put( "addSchema", prop );
+        }
+
+        prop = ContinuumBuildAgentUtil.getAutoVersionSubmodules( context );
+        if ( StringUtils.isNotBlank( prop ) )
+        {
+            props.put( "autoVersionSubmodules", prop );
+        }
+        return props;
+    }
+
+    
+}

Propchange: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentReleaseManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentReleaseManager.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/PrepareBuildProjectsTask.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/PrepareBuildProjectsTask.java?rev=751433&view=auto
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/PrepareBuildProjectsTask.java (added)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/PrepareBuildProjectsTask.java Sun Mar  8 14:41:33 2009
@@ -0,0 +1,71 @@
+package org.apache.continuum.buildagent.taskqueue;
+
+/*
+ * 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 java.util.List;
+
+import org.apache.continuum.buildagent.buildcontext.BuildContext;
+import org.codehaus.plexus.taskqueue.Task;
+
+public class PrepareBuildProjectsTask
+    implements Task
+{
+    private List<BuildContext> buildContexts;
+
+    private int trigger;
+
+    private int projectGroupId;
+
+    private String scmRootAddress;
+
+    public PrepareBuildProjectsTask( List<BuildContext> buildContexts, int trigger, int projectGroupId, String scmRootAddress )
+    {
+        this.buildContexts = buildContexts;
+        this.trigger = trigger;
+        this.projectGroupId = projectGroupId;
+        this.scmRootAddress = scmRootAddress;
+    }
+
+    public long getMaxExecutionTime()
+    {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public List<BuildContext> getBuildContexts()
+    {
+        return buildContexts;
+    }
+
+    public int getTrigger()
+    {
+        return trigger;
+    }
+
+    public int getProjectGroupId()
+    {
+        return projectGroupId;
+    }
+
+    public String getScmRootAddress()
+    {
+        return scmRootAddress;
+    }
+}

Propchange: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/PrepareBuildProjectsTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/PrepareBuildProjectsTask.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java?rev=751433&r1=751432&r2=751433&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java Sun Mar  8 14:41:33 2009
@@ -210,8 +210,8 @@
         result.put( ContinuumBuildAgentUtil.KEY_BUILD_DEFINITION_ID, new Integer( buildContext.getBuildDefinitionId() ) );
         result.put( ContinuumBuildAgentUtil.KEY_TRIGGER, new Integer( buildContext.getTrigger() ) );
         result.put( ContinuumBuildAgentUtil.KEY_BUILD_STATE, new Integer( buildResult.getState() ) );
-        result.put( ContinuumBuildAgentUtil.KEY_BUILD_START, new Long( buildResult.getStartTime() ).toString() );
-        result.put( ContinuumBuildAgentUtil.KEY_BUILD_END, new Long( buildResult.getEndTime() ).toString() );
+        result.put( ContinuumBuildAgentUtil.KEY_START_TIME, new Long( buildResult.getStartTime() ).toString() );
+        result.put( ContinuumBuildAgentUtil.KEY_END_TIME, new Long( buildResult.getEndTime() ).toString() );
         result.put( ContinuumBuildAgentUtil.KEY_BUILD_EXIT_CODE, new Integer( buildResult.getExitCode() ) );
         if ( buildContext.getLatestUpdateDate() != null )
         {

Added: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/PrepareBuildProjectsTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/PrepareBuildProjectsTaskExecutor.java?rev=751433&view=auto
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/PrepareBuildProjectsTaskExecutor.java (added)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/PrepareBuildProjectsTaskExecutor.java Sun Mar  8 14:41:33 2009
@@ -0,0 +1,422 @@
+package org.apache.continuum.buildagent.taskqueue.execution;
+
+/*
+ * 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 java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.continuum.buildagent.buildcontext.BuildContext;
+import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationService;
+import org.apache.continuum.buildagent.manager.BuildAgentManager;
+import org.apache.continuum.buildagent.taskqueue.PrepareBuildProjectsTask;
+import org.apache.continuum.buildagent.utils.BuildContextToBuildDefinition;
+import org.apache.continuum.buildagent.utils.BuildContextToProject;
+import org.apache.continuum.buildagent.utils.ContinuumBuildAgentUtil;
+import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.scm.ChangeSet;
+import org.apache.maven.continuum.model.scm.ScmResult;
+import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.codehaus.plexus.action.ActionManager;
+import org.codehaus.plexus.action.ActionNotFoundException;
+import org.codehaus.plexus.taskqueue.Task;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
+import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @plexus.component role="org.codehaus.plexus.taskqueue.execution.TaskExecutor"
+ * role-hint="prepare-build-agent"
+ */
+public class PrepareBuildProjectsTaskExecutor
+    implements TaskExecutor
+{
+    private Logger log = LoggerFactory.getLogger( this.getClass() );
+
+    /**
+     * @plexus.requirement
+     */
+    private ActionManager actionManager;
+
+    /**
+     * @plexus.requirement
+     */
+    private BuildAgentConfigurationService buildAgentConfigurationService;
+
+    /**
+     * @plexus.requirement
+     */
+    private BuildAgentManager buildAgentManager;
+
+    public void executeTask( Task task )
+        throws TaskExecutionException
+    {
+        List<BuildContext> buildContexts = ( (PrepareBuildProjectsTask) task ).getBuildContexts();
+
+        Map<String, Object> context = null;
+
+        if ( buildContexts != null && buildContexts.size() > 0 )
+        {
+            try
+            {
+                for ( BuildContext buildContext : buildContexts )
+                {
+                    BuildDefinition buildDef = BuildContextToBuildDefinition.getBuildDefinition( buildContext );
+
+                    log.info( "Check scm root state" );
+                    if ( !checkProjectScmRoot( context ) )
+                    {
+                        break;
+                    }
+
+                    log.info( "Starting prepare build" );
+                    startPrepareBuild( buildContext );
+                    
+                    log.info( "Initializing prepare build" );
+                    initializeActionContext( buildContext );
+                    
+                    try
+                    {
+                        if ( buildDef.isBuildFresh() )
+                        {
+                            log.info( "Clean up working directory" );
+                            cleanWorkingDirectory( buildContext );
+                        }
+            
+                        log.info( "Updating working directory" );
+                        updateWorkingDirectory( buildContext );
+
+                        log.info( "Merging SCM results" );
+                        //CONTINUUM-1393
+                        if ( !buildDef.isBuildFresh() )
+                        {
+                            mergeScmResults( buildContext );
+                        }
+                    }
+                    finally
+                    {
+                        endProjectPrepareBuild( buildContext );
+                        context = buildContext.getActionContext();
+                    }
+                }
+            }
+            finally
+            {
+                endPrepareBuild( context );
+            }
+
+            if ( checkProjectScmRoot( context ) )
+            {
+                buildProjects( buildContexts );
+            }
+        }
+        else
+        {
+            throw new TaskExecutionException( "No project build context" );
+        }
+    }
+
+    private void startPrepareBuild( BuildContext buildContext )
+        throws TaskExecutionException
+    {
+        Map<String, Object> actionContext = buildContext.getActionContext();
+        
+        if ( actionContext == null || !( ContinuumBuildAgentUtil.getScmRootState( actionContext ) == ContinuumProjectState.UPDATING ) ) 
+        {
+            Map<String, Object> map = new HashMap<String, Object>();
+            map.put( ContinuumBuildAgentUtil.KEY_PROJECT_GROUP_ID, new Integer( buildContext.getProjectGroupId() ) );
+            map.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_ADDRESS, buildContext.getScmRootAddress() );
+
+            try
+            {
+                buildAgentManager.startPrepareBuild( map );
+            }
+            catch ( ContinuumException e )
+            {
+                throw new TaskExecutionException( e.getMessage(), e );
+            }
+        }
+    }
+    
+    private void initializeActionContext( BuildContext buildContext )
+    {
+        Map<String, Object> actionContext = new HashMap<String, Object>();
+    
+        actionContext.put( ContinuumBuildAgentUtil.KEY_PROJECT_ID, buildContext.getProjectId() );
+        actionContext.put( ContinuumBuildAgentUtil.KEY_PROJECT, BuildContextToProject.getProject( buildContext ) );
+        actionContext.put( ContinuumBuildAgentUtil.KEY_BUILD_DEFINITION, BuildContextToBuildDefinition.getBuildDefinition( buildContext ) );
+        actionContext.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_STATE, ContinuumProjectState.UPDATING );
+        actionContext.put( ContinuumBuildAgentUtil.KEY_PROJECT_GROUP_ID, buildContext.getProjectGroupId() );
+        actionContext.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_ADDRESS, buildContext.getScmRootAddress() );
+        actionContext.put( ContinuumBuildAgentUtil.KEY_OLD_SCM_RESULT, buildContext.getOldScmResult() );
+        actionContext.put( ContinuumBuildAgentUtil.KEY_LATEST_UPDATE_DATE, buildContext.getLatestUpdateDate() );
+    
+        buildContext.setActionContext( actionContext );
+    }
+    
+    private boolean checkProjectScmRoot( Map context )
+    {
+        if ( context != null && ContinuumBuildAgentUtil.getScmRootState( context ) == ContinuumProjectState.ERROR )
+        {
+            return false;
+        }
+    
+        return true;
+    }
+    
+    private void cleanWorkingDirectory( BuildContext buildContext )
+        throws TaskExecutionException
+    {
+        performAction( "clean-agent-working-directory", buildContext );
+    }
+    
+    private void updateWorkingDirectory( BuildContext buildContext )
+        throws TaskExecutionException
+    {
+        Map<String, Object> actionContext = buildContext.getActionContext();
+    
+        performAction( "check-agent-working-directory", buildContext );
+        
+        boolean workingDirectoryExists =
+            ContinuumBuildAgentUtil.getBoolean( actionContext, ContinuumBuildAgentUtil.KEY_WORKING_DIRECTORY_EXISTS );
+    
+        ScmResult scmResult;
+    
+        Date date = null;
+    
+        if ( workingDirectoryExists )
+        {
+            performAction( "update-agent-working-directory", buildContext );
+    
+            scmResult = ContinuumBuildAgentUtil.getUpdateScmResult( actionContext, null );
+    
+            date = ContinuumBuildAgentUtil.getLatestUpdateDate( actionContext );
+    
+            if ( date == null )
+            {
+                // try to get latest update date from change log because sometimes date in the changefile is 0
+                performAction( "changelog-agent-project", buildContext );
+    
+                date = ContinuumBuildAgentUtil.getLatestUpdateDate( actionContext );
+            }
+        }
+        else
+        {
+            Project project = ContinuumBuildAgentUtil.getProject( actionContext );
+    
+            actionContext.put( ContinuumBuildAgentUtil.KEY_WORKING_DIRECTORY,
+                               buildAgentConfigurationService.getWorkingDirectory( project.getId() ).getAbsolutePath() );
+    
+            performAction( "checkout-agent-project", buildContext );
+    
+            scmResult = ContinuumBuildAgentUtil.getCheckoutScmResult( actionContext, null );
+    
+            performAction( "changelog-agent-project", buildContext );
+    
+            date = ContinuumBuildAgentUtil.getLatestUpdateDate( actionContext );
+        }
+    
+        buildContext.setScmResult( scmResult );
+        buildContext.setLatestUpdateDate( date );
+        actionContext.put( ContinuumBuildAgentUtil.KEY_SCM_RESULT, scmResult );
+    }
+    
+    private void endProjectPrepareBuild( BuildContext buildContext )
+        throws TaskExecutionException
+    {
+        Map<String, Object> context = buildContext.getActionContext();
+    
+        ScmResult scmResult = ContinuumBuildAgentUtil.getScmResult( context, null );
+    
+        if ( scmResult == null || !scmResult.isSuccess() )
+        {
+            context.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_STATE, ContinuumProjectState.ERROR );
+        }
+        else
+        {
+            buildContext.setScmResult( scmResult );
+        }
+    }
+    
+    private void endPrepareBuild( Map context )
+        throws TaskExecutionException
+    {
+        if ( context != null )
+        {
+            Map<String, Object> result = new HashMap<String, Object>();
+            result.put( ContinuumBuildAgentUtil.KEY_PROJECT_GROUP_ID, new Integer( ContinuumBuildAgentUtil.getProjectGroupId( context ) ) );
+            result.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_ADDRESS, ContinuumBuildAgentUtil.getScmRootAddress( context ) );
+            result.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_STATE, new Integer( ContinuumBuildAgentUtil.getScmRootState( context ) ) );
+            
+            if ( ContinuumBuildAgentUtil.getScmRootState( context ) == ContinuumProjectState.ERROR )
+            {
+                String error = convertScmResultToError( ContinuumBuildAgentUtil.getScmResult( context, null ) );
+                
+                if ( StringUtils.isEmpty( error ) )
+                {
+                    result.put( ContinuumBuildAgentUtil.KEY_SCM_ERROR, "" );
+                }
+                else
+                {
+                    result.put( ContinuumBuildAgentUtil.KEY_SCM_ERROR, error );
+                }
+            }
+            else
+            {
+                result.put( ContinuumBuildAgentUtil.KEY_SCM_ERROR, "" );
+            }
+
+            try
+            {
+                buildAgentManager.endPrepareBuild( result );
+            }
+            catch ( ContinuumException e )
+            {
+                throw new TaskExecutionException( e.getMessage(), e );
+            }
+        }
+        else
+        {
+            throw new TaskExecutionException( "No project build context" );
+        }
+    }
+
+    private String convertScmResultToError( ScmResult result )
+    {
+        String error = "";
+
+        if ( result == null )
+        {
+            error = "Scm result is null.";
+        }
+        else
+        {
+            if ( result.getCommandLine() != null )
+            {
+                error = "Command line: " + StringUtils.clean( result.getCommandLine() ) +
+                    System.getProperty( "line.separator" );
+            }
+
+            if ( result.getProviderMessage() != null )
+            {
+                error = "Provider message: " + StringUtils.clean( result.getProviderMessage() ) +
+                    System.getProperty( "line.separator" );
+            }
+
+            if ( result.getCommandOutput() != null )
+            {
+                error += "Command output: " + System.getProperty( "line.separator" );
+                error += "-------------------------------------------------------------------------------" +
+                    System.getProperty( "line.separator" );
+                error += StringUtils.clean( result.getCommandOutput() ) + System.getProperty( "line.separator" );
+                error += "-------------------------------------------------------------------------------" +
+                    System.getProperty( "line.separator" );
+            }
+
+            if ( result.getException() != null )
+            {
+                error += "Exception:" + System.getProperty( "line.separator" );
+                error += result.getException();
+            }
+        }
+
+        return error;
+    }
+
+    private void performAction( String actionName, BuildContext buildContext )
+        throws TaskExecutionException
+    {
+        TaskExecutionException exception = null;
+    
+        try
+        {
+            log.info( "Performing action " + actionName );
+            actionManager.lookup( actionName ).execute( buildContext.getActionContext() );
+            return;
+        }
+        catch ( ActionNotFoundException e )
+        {
+            exception = new TaskExecutionException( "Error looking up action '" + actionName + "'", e );
+        }
+        catch ( Exception e )
+        {
+            exception = new TaskExecutionException( "Error executing action '" + actionName + "'", e );
+        }
+        
+        ScmResult result = new ScmResult();
+        
+        result.setSuccess( false );
+        
+        result.setException( ContinuumBuildAgentUtil.throwableToString( exception ) );
+
+        buildContext.setScmResult( result );
+        buildContext.getActionContext().put( ContinuumBuildAgentUtil.KEY_UPDATE_SCM_RESULT, result );
+        
+        throw exception;
+    }
+
+    private void mergeScmResults( BuildContext buildContext )
+    {
+        Map context = buildContext.getActionContext();
+        ScmResult oldScmResult = ContinuumBuildAgentUtil.getOldScmResult( context, null );
+        ScmResult newScmResult = ContinuumBuildAgentUtil.getScmResult( context, null );
+
+        if ( oldScmResult != null )
+        {
+            if ( newScmResult == null )
+            {
+                context.put( ContinuumBuildAgentUtil.KEY_SCM_RESULT, oldScmResult );
+            }
+            else
+            {
+                List<ChangeSet> oldChanges = oldScmResult.getChanges();
+
+                List<ChangeSet> newChanges = newScmResult.getChanges();
+
+                for ( ChangeSet change : newChanges )
+                {
+                    if ( !oldChanges.contains( change ) )
+                    {
+                        oldChanges.add( change );
+                    }
+                }
+
+                newScmResult.setChanges( oldChanges );
+            }
+        }
+    }
+
+    private void buildProjects( List<BuildContext> buildContexts )
+        throws TaskExecutionException
+    {
+        Map map = new HashMap();
+        map.put( ContinuumBuildAgentUtil.KEY_BUILD_CONTEXTS, buildContexts );
+        
+        BuildContext context = new BuildContext();
+        context.setActionContext( map );
+
+        performAction( "create-agent-build-project-task", context );
+    }
+}

Propchange: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/PrepareBuildProjectsTaskExecutor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/PrepareBuildProjectsTaskExecutor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/manager/BuildAgentTaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/manager/BuildAgentTaskQueueManager.java?rev=751433&r1=751432&r2=751433&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/manager/BuildAgentTaskQueueManager.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/manager/BuildAgentTaskQueueManager.java Sun Mar  8 14:41:33 2009
@@ -28,6 +28,8 @@
 
     TaskQueue getBuildQueue();
 
+    TaskQueue getPrepareBuildQueue();
+
     void cancelBuild()
         throws TaskQueueManagerException;
 
@@ -39,4 +41,7 @@
 
     boolean isProjectInBuildQueue( int projectId )
         throws TaskQueueManagerException;
+
+    boolean isInPrepareBuildQueue( int projectGroupId, int trigger, String scmRootAddress )
+        throws TaskQueueManagerException;
 }

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/manager/DefaultBuildAgentTaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/manager/DefaultBuildAgentTaskQueueManager.java?rev=751433&r1=751432&r2=751433&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/manager/DefaultBuildAgentTaskQueueManager.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/manager/DefaultBuildAgentTaskQueueManager.java Sun Mar  8 14:41:33 2009
@@ -21,8 +21,7 @@
 
 import java.util.List;
 
-import javax.annotation.Resource;
-
+import org.apache.continuum.buildagent.taskqueue.PrepareBuildProjectsTask;
 import org.apache.continuum.taskqueue.BuildProjectTask;
 import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
 import org.codehaus.plexus.PlexusConstants;
@@ -37,17 +36,25 @@
 import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
 
-@Service("buildAgentTaskQueueManager")
+/**
+ * @plexus.component role="org.apache.continuum.buildagent.taskqueue.manager.BuildAgentTaskQueueManager" role-hint="default"
+ */
 public class DefaultBuildAgentTaskQueueManager
     implements BuildAgentTaskQueueManager, Contextualizable
 {
     private Logger log = LoggerFactory.getLogger( this.getClass() );
 
-    @Resource
+    /**
+     * @plexus.requirement role-hint="build-agent"
+     */
     private TaskQueue buildAgentBuildQueue;
 
+    /**
+     * @plexus.requirement role-hint="prepare-build-agent"
+     */
+    private TaskQueue buildAgentPrepareBuildQueue;
+
     private PlexusContainer container;
 
     public void cancelBuild()
@@ -75,6 +82,11 @@
         }
         return -1;
     }
+
+    public TaskQueue getPrepareBuildQueue()
+    {
+        return buildAgentPrepareBuildQueue;
+    }
     
     private void removeProjectsFromBuildQueue()
         throws TaskQueueManagerException
@@ -187,6 +199,37 @@
         return false;
     }
 
+    public boolean isInPrepareBuildQueue( int projectGroupId, int trigger, String scmRootAddress )
+        throws TaskQueueManagerException
+    {
+        try
+        {
+            List<PrepareBuildProjectsTask> queues = buildAgentPrepareBuildQueue.getQueueSnapshot();
+        
+            if ( queues != null )
+            {
+                for ( PrepareBuildProjectsTask task : queues )
+                {
+                    if ( task.getProjectGroupId() == projectGroupId && task.getTrigger() == trigger && task.getScmRootAddress().equals( scmRootAddress ) )
+                    {
+                        log.info( "projects already in build queue" );
+                        return true;
+                    }
+                }
+            }
+            else
+            {
+                log.info( "no prepare build task in queue" );
+            }
+        }
+        catch ( TaskQueueException e )
+        {
+            throw new TaskQueueManagerException( e.getMessage(), e );
+        }
+
+        return false;
+    }
+
     public void contextualize( Context context )
         throws ContextException
     {

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java?rev=751433&r1=751432&r2=751433&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java Sun Mar  8 14:41:33 2009
@@ -68,9 +68,9 @@
 
     public static final String KEY_BUILD_FRESH = "build-fresh";
 
-    public static final String KEY_BUILD_START = "build-start";
+    public static final String KEY_START_TIME = "start-time";
 
-    public static final String KEY_BUILD_END = "build-end";
+    public static final String KEY_END_TIME = "end-time";
 
     public static final String KEY_BUILD_ERROR = "build-error";
 
@@ -206,6 +206,46 @@
 
     public static final String KEY_BUILD_AGENT_URL = "build-agent-url";
 
+    public static final String KEY_SCM_TAGBASE = "scm-tagbase";
+
+    public static final String KEY_PREPARE_GOALS = "preparation-goals";
+
+    public static final String KEY_SCM_COMMENT_PREFIX = "scm-comment-prefix";
+
+    public static final String KEY_AUTO_VERSION_SUBMODULES = "auto-version-submodules";
+
+    public static final String KEY_ADD_SCHEMA = "add-schema";
+
+    public static final String KEY_USE_RELEASE_PROFILE = "use-release-profile";
+
+    public static final String KEY_RELEASE_VERSION = "release-version";
+
+    public static final String KEY_DEVELOPMENT_VERSION = "development-version";
+
+    public static final String KEY_USE_EDIT_MODE = "use-edit-mode";
+
+    public static final String KEY_RELEASE_RESULT_CODE = "release-result-code";
+
+    public static final String KEY_RELEASE_OUTPUT = "release-output";
+
+    public static final String KEY_BUILD_CONTEXTS = "build-contexts";
+
+    public static final String KEY_MAX_JOB_EXEC_TIME = "max-job-exec-time";
+
+    public static final String KEY_RELEASE_STATE = "state";
+
+    public static final String KEY_RELEASE_PHASES = "release-phases";
+
+    public static final String KEY_RELEASE_IN_PROGRESS = "release-in-progress";
+
+    public static final String KEY_COMPLETED_RELEASE_PHASES = "completed-release-phases";
+
+    public static final String KEY_RELEASE_ERROR = "release-error";
+
+    public static final String KEY_LOCAL_REPOSITORY_NAME = "repo-name";
+
+    public static final String KEY_LOCAL_REPOSITORY_LAYOUT = "repo-layout";
+
     public static Integer getProjectId( Map context )
     {
         return getInteger( context, KEY_PROJECT_ID );
@@ -253,12 +293,12 @@
 
     public static String getScmUsername( Map context )
     {
-        return getString( context, KEY_SCM_USERNAME );
+        return getString( context, KEY_SCM_USERNAME, "" );
     }
 
     public static String getScmPassword( Map context )
     {
-        return getString( context, KEY_SCM_PASSWORD );
+        return getString( context, KEY_SCM_PASSWORD, "" );
     }
 
     public static boolean isBuildFresh( Map context )
@@ -323,7 +363,7 @@
 
     public static String getLocalRepository( Map context )
     {
-        return getString( context, KEY_LOCAL_REPOSITORY );
+        return getString( context, KEY_LOCAL_REPOSITORY, "" );
     }
 
     public static String getProjectVersion( Map context )
@@ -410,6 +450,81 @@
         return getString( context, KEY_BUILD_AGENT_URL );
     }
 
+    public static String getGroupId( Map context )
+    {
+        return getString( context, KEY_GROUP_ID );
+    }
+
+    public static String getArtifactId( Map context )
+    {
+        return getString( context, KEY_ARTIFACT_ID );
+    }
+
+    public static Map getReleaseVersion( Map context )
+    {
+        return getMap( context, KEY_RELEASE_VERSION );
+    }
+
+    public static Map getDevelopmentVersion( Map context )
+    {
+        return getMap( context, KEY_DEVELOPMENT_VERSION );
+    }
+
+    public static String getScmTagBase( Map context )
+    {
+        return getString( context, KEY_SCM_TAGBASE, "" );
+    }
+
+    public static String getScmCommentPrefix( Map context )
+    {
+        return getString( context, KEY_SCM_COMMENT_PREFIX, "" );
+    }
+
+    public static String getScmTag( Map context )
+    {
+        return getString( context, KEY_SCM_TAG, "" );
+    }
+
+    public static String getPrepareGoals( Map context )
+    {
+        return getString( context, KEY_PREPARE_GOALS, "" );
+    }
+
+    public static String getUseEditMode( Map context )
+    {
+        return getString( context, KEY_USE_EDIT_MODE, "" );
+    }
+
+    public static String getAddSchema( Map context )
+    {
+        return getString( context, KEY_ADD_SCHEMA, "" );
+    }
+
+    public static String getAutoVersionSubmodules( Map context )
+    {
+        return getString( context, KEY_AUTO_VERSION_SUBMODULES, "" );
+    }
+
+    public static List getBuildContexts( Map context )
+    {
+        return getList( context, KEY_BUILD_CONTEXTS );
+    }
+
+    public static int getMaxExecutionTime( Map context )
+    {
+        return getInteger( context, KEY_MAX_JOB_EXEC_TIME );
+    }
+
+    public static String getLocalRepositoryName( Map context )
+    {
+        return getString( context, KEY_LOCAL_REPOSITORY_NAME, "" );
+    }
+
+    public static String getLocalRepositoryLayout( Map context )
+    {
+        return getString( context, KEY_LOCAL_REPOSITORY_LAYOUT, "" );
+    }
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -459,19 +574,27 @@
         else
         {
             List list = new ArrayList();
-            Object[] objA = (Object[]) obj;
 
-            for ( Object o : objA )
+            if ( obj instanceof Object[] )
             {
-                if ( o instanceof Map )
-                {
-                    list.add( (Map) o );
-                }
-                else
+                Object[] objA = (Object[]) obj;
+    
+                for ( Object o : objA )
                 {
-                    list.add( o );
+                    if ( o instanceof Map )
+                    {
+                        list.add( (Map) o );
+                    }
+                    else
+                    {
+                        list.add( o );
+                    }
                 }
             }
+            else
+            {
+                list = (List) obj;
+            }
 
             return list;
         }
@@ -491,6 +614,20 @@
         }
     }
 
+    protected static Map getMap( Map context, String key )
+    {
+        Object obj = getObject( context, key, null );
+
+        if ( obj == null )
+        {
+            return null;
+        }
+        else
+        {
+            return (Map) obj;
+        }
+    }
+
     protected static Object getObject( Map context, String key )
     {
         if ( !context.containsKey( key ) )

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/resources/META-INF/plexus/components.xml?rev=751433&r1=751432&r2=751433&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/resources/META-INF/plexus/components.xml Sun Mar  8 14:41:33 2009
@@ -27,6 +27,13 @@
     </component>
 
     <component>
+      <role>org.codehaus.plexus.taskqueue.TaskQueue</role>
+      <role-hint>prepare-build-agent</role-hint>
+      <implementation>org.codehaus.plexus.taskqueue.DefaultTaskQueue</implementation>
+      <lifecycle-handler>plexus-configurable</lifecycle-handler>
+    </component>
+
+    <component>
       <role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role>
       <role-hint>build-agent</role-hint>
       <implementation>org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor</implementation>
@@ -45,5 +52,25 @@
         <name>build-agent</name>
       </configuration>
     </component>
+
+    <component>
+      <role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role>
+      <role-hint>prepare-build-agent</role-hint>
+      <implementation>org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor</implementation>
+      <instantiation-strategy>singleton</instantiation-strategy>
+      <requirements>
+        <requirement>
+          <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role>
+          <role-hint>prepare-build-agent</role-hint>
+        </requirement>
+        <requirement>
+          <role>org.codehaus.plexus.taskqueue.TaskQueue</role>
+          <role-hint>prepare-build-agent</role-hint>
+        </requirement>
+      </requirements>
+      <configuration>
+        <name>prepare-build-agent</name>
+      </configuration>
+    </component>
   </components>
 </component-set>
\ No newline at end of file

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/resources/META-INF/spring-context.xml?rev=751433&r1=751432&r2=751433&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/resources/META-INF/spring-context.xml (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/resources/META-INF/spring-context.xml Sun Mar  8 14:41:33 2009
@@ -38,7 +38,5 @@
      init-method="initialize">
     <property name="configurationFile" value="file:${CONTINUUM_BUILDAGENT_HOME}/conf/continuum-buildagent.xml" />
   </bean>
-
-  <bean id="actionManager" class="org.codehaus.plexus.action.DefaultActionManager"/>
 </beans>
 	
\ No newline at end of file

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-webapp/src/main/java/org/apache/continuum/web/startup/BuildAgentStartup.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-webapp/src/main/java/org/apache/continuum/web/startup/BuildAgentStartup.java?rev=751433&r1=751432&r2=751433&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-webapp/src/main/java/org/apache/continuum/web/startup/BuildAgentStartup.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-webapp/src/main/java/org/apache/continuum/web/startup/BuildAgentStartup.java Sun Mar  8 14:41:33 2009
@@ -36,5 +36,17 @@
         
         TaskQueueExecutor buildAgent = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils
             .buildSpringId( TaskQueueExecutor.class, "build-agent" ) );
+
+        TaskQueueExecutor prepareBuildAgent = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils
+            .buildSpringId( TaskQueueExecutor.class, "prepare-build-agent" ) );
+
+        TaskQueueExecutor prepareRelease = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils
+            .buildSpringId( TaskQueueExecutor.class, "prepare-release" ) );
+
+        TaskQueueExecutor performRelease = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils
+            .buildSpringId( TaskQueueExecutor.class, "perform-release" ) );
+
+        TaskQueueExecutor rollbackRelease = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils
+            .buildSpringId( TaskQueueExecutor.class, "rollback-release" ) ); 
     }
 }

Modified: continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java?rev=751433&r1=751432&r2=751433&view=diff
==============================================================================
--- continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java (original)
+++ continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java Sun Mar  8 14:41:33 2009
@@ -219,6 +219,7 @@
                 context.put( ContinuumBuildConstant.KEY_ALWAYS_BUILD, new Boolean( buildDef.isAlwaysBuild() ) );
                 context.put( ContinuumBuildConstant.KEY_OLD_SCM_CHANGES, getOldScmChanges( project.getId(), buildDefinitionId ) );
                 context.put( ContinuumBuildConstant.KEY_BUILD_AGENT_URL, buildAgentUrl );
+                context.put( ContinuumBuildConstant.KEY_MAX_JOB_EXEC_TIME, new Integer( buildDef.getSchedule().getMaxJobExecutionTime() ) );
 
                 buildContext.add( context );
             }

Modified: continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java?rev=751433&r1=751432&r2=751433&view=diff
==============================================================================
--- continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java (original)
+++ continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java Sun Mar  8 14:41:33 2009
@@ -56,9 +56,9 @@
 
     public static final String KEY_ALWAYS_BUILD = "always-build";
 
-    public static final String KEY_BUILD_START = "build-start";
+    public static final String KEY_START_TIME = "start-time";
 
-    public static final String KEY_BUILD_END = "build-end";
+    public static final String KEY_END_TIME = "end-time";
 
     public static final String KEY_BUILD_ERROR = "build-error";
 
@@ -176,6 +176,8 @@
 
     public static final String KEY_BUILD_AGENT_URL = "build-agent-url";
 
+    public static final String KEY_MAX_JOB_EXEC_TIME = "max-job-exec-time";
+
     public static int getProjectId( Map context )
     {
         return getInteger( context, KEY_PROJECT_ID );
@@ -196,14 +198,14 @@
         return getInteger( context, KEY_TRIGGER );
     }
 
-    public static long getBuildStart( Map context )
+    public static long getStartTime( Map context )
     {
-        return new Long( getString( context, KEY_BUILD_START ) );
+        return new Long( getString( context, KEY_START_TIME ) );
     }
 
-    public static long getBuildEnd( Map context )
+    public static long getEndTime( Map context )
     {
-        return new Long( getString( context, KEY_BUILD_END ) );
+        return new Long( getString( context, KEY_END_TIME ) );
     }
 
     public static int getBuildExitCode( Map context )

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java?rev=751433&r1=751432&r2=751433&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java Sun Mar  8 14:41:33 2009
@@ -1076,8 +1076,8 @@
     {
         BuildResult buildResult = new BuildResult();
 
-        buildResult.setStartTime( ContinuumBuildConstant.getBuildStart( context ) );
-        buildResult.setEndTime( ContinuumBuildConstant.getBuildEnd( context ) );
+        buildResult.setStartTime( ContinuumBuildConstant.getStartTime( context ) );
+        buildResult.setEndTime( ContinuumBuildConstant.getEndTime( context ) );
         buildResult.setError( ContinuumBuildConstant.getBuildError( context ) );
         buildResult.setExitCode( ContinuumBuildConstant.getBuildExitCode( context ) );
         buildResult.setState( ContinuumBuildConstant.getBuildState( context ) );

Added: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/DistributedReleaseUtil.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/DistributedReleaseUtil.java?rev=751433&view=auto
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/DistributedReleaseUtil.java (added)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/DistributedReleaseUtil.java Sun Mar  8 14:41:33 2009
@@ -0,0 +1,287 @@
+package org.apache.continuum.release.distributed;
+
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class DistributedReleaseUtil
+{
+    public static final String KEY_SCM_TAG = "scm-tag";
+
+    public static final String KEY_SCM_TAGBASE = "scm-tagbase";
+
+    public static final String KEY_SCM_USERNAME = "scm-username";
+
+    public static final String KEY_SCM_PASSWORD = "scm-password";
+
+    public static final String KEY_ARGUMENTS = "arguments";
+
+    public static final String KEY_PREPARE_GOALS = "preparation-goals";
+
+    public static final String KEY_SCM_COMMENT_PREFIX = "scm-comment-prefix";
+
+    public static final String KEY_AUTO_VERSION_SUBMODULES = "auto-version-submodules";
+
+    public static final String KEY_ADD_SCHEMA = "add-schema";
+
+    public static final String KEY_PROJECT = "project";
+
+    public static final String KEY_PROFILE = "profile";
+
+    public static final String KEY_PROPERTIES = "properties";
+
+    public static final String KEY_RELEASE_VERSION = "releaseVersion";
+
+    public static final String KEY_DEVELOPMENT_VERSION = "developmentVersion";
+
+    public static final String KEY_PROJECT_ID = "project-id";
+
+    public static final String KEY_GROUP_ID = "group-id";
+
+    public static final String KEY_ARTIFACT_ID = "artifact-id";
+
+    public static final String KEY_SCM_URL = "scm-url";
+
+    public static final String KEY_LOCAL_REPOSITORY = "local-repository";
+
+    public static final String KEY_USE_EDIT_MODE = "use-edit-mode";
+
+    public static final String KEY_ENVIRONMENTS = "environments";
+
+    public static final String KEY_START_TIME = "start-time";
+
+    public static final String KEY_END_TIME = "end-time";
+
+    public static final String KEY_RELEASE_RESULT_CODE = "release-result-code";
+
+    public static final String KEY_RELEASE_OUTPUT = "release-output";
+
+    public static final String KEY_RELEASE_STATE = "state";
+
+    public static final String KEY_RELEASE_PHASES = "release-phases";
+
+    public static final String KEY_COMPLETED_RELEASE_PHASES = "completed-release-phases";
+
+    public static final String KEY_RELEASE_IN_PROGRESS = "release-in-progress";
+
+    public static final String KEY_RELEASE_ERROR = "release-error";
+
+    public static final String KEY_USE_RELEASE_PROFILE = "use-release-profile";
+
+    public static final String KEY_GOALS = "goals";
+
+    public static final String KEY_RELEASE_ID = "release-id";
+
+    public static final String KEY_LOCAL_REPOSITORY_NAME = "repo-name";
+
+    public static final String KEY_LOCAL_REPOSITORY_LAYOUT = "repo-layout";
+
+    public static String getScmTag( Map context, String defaultValue )
+    {
+        return getString( context, KEY_SCM_TAG, defaultValue );
+    }
+
+    public static String getScmTagBase( Map context, String defaultValue )
+    {
+        return getString( context, KEY_SCM_TAGBASE, defaultValue );
+    }
+
+    public static String getArguments( Map context, String defaultValue )
+    {
+        return getString( context, KEY_ARGUMENTS, defaultValue );
+    }
+
+    public static String getPrepareGoals( Map context, String defaultValue )
+    {
+        return getString( context, KEY_PREPARE_GOALS, defaultValue );
+    }
+
+    public static String getScmCommentPrefix( Map context, String defaultValue )
+    {
+        return getString( context, KEY_SCM_COMMENT_PREFIX, defaultValue );
+    }
+
+    public static Boolean getAutoVersionSubmodules( Map context, boolean defaultValue )
+    {
+        return getBoolean( context, KEY_AUTO_VERSION_SUBMODULES, defaultValue );
+    }
+
+    public static Boolean getAddSchema( Map context, boolean defaultValue )
+    {
+        return getBoolean( context, KEY_ADD_SCHEMA, defaultValue );
+    }
+
+    public static Long getStartTime( Map context )
+    {
+        return new Long( getString( context, KEY_START_TIME ) );
+    }
+
+    public static Long getEndTime( Map context )
+    {
+        return new Long( getString( context, KEY_END_TIME ) );
+    }
+
+    public static int getReleaseResultCode( Map context )
+    {
+        return getInteger( context, KEY_RELEASE_RESULT_CODE );
+    }
+
+    public static String getReleaseOutput( Map context )
+    {
+        return getString( context, KEY_RELEASE_OUTPUT );
+    }
+
+    public static int getReleaseState( Map context )
+    {
+        return getInteger( context, KEY_RELEASE_STATE );
+    }
+
+    public static List getReleasePhases( Map context )
+    {
+        return getList( context, KEY_RELEASE_PHASES, new ArrayList() );
+    }
+
+    public static List getCompletedReleasePhases( Map context )
+    {
+        return getList( context, KEY_COMPLETED_RELEASE_PHASES, new ArrayList() );
+    }
+
+    public static String getReleaseInProgress( Map context )
+    {
+        return getString( context, KEY_RELEASE_IN_PROGRESS, "" );
+    }
+
+    public static String getReleaseError( Map context )
+    {
+        return getString( context, KEY_RELEASE_ERROR, null );
+    }
+
+    public static boolean getUseReleaseProfile( Map context, boolean defaultValue )
+    {
+        return getBoolean( context, KEY_USE_RELEASE_PROFILE, defaultValue );
+    }
+
+    public static String getGoals( Map context, String defaultValue )
+    {
+        return getString( context, KEY_GOALS, defaultValue );
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    public static Integer getInteger( Map context, String key )
+    {
+        return (Integer) getObject( context, key );
+    }
+
+    public static Integer getInteger( Map context, String key, Object defaultValue )
+    {
+        return (Integer) getObject( context, key, defaultValue );
+    }
+
+    public static String getString( Map context, String key )
+    {
+        return (String) getObject( context, key );
+    }
+
+    public static String getString( Map context, String key, String defaultValue )
+    {
+        return (String) getObject( context, key, defaultValue );
+    }
+
+    public static boolean getBoolean( Map context, String key )
+    {
+        return ( (Boolean) getObject( context, key ) ).booleanValue();
+    }
+    
+    public static boolean getBoolean( Map context, String key, boolean defaultValue )
+    {
+        return ( (Boolean) getObject( context, key, Boolean.valueOf( defaultValue ) ) ).booleanValue();
+    }
+
+    public static List getList( Map context, String key, Object defaultValue )
+    {
+        Object obj = getObject( context, key, defaultValue );
+
+        if ( obj == null )
+        {
+            return null;
+        }
+        else
+        {
+            List list = new ArrayList();
+
+            if ( obj instanceof Object[] )
+            {
+                Object[] objA = (Object[]) obj;
+    
+                for ( Object o : objA )
+                {
+                    if ( o instanceof Map )
+                    {
+                        list.add( (Map) o );
+                    }
+                    else
+                    {
+                        list.add( o );
+                    }
+                }
+            }
+            else
+            {
+                list = (List) obj;
+            }
+
+            return list;
+        }
+    }
+
+    protected static Object getObject( Map context, String key )
+    {
+        if ( !context.containsKey( key ) )
+        {
+            throw new RuntimeException( "Missing key '" + key + "'." );
+        }
+
+        Object value = context.get( key );
+
+        if ( value == null )
+        {
+            throw new RuntimeException( "Missing value for key '" + key + "'." );
+        }
+
+        return value;
+    }
+
+    protected static Object getObject( Map context, String key, Object defaultValue )
+    {
+        Object value = context.get( key );
+
+        if ( value == null )
+        {
+            return defaultValue;
+        }
+
+        return value;
+    }
+}
\ No newline at end of file

Propchange: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/DistributedReleaseUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/DistributedReleaseUtil.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message