continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r740587 [1/2] - in /continuum/trunk: continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/ continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ continuum-buildagent/continuum-b...
Date Wed, 04 Feb 2009 03:23:32 GMT
Author: ctan
Date: Wed Feb  4 03:23:31 2009
New Revision: 740587

URL: http://svn.apache.org/viewvc?rev=740587&view=rev
Log:
[CONTINUUM-2057] fix update of project from working copy


Added:
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateProjectFromWorkingDirectoryAction.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/BuildAgentMavenOneMetadataHelper.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/BuildAgentMavenOneMetadataHelperException.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/DefaultBuildAgentMavenOneMetadataHelper.java
Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/AbstractBuildExecutor.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/ContinuumAgentBuildExecutor.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/ant/AntBuildExecutor.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/MavenOneBuildExecutor.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/BuildAgentMavenBuilderHelper.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/DefaultBuildAgentMavenBuilderHelper.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/MavenTwoBuildExecutor.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/shell/ShellBuildExecutor.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentManager.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/BuildContextToProject.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/resources/META-INF/spring-context.xml
    continuum/trunk/continuum-buildagent/continuum-buildagent-webapp/src/main/webapp/WEB-INF/web.xml
    continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java
    continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
    continuum/trunk/continuum-distributed/continuum-distributed-master/continuum-distributed-master-api/src/main/java/org/apache/continuum/distributed/transport/master/MasterBuildAgentTransportService.java
    continuum/trunk/continuum-distributed/continuum-distributed-master/continuum-distributed-master-client/src/main/java/org/apache/continuum/distributed/transport/master/MasterBuildAgentTransportClient.java
    continuum/trunk/continuum-distributed/continuum-distributed-master/continuum-distributed-master-server/src/main/java/org/apache/continuum/distributed/transport/master/MasterBuildAgentTransportServer.java
    continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-api/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportService.java
    continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-client/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportClient.java
    continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-server/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportServer.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java?rev=740587&r1=740586&r2=740587&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java Wed Feb  4 03:23:31 2009
@@ -66,4 +66,7 @@
 
     Map<String, String> getEnvironments( int buildDefinitionId, String installationType )
         throws ContinuumException;
+
+    void updateProject( Map context )
+        throws ContinuumException;
 }

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java?rev=740587&r1=740586&r2=740587&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java Wed Feb  4 03:23:31 2009
@@ -24,6 +24,9 @@
 
 public interface ContinuumBuildAgentService
 {
+    void updateProjects( List<Map> projectsBuildContext )
+        throws ContinuumBuildAgentException;
+
     void buildProjects( List<Map> projectsBuildContext )
         throws ContinuumBuildAgentException;
     

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java?rev=740587&r1=740586&r2=740587&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java Wed Feb  4 03:23:31 2009
@@ -36,6 +36,9 @@
 import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.BuildResult;
+import org.apache.maven.continuum.model.scm.ChangeFile;
+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.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
@@ -70,7 +73,7 @@
      */
     private BuildContextManager buildContextManager;
 
-    public void buildProjects( List<Map> projectsBuildContext )
+    public void updateProjects( List<Map> projectsBuildContext )
         throws ContinuumBuildAgentException
     {
         List<BuildContext> buildContextList = initializeBuildContext( projectsBuildContext );
@@ -85,6 +88,21 @@
         }
     }
 
+    public void buildProjects( List<Map> projectsBuildContext )
+        throws ContinuumBuildAgentException
+    {
+        List<BuildContext> buildContextList = initializeBuildContext( projectsBuildContext );
+
+        try
+        {
+            buildAgentManager.buildProjects( buildContextList );
+        }
+        catch ( ContinuumException e )
+        {
+            throw new ContinuumBuildAgentException( e.getMessage(), e );
+        }
+    }
+
     public List<Map> getAvailableInstallations()
         throws ContinuumBuildAgentException
     {
@@ -233,6 +251,7 @@
         {
             BuildContext context = new BuildContext();
             context.setProjectId( ContinuumBuildAgentUtil.getProjectId( map ) );
+            context.setProjectVersion( ContinuumBuildAgentUtil.getProjectVersion( map ) );
             context.setBuildDefinitionId( ContinuumBuildAgentUtil.getBuildDefinitionId( map ) );
             context.setBuildFile( ContinuumBuildAgentUtil.getBuildFile( map ) );
             context.setExecutorId( ContinuumBuildAgentUtil.getExecutorId( map ) );
@@ -243,11 +262,15 @@
             context.setScmPassword( ContinuumBuildAgentUtil.getScmPassword( map ) );
             context.setBuildFresh( ContinuumBuildAgentUtil.isBuildFresh( map ) );
             context.setProjectGroupId( ContinuumBuildAgentUtil.getProjectGroupId( map ) );
+            context.setProjectGroupName( ContinuumBuildAgentUtil.getProjectGroupName( map ) );
             context.setScmRootAddress( ContinuumBuildAgentUtil.getScmRootAddress( map ) );
             context.setProjectName( ContinuumBuildAgentUtil.getProjectName( map ) );
             context.setProjectState( ContinuumBuildAgentUtil.getProjectState( map ) );
             context.setTrigger( ContinuumBuildAgentUtil.getTrigger( map ) );
             context.setLocalRepository( ContinuumBuildAgentUtil.getLocalRepository( map ) );
+            context.setBuildNumber( ContinuumBuildAgentUtil.getBuildNumber( map ) );
+            context.setOldScmResult( getOldScmResult( map ) );
+            //context.setScmResult( context.getOldScmResult() );
 
             buildContext.add( context );
         }
@@ -276,4 +299,46 @@
 
         return null;
     }
+
+    private ScmResult getOldScmResult( Map context )
+    {
+        ScmResult oldScmResult = null;
+
+        List<Map> scmChanges = ContinuumBuildAgentUtil.getOldScmChanges( context );
+
+        if ( scmChanges != null && scmChanges.size() > 0 )
+        {
+            oldScmResult = new ScmResult();
+            
+            for ( Map map : scmChanges )
+            {
+                ChangeSet changeSet = new ChangeSet();
+                changeSet.setAuthor( ContinuumBuildAgentUtil.getChangeSetAuthor( map ) );
+                changeSet.setComment( ContinuumBuildAgentUtil.getChangeSetComment( map ) );
+                changeSet.setDate( ContinuumBuildAgentUtil.getChangeSetDate( map ) );
+                setChangeFiles( changeSet, map );
+                oldScmResult.addChange( changeSet );
+            }
+        }
+
+        return oldScmResult;
+    }
+
+    private void setChangeFiles( ChangeSet changeSet, Map context )
+    {
+        List<Map> files = ContinuumBuildAgentUtil.getChangeSetFiles( context );
+
+        if ( files != null )
+        {
+            for ( Map map : files )
+            {
+                ChangeFile changeFile = new ChangeFile();
+                changeFile.setName( ContinuumBuildAgentUtil.getChangeFileName( map ) );
+                changeFile.setRevision( ContinuumBuildAgentUtil.getChangeFileRevision( map ) );
+                changeFile.setStatus( ContinuumBuildAgentUtil.getChangeFileStatus( map ) );
+
+                changeSet.addFile( changeFile );
+            }
+        }
+    }
 }

Added: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateProjectFromWorkingDirectoryAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateProjectFromWorkingDirectoryAction.java?rev=740587&view=auto
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateProjectFromWorkingDirectoryAction.java (added)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateProjectFromWorkingDirectoryAction.java Wed Feb  4 03:23:31 2009
@@ -0,0 +1,51 @@
+package org.apache.continuum.buildagent.action;
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.continuum.buildagent.build.execution.ContinuumAgentBuildExecutor;
+import org.apache.continuum.buildagent.build.execution.manager.BuildAgentBuildExecutorManager;
+import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationService;
+import org.apache.continuum.buildagent.utils.ContinuumBuildAgentUtil;
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.Project;
+import org.codehaus.plexus.action.AbstractAction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @plexus.component role="org.codehaus.plexus.action.Action"  
+ * role-hint="update-project-from-agent-working-directory"
+ */
+public class UpdateProjectFromWorkingDirectoryAction
+    extends AbstractAction
+{
+    private Logger logger = LoggerFactory.getLogger( getClass() );
+
+    /**
+    * @plexus.requirement
+    */
+    private BuildAgentBuildExecutorManager buildAgentBuildExecutorManager;
+
+    /**
+    * @plexus.requirement
+    */
+    private BuildAgentConfigurationService buildAgentConfigurationService;
+
+    public void execute( Map context )
+        throws Exception
+    {
+        Project project = ContinuumBuildAgentUtil.getProject( context );
+
+        logger.info( "Updating project '" + project.getName() + "' from checkout." );
+
+        BuildDefinition buildDefinition = ContinuumBuildAgentUtil.getBuildDefinition( context );
+
+        File workingDirectory = buildAgentConfigurationService.getWorkingDirectory( project.getId() );
+
+        ContinuumAgentBuildExecutor buildExecutor = buildAgentBuildExecutorManager.getBuildExecutor( project.getExecutorId() );
+
+        buildExecutor.updateProjectFromWorkingDirectory( workingDirectory, project, buildDefinition );
+    }
+
+}

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java?rev=740587&r1=740586&r2=740587&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java Wed Feb  4 03:23:31 2009
@@ -30,8 +30,11 @@
 import org.apache.continuum.scm.ContinuumScmConfiguration;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.scm.ChangeFile;
+import org.apache.maven.continuum.model.scm.ChangeSet;
 import org.apache.maven.continuum.model.scm.ScmResult;
 import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFile;
 import org.apache.maven.scm.command.update.UpdateScmResult;
 import org.apache.maven.scm.manager.NoSuchScmProviderException;
 import org.apache.maven.scm.repository.ScmRepositoryException;
@@ -151,10 +154,78 @@
 
         result.setProviderMessage( scmResult.getProviderMessage() );
 
+        if ( scmResult.getChanges() != null && !scmResult.getChanges().isEmpty() )
+        {
+            for ( org.apache.maven.scm.ChangeSet scmChangeSet : (List<org.apache.maven.scm.ChangeSet>) scmResult.getChanges() )
+            {
+                ChangeSet change = new ChangeSet();
+
+                change.setAuthor( scmChangeSet.getAuthor() );
+
+                change.setComment( scmChangeSet.getComment() );
+
+                if ( scmChangeSet.getDate() != null )
+                {
+                    change.setDate( scmChangeSet.getDate().getTime() );
+                }
+
+                if ( scmChangeSet.getFiles() != null )
+                {
+                    for ( org.apache.maven.scm.ChangeFile f : (List<org.apache.maven.scm.ChangeFile>) scmChangeSet.getFiles() )
+                    {
+                        ChangeFile file = new ChangeFile();
+
+                        file.setName( f.getName() );
+
+                        file.setRevision( f.getRevision() );
+
+                        change.addFile( file );
+                    }
+                }
+
+                result.addChange( change );
+            }
+        }
+        else
+        {
+            // We don't have a changes information probably because provider doesn't have a changelog command
+            // so we use the updated list that contains only the updated files list
+            ChangeSet changeSet = convertScmFileSetToChangeSet( scmResult.getUpdatedFiles() );
+
+            if ( changeSet != null )
+            {
+                result.addChange( changeSet );
+            }
+        }
         return result;
     }
-    
- // TODO: migrate to the SvnCommandLineUtils version (preferably properly encapsulated in the provider)
+
+    private static ChangeSet convertScmFileSetToChangeSet( List<ScmFile> files )
+    {
+        ChangeSet changeSet = null;
+
+        if ( files != null && !files.isEmpty() )
+        {
+            changeSet = new ChangeSet();
+
+            // TODO: author, etc.
+            for ( ScmFile scmFile : files )
+            {
+                ChangeFile file = new ChangeFile();
+
+                file.setName( scmFile.getPath() );
+
+                // TODO: revision?
+
+                file.setStatus( scmFile.getStatus().toString() );
+
+                changeSet.addFile( file );
+            }
+        }
+        return changeSet;
+    }
+
+    // TODO: migrate to the SvnCommandLineUtils version (preferably properly encapsulated in the provider)
     private String maskPassword( String commandLine )
     {
         String cmd = commandLine;

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/AbstractBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/AbstractBuildExecutor.java?rev=740587&r1=740586&r2=740587&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/AbstractBuildExecutor.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/AbstractBuildExecutor.java Wed Feb  4 03:23:31 2009
@@ -20,18 +20,25 @@
  */
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 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.manager.BuildAgentManager;
+import org.apache.continuum.buildagent.utils.ContinuumBuildAgentUtil;
 import org.apache.continuum.buildagent.utils.shell.ExecutionResult;
 import org.apache.continuum.buildagent.utils.shell.BuildAgentShellCommandHelper;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectDependency;
+import org.apache.maven.continuum.model.project.ProjectDeveloper;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.project.ContinuumProjectState;
 import org.codehaus.plexus.commandline.ExecutableResolver;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
@@ -71,6 +78,11 @@
      */
     private String defaultExecutable;
 
+    /**
+     * @plexus.requirement
+     */
+    private BuildAgentManager buildAgentManager;
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -79,7 +91,7 @@
 
     private boolean resolveExecutable;
 
- // ----------------------------------------------------------------------
+    // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
 
@@ -125,6 +137,16 @@
         this.buildAgentInstallationService = buildAgentInstallationService;
     }
 
+    public BuildAgentManager getBuildAgentManager()
+    {
+        return buildAgentManager;
+    }
+
+    public void setBuildAgentManager( BuildAgentManager buildAgentManager )
+    {
+        this.buildAgentManager = buildAgentManager;
+    }
+
     // ----------------------------------------------------------------------
     // Component Lifecycle
     // ----------------------------------------------------------------------
@@ -292,6 +314,160 @@
         return buildFile;
     }
 
+    protected void updateProject( Project project )
+        throws ContinuumAgentBuildExecutorException
+    {
+        Map projectMap = new HashMap();
+
+        projectMap.put( ContinuumBuildAgentUtil.KEY_PROJECT_ID, new Integer( project.getId() ) );
+        projectMap.put( ContinuumBuildAgentUtil.KEY_PROJECT_VERSION, project.getVersion() );
+        projectMap.put( ContinuumBuildAgentUtil.KEY_ARTIFACT_ID, project.getArtifactId() );
+        projectMap.put( ContinuumBuildAgentUtil.KEY_GROUP_ID, project.getGroupId() );
+        if ( StringUtils.isNotEmpty( project.getName() ) )
+        {
+            projectMap.put( ContinuumBuildAgentUtil.KEY_PROJECT_NAME, project.getName() );
+        }
+        else
+        {
+            projectMap.put( ContinuumBuildAgentUtil.KEY_PROJECT_NAME, "" );
+        }
+        if ( StringUtils.isNotEmpty( project.getDescription() ) )
+        {
+            projectMap.put( ContinuumBuildAgentUtil.KEY_PROJECT_DESCRIPTION, project.getDescription() );
+        }
+        else
+        {
+            projectMap.put( ContinuumBuildAgentUtil.KEY_PROJECT_DESCRIPTION, "" );
+        }
+        if ( StringUtils.isNotEmpty( project.getScmUrl() ) )
+        {
+            projectMap.put( ContinuumBuildAgentUtil.KEY_SCM_URL, project.getScmUrl() );
+        }
+        else
+        {
+            projectMap.put( ContinuumBuildAgentUtil.KEY_SCM_URL, "" );
+        }
+        if ( StringUtils.isNotEmpty( project.getScmTag() ) )
+        {
+            projectMap.put( ContinuumBuildAgentUtil.KEY_SCM_TAG, project.getScmTag() );
+        }
+        else
+        {
+            projectMap.put( ContinuumBuildAgentUtil.KEY_SCM_TAG, "" );
+        }
+        if ( StringUtils.isNotEmpty( project.getUrl() ) )
+        {
+            projectMap.put( ContinuumBuildAgentUtil.KEY_PROJECT_URL, project.getUrl() );
+        }
+        else
+        {
+            projectMap.put( ContinuumBuildAgentUtil.KEY_PROJECT_URL, "" );
+        }
+        projectMap.put( ContinuumBuildAgentUtil.KEY_PROJECT_PARENT, getProjectParent( project.getParent() ) );
+        projectMap.put( ContinuumBuildAgentUtil.KEY_PROJECT_DEVELOPERS, getProjectDevelopers( project.getDevelopers() ) );
+        projectMap.put( ContinuumBuildAgentUtil.KEY_PROJECT_DEPENDENCIES, getProjectDependencies( project.getDependencies() ) );
+        projectMap.put( ContinuumBuildAgentUtil.KEY_PROJECT_NOTIFIERS, getProjectNotifiers( project.getNotifiers() ) );
+
+        try
+        {
+            buildAgentManager.updateProject( projectMap );
+        }
+        catch ( Exception e )
+        {
+            throw new ContinuumAgentBuildExecutorException( "Failed to update project", e );
+        }
+    }
+
+    protected List<Map> getProjectDevelopers( List<ProjectDeveloper> developers )
+    {
+        List<Map> pDevelopers = new ArrayList<Map>();
+
+        if ( developers != null )
+        {
+            for ( ProjectDeveloper developer : developers )
+            {
+                Map map = new HashMap();
+                map.put( ContinuumBuildAgentUtil.KEY_PROJECT_DEVELOPER_NAME, developer.getName() );
+                map.put( ContinuumBuildAgentUtil.KEY_PROJECT_DEVELOPER_EMAIL, developer.getEmail() );
+                map.put( ContinuumBuildAgentUtil.KEY_PROJECT_DEVELOPER_SCMID, developer.getScmId() );
+
+                pDevelopers.add( map );
+            }
+        }
+        return pDevelopers;
+    }
+
+    protected Map getProjectParent( ProjectDependency parent )
+    {
+        Map map = new HashMap();
+
+        if ( parent != null )
+        {
+            map.put( ContinuumBuildAgentUtil.KEY_GROUP_ID, parent.getGroupId() );
+            map.put( ContinuumBuildAgentUtil.KEY_ARTIFACT_ID, parent.getArtifactId() );
+            map.put( ContinuumBuildAgentUtil.KEY_PROJECT_VERSION, parent.getVersion() );
+        }
+        return map;
+    }
+
+    protected List<Map> getProjectDependencies( List<ProjectDependency> dependencies )
+    {
+        List<Map> pDependencies = new ArrayList<Map>();
+
+        if ( dependencies != null )
+        {
+            for ( ProjectDependency dependency : dependencies )
+            {
+                Map map = new HashMap();
+                map.put( ContinuumBuildAgentUtil.KEY_GROUP_ID, dependency.getGroupId() );
+                map.put( ContinuumBuildAgentUtil.KEY_ARTIFACT_ID, dependency.getArtifactId() );
+                map.put( ContinuumBuildAgentUtil.KEY_PROJECT_VERSION, dependency.getVersion() );
+
+                pDependencies.add( map );
+            }
+        }
+        return pDependencies;
+    }
+
+    protected List<Map> getProjectNotifiers( List<ProjectNotifier> notifiers )
+    {
+        List<Map> pNotifiers = new ArrayList<Map>();
+
+        if ( notifiers != null )
+        {
+            for ( ProjectNotifier notifier : notifiers )
+            {
+                Map map = new HashMap();
+
+                if ( notifier.getConfiguration() != null )
+                {
+                    map.put( ContinuumBuildAgentUtil.KEY_NOTIFIER_CONFIGURATION, notifier.getConfiguration() );
+                }
+                else
+                {
+
+                }
+                if ( StringUtils.isNotBlank( notifier.getType() ) )
+                {
+                    map.put( ContinuumBuildAgentUtil.KEY_NOTIFIER_TYPE, notifier.getType() );
+                }
+                else
+                {
+                    map.put( ContinuumBuildAgentUtil.KEY_NOTIFIER_TYPE, "" );
+                }
+                map.put( ContinuumBuildAgentUtil.KEY_NOTIFIER_FROM, new Integer( notifier.getFrom() ) );
+                map.put( ContinuumBuildAgentUtil.KEY_NOTIFIER_RECIPIENT_TYPE, new Integer( notifier.getRecipientType() ) );
+                map.put( ContinuumBuildAgentUtil.KEY_NOTIFIER_ENABLED, new Boolean( notifier.isEnabled() ) );
+                map.put( ContinuumBuildAgentUtil.KEY_NOTIFIER_SEND_ON_ERROR, new Boolean( notifier.isSendOnError() ) );
+                map.put( ContinuumBuildAgentUtil.KEY_NOTIFIER_SEND_ON_SUCCESS, new Boolean( notifier.isSendOnSuccess() ) );
+                map.put( ContinuumBuildAgentUtil.KEY_NOTIFIER_SEND_ON_FAILURE, new Boolean( notifier.isSendOnFailure() ) );
+                map.put( ContinuumBuildAgentUtil.KEY_NOTIFIER_SEND_ON_SCMFAILURE, new Boolean( notifier.isSendOnScmFailure() ) );
+                map.put( ContinuumBuildAgentUtil.KEY_NOTIFIER_SEND_ON_WARNING, new Boolean( notifier.isSendOnWarning() ) );
+            }
+        }
+        return pNotifiers;
+    }
+
     public boolean isBuilding( Project project )
     {
         return project.getState() == ContinuumProjectState.BUILDING ||

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/ContinuumAgentBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/ContinuumAgentBuildExecutor.java?rev=740587&r1=740586&r2=740587&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/ContinuumAgentBuildExecutor.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/ContinuumAgentBuildExecutor.java Wed Feb  4 03:23:31 2009
@@ -34,7 +34,7 @@
     ContinuumAgentBuildExecutionResult build( Project project, BuildDefinition buildDefinition, File buildOutput,
                                               Map<String, String> environments, String localRepository )
         throws ContinuumAgentBuildExecutorException, ContinuumAgentBuildCancelledException;
-    
+
     boolean isBuilding( Project project );
 
     void killProcess( Project project );
@@ -42,4 +42,7 @@
     // TODO: are these part of the builder interface, or a separate project/build definition interface?
     List<Artifact> getDeployableArtifacts( Project project, File workingDirectory, BuildDefinition buildDefinition )
         throws ContinuumAgentBuildExecutorException;
+
+    void updateProjectFromWorkingDirectory( File workingDirectory, Project project, BuildDefinition buildDefinition )
+        throws ContinuumAgentBuildExecutorException;
 }

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/ant/AntBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/ant/AntBuildExecutor.java?rev=740587&r1=740586&r2=740587&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/ant/AntBuildExecutor.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/ant/AntBuildExecutor.java Wed Feb  4 03:23:31 2009
@@ -94,4 +94,11 @@
 
         return executeShellCommand( project, executable, arguments.toString(), buildOutput, environments );
     }
+
+    public void updateProjectFromWorkingDirectory( File workingDirectory, Project project,
+                                                   BuildDefinition buildDefinition )
+        throws ContinuumAgentBuildExecutorException
+    {
+        // nothing to do here
+    }
 }

Added: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/BuildAgentMavenOneMetadataHelper.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/BuildAgentMavenOneMetadataHelper.java?rev=740587&view=auto
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/BuildAgentMavenOneMetadataHelper.java (added)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/BuildAgentMavenOneMetadataHelper.java Wed Feb  4 03:23:31 2009
@@ -0,0 +1,14 @@
+package org.apache.continuum.buildagent.build.execution.maven.m1;
+
+import java.io.File;
+
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
+
+public interface BuildAgentMavenOneMetadataHelper
+{
+    String ROLE = BuildAgentMavenOneMetadataHelper.class.getName();
+
+    void mapMetadata( ContinuumProjectBuildingResult result, File metadata, Project project )
+        throws BuildAgentMavenOneMetadataHelperException;
+}

Added: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/BuildAgentMavenOneMetadataHelperException.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/BuildAgentMavenOneMetadataHelperException.java?rev=740587&view=auto
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/BuildAgentMavenOneMetadataHelperException.java (added)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/BuildAgentMavenOneMetadataHelperException.java Wed Feb  4 03:23:31 2009
@@ -0,0 +1,20 @@
+package org.apache.continuum.buildagent.build.execution.maven.m1;
+
+public class BuildAgentMavenOneMetadataHelperException
+    extends Exception
+{
+    public BuildAgentMavenOneMetadataHelperException( String message )
+    {
+        super( message );
+    }
+
+    public BuildAgentMavenOneMetadataHelperException( Throwable cause )
+    {
+        super( cause );
+    }
+
+    public BuildAgentMavenOneMetadataHelperException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}

Added: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/DefaultBuildAgentMavenOneMetadataHelper.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/DefaultBuildAgentMavenOneMetadataHelper.java?rev=740587&view=auto
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/DefaultBuildAgentMavenOneMetadataHelper.java (added)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/DefaultBuildAgentMavenOneMetadataHelper.java Wed Feb  4 03:23:31 2009
@@ -0,0 +1,349 @@
+package org.apache.continuum.buildagent.build.execution.maven.m1;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectDependency;
+import org.apache.maven.continuum.model.project.ProjectDeveloper;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+@Service("buildAgentMavenOneMetadataHelper")
+public class DefaultBuildAgentMavenOneMetadataHelper
+    implements BuildAgentMavenOneMetadataHelper
+{
+    private Logger log = LoggerFactory.getLogger( getClass() );
+
+    public void mapMetadata( ContinuumProjectBuildingResult result, File metadata, Project project )
+        throws BuildAgentMavenOneMetadataHelperException
+    {
+        Xpp3Dom mavenProject;
+
+        try
+        {
+            mavenProject = Xpp3DomBuilder.build( new FileReader( metadata ) );
+        }
+        catch ( XmlPullParserException e )
+        {
+            result.addError( ContinuumProjectBuildingResult.ERROR_XML_PARSE );
+
+            log.info( "Error while reading maven POM (" + e.getMessage() + ").", e );
+
+            return;
+        }
+        catch ( FileNotFoundException e )
+        {
+            result.addError( ContinuumProjectBuildingResult.ERROR_POM_NOT_FOUND );
+
+            log.info( "Error while reading maven POM (" + e.getMessage() + ").", e );
+
+            return;
+        }
+        catch ( IOException e )
+        {
+            result.addError( ContinuumProjectBuildingResult.ERROR_UNKNOWN );
+
+            log.info( "Error while reading maven POM (" + e.getMessage() + ").", e );
+
+            return;
+        }
+
+        // ----------------------------------------------------------------------
+        // We cannot deal with projects that use the <extend/> element because
+        // we don't have the whole source tree and we might be missing elements
+        // that are present in the parent.
+        // ----------------------------------------------------------------------
+
+        String extend = getValue( mavenProject, "extend", null );
+
+        if ( extend != null )
+        {
+            result.addError( ContinuumProjectBuildingResult.ERROR_EXTEND );
+
+            log.info( "Cannot use a POM with an 'extend' element." );
+
+            return;
+        }
+
+        // ----------------------------------------------------------------------
+        // Artifact and group id
+        // ----------------------------------------------------------------------
+
+        String groupId;
+
+        String artifactId;
+
+        String id = getValue( mavenProject, "id", null );
+
+        if ( !StringUtils.isEmpty( id ) )
+        {
+            groupId = id;
+
+            artifactId = id;
+        }
+        else
+        {
+            groupId = getValue( mavenProject, "groupId", project.getGroupId() );
+
+            if ( StringUtils.isEmpty( groupId ) )
+            {
+                result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_GROUPID );
+
+                log.info( "Missing 'groupId' element in the POM." );
+
+                // Do not throw an exception or return here, gather up as many results as possible first.
+            }
+
+            artifactId = getValue( mavenProject, "artifactId", project.getArtifactId() );
+
+            if ( StringUtils.isEmpty( artifactId ) )
+            {
+                result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_ARTIFACTID );
+
+                log.info( "Missing 'artifactId' element in the POM." );
+
+                // Do not throw an exception or return here, gather up as many results as possible first.
+            }
+        }
+
+        // ----------------------------------------------------------------------
+        // version
+        // ----------------------------------------------------------------------
+
+        String version = getValue( mavenProject, "currentVersion", project.getVersion() );
+
+        if ( StringUtils.isEmpty( project.getVersion() ) && StringUtils.isEmpty( version ) )
+        {
+            result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_VERSION );
+
+            // Do not throw an exception or return here, gather up as many results as possible first.
+        }
+
+        // ----------------------------------------------------------------------
+        // name
+        // ----------------------------------------------------------------------
+
+        String name = getValue( mavenProject, "name", project.getName() );
+
+        if ( StringUtils.isEmpty( project.getName() ) && StringUtils.isEmpty( name ) )
+        {
+            result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_NAME );
+
+            // Do not throw an exception or return here, gather up as many results as possible first.
+        }
+
+        // ----------------------------------------------------------------------
+        // description
+        // ----------------------------------------------------------------------
+
+        String shortDescription = getValue( mavenProject, "shortDescription", project.getDescription() );
+
+        String description = getValue( mavenProject, "description", project.getDescription() );
+
+        // ----------------------------------------------------------------------
+        // scm
+        // ----------------------------------------------------------------------
+
+        Xpp3Dom repository = mavenProject.getChild( "repository" );
+
+        String scmConnection = null;
+
+        if ( repository == null )
+        {
+            if ( !StringUtils.isEmpty( project.getScmUrl() ) )
+            {
+                scmConnection = project.getScmUrl();
+            }
+            else
+            {
+                result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_REPOSITORY );
+
+                // Do not throw an exception or return here, gather up as many results as possible first.
+            }
+        }
+        else
+        {
+            scmConnection = getValue( repository, "developerConnection", project.getScmUrl() );
+
+            scmConnection = getValue( repository, "connection", scmConnection );
+
+            if ( StringUtils.isEmpty( scmConnection ) )
+            {
+                result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_SCM, name );
+
+                // Do not throw an exception or return here, gather up as many results as possible first.
+            }
+        }
+
+        // ----------------------------------------------------------------------
+        // Developers
+        // ----------------------------------------------------------------------
+
+        Xpp3Dom developers = mavenProject.getChild( "developers" );
+
+        if ( developers != null )
+        {
+            Xpp3Dom[] developersList = developers.getChildren();
+
+            List<ProjectDeveloper> cds = new ArrayList<ProjectDeveloper>();
+
+            for ( Xpp3Dom developer : developersList )
+            {
+                ProjectDeveloper cd = new ProjectDeveloper();
+
+                cd.setScmId( getValue( developer, "id", null ) );
+
+                cd.setName( getValue( developer, "name", null ) );
+
+                cd.setEmail( getValue( developer, "email", null ) );
+
+                cds.add( cd );
+            }
+
+            project.setDevelopers( cds );
+        }
+
+        // ----------------------------------------------------------------------
+        // Dependencies
+        // ----------------------------------------------------------------------
+
+        Xpp3Dom dependencies = mavenProject.getChild( "dependencies" );
+
+        if ( dependencies != null )
+        {
+            Xpp3Dom[] dependenciesList = dependencies.getChildren();
+
+            List<ProjectDependency> deps = new ArrayList<ProjectDependency>();
+
+            for ( Xpp3Dom dependency : dependenciesList )
+            {
+                ProjectDependency cd = new ProjectDependency();
+
+                if ( getValue( dependency, "groupId", null ) != null )
+                {
+                    cd.setGroupId( getValue( dependency, "groupId", null ) );
+
+                    cd.setArtifactId( getValue( dependency, "artifactId", null ) );
+                }
+                else
+                {
+                    cd.setGroupId( getValue( dependency, "id", null ) );
+
+                    cd.setArtifactId( getValue( dependency, "id", null ) );
+                }
+
+                cd.setVersion( getValue( dependency, "version", null ) );
+
+                deps.add( cd );
+            }
+
+            project.setDependencies( deps );
+        }
+
+        // ----------------------------------------------------------------------
+        // notifiers
+        // ----------------------------------------------------------------------
+
+        Xpp3Dom build = mavenProject.getChild( "build" );
+
+        List<ProjectNotifier> notifiers = new ArrayList<ProjectNotifier>();
+
+        // Add project Notifier
+        if ( build != null )
+        {
+            String nagEmailAddress = getValue( build, "nagEmailAddress", null );
+
+            if ( nagEmailAddress != null )
+            {
+                Properties props = new Properties();
+
+                props.put( "address", nagEmailAddress );
+
+                ProjectNotifier notifier = new ProjectNotifier();
+
+                notifier.setConfiguration( props );
+
+                notifier.setFrom( ProjectNotifier.FROM_PROJECT );
+
+                notifiers.add( notifier );
+            }
+        }
+
+        // Add all user notifiers
+        if ( project.getNotifiers() != null && !project.getNotifiers().isEmpty() )
+        {
+            for ( ProjectNotifier notif : (List<ProjectNotifier>) project.getNotifiers() )
+            {
+                if ( notif.isFromUser() )
+                {
+                    notifiers.add( notif );
+                }
+            }
+        }
+
+        // ----------------------------------------------------------------------
+        // Handle Errors / Results
+        // ----------------------------------------------------------------------
+
+        if ( result.hasErrors() )
+        {
+            // prevent project creation if there are errors.
+            return;
+        }
+
+        // ----------------------------------------------------------------------
+        // Make the project
+        // ----------------------------------------------------------------------
+
+        project.setGroupId( groupId );
+
+        project.setArtifactId( artifactId );
+
+        project.setVersion( version );
+
+        project.setName( name );
+
+        if ( StringUtils.isEmpty( shortDescription ) )
+        {
+            project.setDescription( description );
+        }
+        else
+        {
+            project.setDescription( shortDescription );
+        
+        }
+
+        project.setScmUrl( scmConnection );
+
+        project.setNotifiers( notifiers );
+    }
+
+    //----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    private String getValue( Xpp3Dom dom, String key, String defaultValue )
+    {
+        Xpp3Dom child = dom.getChild( key );
+
+        if ( child == null )
+        {
+            return defaultValue;
+        }
+
+        return child.getValue();
+    }
+}

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/MavenOneBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/MavenOneBuildExecutor.java?rev=740587&r1=740586&r2=740587&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/MavenOneBuildExecutor.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/MavenOneBuildExecutor.java Wed Feb  4 03:23:31 2009
@@ -24,6 +24,8 @@
 import java.util.Map;
 import java.util.Properties;
 
+import javax.annotation.Resource;
+
 import org.apache.continuum.buildagent.build.execution.AbstractBuildExecutor;
 import org.apache.continuum.buildagent.build.execution.ContinuumAgentBuildCancelledException;
 import org.apache.continuum.buildagent.build.execution.ContinuumAgentBuildExecutionResult;
@@ -33,6 +35,7 @@
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.codehaus.plexus.util.StringUtils;
 
 public class MavenOneBuildExecutor
@@ -43,6 +46,9 @@
 
     public final static String ID = ContinuumBuildExecutorConstants.MAVEN_ONE_BUILD_EXECUTOR;
 
+    @Resource
+    private BuildAgentMavenOneMetadataHelper buildAgentMavenOneMetadataHelper;
+
     public MavenOneBuildExecutor()
     {
         super( ID, true );
@@ -98,4 +104,48 @@
         return executeShellCommand( project, executable, arguments.toString(), buildOutput, environments );
     }
 
+    public void updateProjectFromWorkingDirectory( File workingDirectory, Project project,
+                                                   BuildDefinition buildDefinition )
+        throws ContinuumAgentBuildExecutorException
+    {
+        File projectXmlFile = null;
+
+        if ( buildDefinition != null )
+        {
+            String buildFile = StringUtils.clean( buildDefinition.getBuildFile() );
+
+            if ( !StringUtils.isEmpty( buildFile ) )
+            {
+                projectXmlFile = new File( workingDirectory, buildFile );
+            }
+        }
+
+        if ( projectXmlFile == null )
+        {
+            projectXmlFile = new File( workingDirectory, "project.xml" );
+        }
+
+        if ( !projectXmlFile.exists() )
+        {
+            throw new ContinuumAgentBuildExecutorException( "Could not find Maven project descriptor." );
+        }
+
+        try
+        {
+            ContinuumProjectBuildingResult result = new ContinuumProjectBuildingResult();
+            
+            buildAgentMavenOneMetadataHelper.mapMetadata( result, projectXmlFile, project );
+
+            if ( result.hasErrors() )
+            {
+                throw new ContinuumAgentBuildExecutorException( "Error while mapping metadata:" + result.getErrorsAsString() );
+            }
+
+            updateProject( project );
+        }
+        catch ( BuildAgentMavenOneMetadataHelperException e )
+        {
+            throw new ContinuumAgentBuildExecutorException( "Error while mapping metadata.", e );
+        }
+    }
 }

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/BuildAgentMavenBuilderHelper.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/BuildAgentMavenBuilderHelper.java?rev=740587&r1=740586&r2=740587&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/BuildAgentMavenBuilderHelper.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/BuildAgentMavenBuilderHelper.java Wed Feb  4 03:23:31 2009
@@ -21,6 +21,7 @@
 
 import java.io.File;
 
+import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.project.MavenProject;
 
@@ -29,4 +30,6 @@
     String ROLE = BuildAgentMavenBuilderHelper.class.getName();
 
     MavenProject getMavenProject( ContinuumProjectBuildingResult result, File file );
+
+    void mapMetadataToProject( ContinuumProjectBuildingResult result, File metadata, Project project );
 }

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/DefaultBuildAgentMavenBuilderHelper.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/DefaultBuildAgentMavenBuilderHelper.java?rev=740587&r1=740586&r2=740587&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/DefaultBuildAgentMavenBuilderHelper.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/DefaultBuildAgentMavenBuilderHelper.java Wed Feb  4 03:23:31 2009
@@ -22,19 +22,28 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.StringWriter;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-import javax.annotation.Resource;
-
 import org.apache.maven.artifact.manager.WagonManager;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectDependency;
+import org.apache.maven.continuum.model.project.ProjectDeveloper;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Developer;
+import org.apache.maven.model.Extension;
 import org.apache.maven.model.Model;
+import org.apache.maven.model.Notifier;
+import org.apache.maven.model.Plugin;
 import org.apache.maven.model.Profile;
+import org.apache.maven.model.ReportPlugin;
 import org.apache.maven.model.Scm;
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.apache.maven.profiles.DefaultProfileManager;
@@ -64,27 +73,34 @@
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
 
 /**
- * @author marica
+ * @plexus.component role="org.apache.continuum.buildagent.build.execution.maven.m2.BuildAgentMavenBuilderHelper" 
+ * role-hint="default" 
  */
-@Service("buildAgentMavenBuilderHelper")
 public class DefaultBuildAgentMavenBuilderHelper
     implements BuildAgentMavenBuilderHelper, Contextualizable, Initializable
 {
     private Logger log = LoggerFactory.getLogger( this.getClass() );
 
-    @Resource
+    /**
+     * @plexus.requirement
+     */
     private MavenProjectBuilder projectBuilder;
 
-    @Resource
+    /**
+     * @plexus.requirement
+     */
     private MavenSettingsBuilder mavenSettingsBuilder;
 
-    @Resource
+    /**
+     * @plexus.requirement
+     */
     private ArtifactRepositoryFactory artifactRepositoryFactory;
 
-    @Resource
+    /**
+     * @plexus.requirement
+     */
     private ArtifactRepositoryLayout defaultRepositoryLayout;
 
     private PlexusContainer container;
@@ -210,6 +226,307 @@
         return project;
     }
 
+    public void mapMetadataToProject( ContinuumProjectBuildingResult result, File metadata, Project continuumProject )
+    {
+        MavenProject mavenProject = getMavenProject( result, metadata );
+
+        if ( mavenProject == null )
+        {
+            result.addError( ContinuumProjectBuildingResult.ERROR_UNKNOWN,
+                             "Can't load the maven project. Verify that your scm url is correct and remove/readd the project." );
+            return;
+        }
+
+        mapMavenProjectToContinuumProject( result, mavenProject, continuumProject, false );
+    }
+
+    public void mapMavenProjectToContinuumProject( ContinuumProjectBuildingResult result, MavenProject mavenProject,
+                                                   Project continuumProject, boolean groupPom )
+    {
+        if ( mavenProject == null )
+        {
+            result.addError( ContinuumProjectBuildingResult.ERROR_UNKNOWN, "The maven project is null." );
+            return;
+        }
+
+        // ----------------------------------------------------------------------
+        // Name
+        // ----------------------------------------------------------------------
+
+        continuumProject.setName( getProjectName( mavenProject ) );
+
+        // ----------------------------------------------------------------------
+        // SCM Url
+        // ----------------------------------------------------------------------
+
+        // TODO: Remove this: scm url shouldn't be null there
+        if ( StringUtils.isEmpty( continuumProject.getScmUrl() ) )
+        {
+            String scmUrl = getScmUrl( mavenProject );
+
+            continuumProject.setScmUrl( scmUrl );
+
+            if ( !"HEAD".equals( mavenProject.getScm().getTag() ) )
+            {
+                continuumProject.setScmTag( mavenProject.getScm().getTag() );
+            }
+        }
+
+        // ----------------------------------------------------------------------
+        // Version
+        // ----------------------------------------------------------------------
+
+        continuumProject.setVersion( getVersion( mavenProject ) );
+
+        // ----------------------------------------------------------------------
+        // GroupId
+        // ----------------------------------------------------------------------
+
+        if ( !StringUtils.isEmpty( mavenProject.getGroupId() ) )
+        {
+            continuumProject.setGroupId( mavenProject.getGroupId() );
+        }
+        else
+        {
+            result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_GROUPID );
+            return;
+        }
+
+        // ----------------------------------------------------------------------
+        // artifactId
+        // ----------------------------------------------------------------------
+
+        if ( !StringUtils.isEmpty( mavenProject.getArtifactId() ) )
+        {
+            continuumProject.setArtifactId( mavenProject.getArtifactId() );
+        }
+        else
+        {
+            result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_ARTIFACTID );
+            return;
+        }
+
+        // ----------------------------------------------------------------------
+        // Project Url
+        // ----------------------------------------------------------------------
+
+        if ( !StringUtils.isEmpty( mavenProject.getUrl() ) )
+        {
+            continuumProject.setUrl( mavenProject.getUrl() );
+        }
+
+        // ----------------------------------------------------------------------
+        // Developers
+        // ----------------------------------------------------------------------
+
+        if ( mavenProject.getDevelopers() != null )
+        {
+            List<ProjectDeveloper> developers = new ArrayList<ProjectDeveloper>();
+
+            for ( Developer d : (List<Developer>)mavenProject.getDevelopers() )
+            {
+                ProjectDeveloper cd = new ProjectDeveloper();
+
+                cd.setScmId( d.getId() );
+
+                cd.setName( d.getName() );
+
+                cd.setEmail( d.getEmail() );
+
+                developers.add( cd );
+            }
+
+            continuumProject.setDevelopers( developers );
+        }
+
+        // ----------------------------------------------------------------------
+        // Parent
+        // ----------------------------------------------------------------------
+
+        if ( mavenProject.getParent() != null )
+        {
+            MavenProject parentProject = mavenProject.getParent();
+
+            ProjectDependency parent = new ProjectDependency();
+
+            parent.setGroupId( parentProject.getGroupId() );
+
+            parent.setArtifactId( parentProject.getArtifactId() );
+
+            parent.setVersion( parentProject.getVersion() );
+
+            continuumProject.setParent( parent );
+        }
+
+        // ----------------------------------------------------------------------
+        // Dependencies
+        // ----------------------------------------------------------------------
+
+        List<ProjectDependency> dependencies = new ArrayList<ProjectDependency>();
+
+        for ( Dependency dependency : (List<Dependency>)mavenProject.getDependencies() )
+        {
+            ProjectDependency cd = new ProjectDependency();
+
+            cd.setGroupId( dependency.getGroupId() );
+
+            cd.setArtifactId( dependency.getArtifactId() );
+
+            cd.setVersion( dependency.getVersion() );
+
+            dependencies.add( cd );
+        }
+
+        for ( Plugin dependency : (List<Plugin>)mavenProject.getBuildPlugins() )
+        {
+            ProjectDependency cd = new ProjectDependency();
+
+            cd.setGroupId( dependency.getGroupId() );
+
+            cd.setArtifactId( dependency.getArtifactId() );
+
+            cd.setVersion( dependency.getVersion() );
+
+            dependencies.add( cd );
+        }
+
+        for ( ReportPlugin dependency : (List<ReportPlugin>)mavenProject.getReportPlugins() )
+        {
+            ProjectDependency cd = new ProjectDependency();
+
+            cd.setGroupId( dependency.getGroupId() );
+
+            cd.setArtifactId( dependency.getArtifactId() );
+
+            cd.setVersion( dependency.getVersion() );
+
+            dependencies.add( cd );
+        }
+
+        for ( Extension dependency : (List<Extension>)mavenProject.getBuildExtensions() )
+        {
+            ProjectDependency cd = new ProjectDependency();
+
+            cd.setGroupId( dependency.getGroupId() );
+
+            cd.setArtifactId( dependency.getArtifactId() );
+
+            cd.setVersion( dependency.getVersion() );
+
+            dependencies.add( cd );
+        }
+
+        continuumProject.setDependencies( dependencies );
+
+        // ----------------------------------------------------------------------
+        // Notifiers
+        // ----------------------------------------------------------------------
+
+        List<ProjectNotifier> userNotifiers = new ArrayList<ProjectNotifier>();
+
+        if ( continuumProject.getNotifiers() != null )
+        {
+            for ( int i = 0; i < continuumProject.getNotifiers().size(); i++ )
+            {
+                ProjectNotifier notifier = (ProjectNotifier) continuumProject.getNotifiers().get( i );
+
+                if ( notifier.isFromUser() )
+                {
+                    ProjectNotifier userNotifier = new ProjectNotifier();
+
+                    userNotifier.setType( notifier.getType() );
+
+                    userNotifier.setEnabled( notifier.isEnabled() );
+
+                    userNotifier.setConfiguration( notifier.getConfiguration() );
+
+                    userNotifier.setFrom( notifier.getFrom() );
+
+                    userNotifier.setRecipientType( notifier.getRecipientType() );
+
+                    userNotifier.setSendOnError( notifier.isSendOnError() );
+
+                    userNotifier.setSendOnFailure( notifier.isSendOnFailure() );
+
+                    userNotifier.setSendOnSuccess( notifier.isSendOnSuccess() );
+
+                    userNotifier.setSendOnWarning( notifier.isSendOnWarning() );
+
+                    userNotifier.setSendOnScmFailure( notifier.isSendOnScmFailure() );
+
+                    userNotifiers.add( userNotifier );
+                }
+            }
+        }
+
+        List<ProjectNotifier> notifiers = getNotifiers( result, mavenProject, continuumProject );
+        if ( notifiers != null )
+        {
+            continuumProject.setNotifiers( notifiers );
+        }
+
+        for ( ProjectNotifier notifier : userNotifiers )
+        {
+            continuumProject.addNotifier( notifier );
+        }
+    }
+
+    private String getScmUrl( MavenProject project )
+    {
+        return project.getScm().getConnection();
+    }
+
+    private List<ProjectNotifier> getNotifiers( ContinuumProjectBuildingResult result, MavenProject mavenProject,
+                               Project continuumProject )
+    {
+        List<ProjectNotifier> notifiers = new ArrayList<ProjectNotifier>();
+
+        if ( mavenProject.getCiManagement() != null && mavenProject.getCiManagement().getNotifiers() != null )
+        {
+            for ( Notifier projectNotifier : (List<Notifier>)mavenProject.getCiManagement().getNotifiers() )
+            {
+                ProjectNotifier notifier = new ProjectNotifier();
+
+                if ( StringUtils.isEmpty( projectNotifier.getType() ) )
+                {
+                    result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_NOTIFIER_TYPE );
+                    return null;
+                }
+
+                notifier.setType( projectNotifier.getType() );
+
+                if ( projectNotifier.getConfiguration() == null )
+                {
+                    result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_NOTIFIER_CONFIGURATION );
+                    return null;
+                }
+
+                notifier.setConfiguration( projectNotifier.getConfiguration() );
+
+                notifier.setFrom( ProjectNotifier.FROM_PROJECT );
+
+                notifier.setSendOnSuccess( projectNotifier.isSendOnSuccess() );
+
+                notifier.setSendOnFailure( projectNotifier.isSendOnFailure() );
+
+                notifier.setSendOnError( projectNotifier.isSendOnError() );
+
+                notifier.setSendOnWarning( projectNotifier.isSendOnWarning() );
+
+                notifier.setSendOnScmFailure( false );
+
+                notifiers.add( notifier );
+            }
+        }
+
+        return notifiers;
+    }
+
+    private String getVersion( MavenProject project )
+    {
+        return project.getVersion();
+    }
+
     private Settings getSettings()
         throws SettingsConfigurationException
     {

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/MavenTwoBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/MavenTwoBuildExecutor.java?rev=740587&r1=740586&r2=740587&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/MavenTwoBuildExecutor.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/MavenTwoBuildExecutor.java Wed Feb  4 03:23:31 2009
@@ -26,8 +26,6 @@
 import java.util.Map;
 import java.util.Properties;
 
-import javax.annotation.Resource;
-
 import org.apache.continuum.buildagent.build.execution.AbstractBuildExecutor;
 import org.apache.continuum.buildagent.build.execution.ContinuumAgentBuildCancelledException;
 import org.apache.continuum.buildagent.build.execution.ContinuumAgentBuildExecutionResult;
@@ -53,10 +51,14 @@
 
     public static final String ID = ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR;
 
-    @Resource
+    /**
+     * @plexus.requirement
+     */
     private MavenProjectHelper projectHelper;
 
-    @Resource
+    /**
+     * @plexus.requirement
+     */
     private BuildAgentMavenBuilderHelper buildAgentMavenBuilderHelper;
 
     public MavenTwoBuildExecutor()
@@ -74,12 +76,12 @@
         this.projectHelper = projectHelper;
     }
 
-    public BuildAgentMavenBuilderHelper getBuilderHelper()
+    public BuildAgentMavenBuilderHelper getBuildAgentMavenBuilderHelper()
     {
         return buildAgentMavenBuilderHelper;
     }
 
-    public void setBuilderHelper( BuildAgentMavenBuilderHelper builderHelper )
+    public void setBuildAgentMavenBuilderHelper( BuildAgentMavenBuilderHelper builderHelper )
     {
         this.buildAgentMavenBuilderHelper = builderHelper;
     }
@@ -103,7 +105,6 @@
     
         arguments.append( StringUtils.clean( buildDefinition.getArguments() ) ).append( " " );
     
-        /*
         Properties props = getContinuumSystemProperties( project );
         for ( Enumeration itr = props.propertyNames(); itr.hasMoreElements(); )
         {
@@ -111,7 +112,6 @@
             String value = props.getProperty( name );
             arguments.append( "\"-D" ).append( name ).append( "=" ).append( value ).append( "\" " );
         }
-        */
 
         if ( StringUtils.isNotEmpty( localRepository ) )
         {
@@ -231,6 +231,30 @@
         return artifacts;
     }
 
+    public void updateProjectFromWorkingDirectory( File workingDirectory, Project project, BuildDefinition buildDefinition )
+        throws ContinuumAgentBuildExecutorException
+    {
+        File f = getPomFile( getBuildFileForProject( project, buildDefinition ), workingDirectory );
+    
+        if ( !f.exists() )
+        {
+            throw new ContinuumAgentBuildExecutorException( "Could not find Maven project descriptor." );
+        }
+    
+        ContinuumProjectBuildingResult result = new ContinuumProjectBuildingResult();
+    
+        buildAgentMavenBuilderHelper.mapMetadataToProject( result, f, project );
+    
+        if ( result.hasErrors() )
+        {
+            throw new ContinuumAgentBuildExecutorException( "Error while mapping metadata:" + result.getErrorsAsString() );
+        }
+        else
+        {
+            updateProject( project );
+        }
+    }
+
     private MavenProject getMavenProject( Project continuumProject, File workingDirectory,
                                           BuildDefinition buildDefinition )
         throws ContinuumAgentBuildExecutorException

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/shell/ShellBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/shell/ShellBuildExecutor.java?rev=740587&r1=740586&r2=740587&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/shell/ShellBuildExecutor.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/shell/ShellBuildExecutor.java Wed Feb  4 03:23:31 2009
@@ -53,4 +53,11 @@
 
         return executeShellCommand( project, executable, buildDefinition.getArguments(), buildOutput, environments );
     }
+
+    public void updateProjectFromWorkingDirectory( File workingDirectory, Project project,
+                                                   BuildDefinition buildDefinition )
+        throws ContinuumAgentBuildExecutorException
+    {
+        // nothing to do here   
+    }
 }

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java?rev=740587&r1=740586&r2=740587&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java Wed Feb  4 03:23:31 2009
@@ -30,8 +30,12 @@
 
     private String projectName;
 
+    private String projectVersion;
+
     private int projectState;
 
+    private int buildNumber;
+
     private int buildDefinitionId;
 
     private String buildFile;
@@ -54,6 +58,8 @@
 
     private int projectGroupId;
 
+    private String projectGroupName;
+
     private String scmRootAddress;
 
     private Map<String, Object> actionContext;
@@ -66,6 +72,8 @@
 
     private String localRepository;
 
+    private ScmResult oldScmResult;
+
     public int getProjectGroupId()
     {
         return projectGroupId;
@@ -265,4 +273,44 @@
     {
         this.localRepository = localRepository;
     }
+
+    public void setProjectGroupName( String projectGroupName )
+    {
+        this.projectGroupName = projectGroupName;
+    }
+
+    public String getProjectGroupName()
+    {
+        return projectGroupName;
+    }
+
+    public void setProjectVersion( String projectVersion )
+    {
+        this.projectVersion = projectVersion;
+    }
+
+    public String getProjectVersion()
+    {
+        return projectVersion;
+    }
+
+    public void setBuildNumber( int buildNumber )
+    {
+        this.buildNumber = buildNumber;
+    }
+
+    public int getBuildNumber()
+    {
+        return buildNumber;
+    }
+
+    public void setOldScmResult( ScmResult oldScmResult )
+    {
+        this.oldScmResult = oldScmResult;
+    }
+
+    public ScmResult getOldScmResult()
+    {
+        return oldScmResult;
+    }
 }

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentManager.java?rev=740587&r1=740586&r2=740587&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentManager.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentManager.java Wed Feb  4 03:23:31 2009
@@ -32,6 +32,9 @@
     void prepareBuildProjects( List<BuildContext> buildContextList )
         throws ContinuumException;
 
+    void buildProjects( List<BuildContext> buildContextList )
+        throws ContinuumException;
+
     void returnBuildResult( Map result )
         throws ContinuumException;
     
@@ -40,4 +43,7 @@
 
     Map<String, String> getEnvironments( int buildDefinitionId, String installationType )
         throws ContinuumException;
+
+    void updateProject( Map project )
+        throws ContinuumException;
 }

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=740587&r1=740586&r2=740587&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 Wed Feb  4 03:23:31 2009
@@ -21,6 +21,7 @@
 
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -37,6 +38,8 @@
 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.ChangeFile;
+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;
@@ -104,6 +107,13 @@
             
                         log.info( "Updating working directory" );
                         updateWorkingDirectory( buildContext );
+
+                        log.info( "Merging SCM results" );
+                        //CONTINUUM-1393
+                        if ( !buildDef.isBuildFresh() )
+                        {
+                            mergeScmResults( buildContext );
+                        }    
                     }
                     finally
                     {
@@ -116,11 +126,10 @@
             {
                 endPrepareBuild( context );
             }
-
-            if ( checkProjectScmRoot( context ) )
-            {
-                buildProjects( buildContexts );
-            }
+        }
+        else
+        {
+            throw new ContinuumException( "No project build context" );
         }
     }
 
@@ -187,6 +196,27 @@
         }
     }
 
+    public void updateProject( Map project )
+        throws ContinuumException
+    {
+        try
+        {
+            MasterBuildAgentTransportClient client = new MasterBuildAgentTransportClient(
+                new URL( buildAgentConfigurationService.getContinuumServerUrl() ) );
+            client.updateProject( project );
+        }
+        catch ( MalformedURLException e )
+        {
+            log.error( "Invalid continuum server URL '" + buildAgentConfigurationService.getContinuumServerUrl() + "'" );
+            throw new ContinuumException( "Invalid continuum server URL '" + buildAgentConfigurationService.getContinuumServerUrl() + "'" );
+        }
+        catch ( Exception e )
+        {
+            log.error( "Error while updating project", e );
+            throw new ContinuumException( e.getMessage(), e );
+        }
+    }
+
     private void startPrepareBuild( BuildContext buildContext )
         throws ContinuumException
     {
@@ -227,7 +257,8 @@
         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() );
+
         buildContext.setActionContext( actionContext );
     }
 
@@ -293,6 +324,10 @@
         {
             context.put( ContinuumBuildAgentUtil.KEY_SCM_ROOT_STATE, ContinuumProjectState.ERROR );
         }
+        else
+        {
+            buildContext.setScmResult( scmResult );
+        }
 
         // connect to continuum server (master)
         try
@@ -338,7 +373,7 @@
             {
                 result.put( ContinuumBuildAgentUtil.KEY_SCM_ERROR, "" );
             }
-    
+
             // connect to continuum server (master)
             try
             {
@@ -355,6 +390,10 @@
                 throw new ContinuumException( "Error while finishing prepare build", e );
             }
         }
+        else
+        {
+            throw new ContinuumException( "No project build context" );
+        }
     }
 
     private Map<String, Object> createScmResult( BuildContext buildContext )
@@ -396,7 +435,8 @@
             result.put( ContinuumBuildAgentUtil.KEY_SCM_EXCEPTION, scmResult.getException() );
         }
         result.put( ContinuumBuildAgentUtil.KEY_SCM_SUCCESS, new Boolean( scmResult.isSuccess() ) );
-        
+        result.put( ContinuumBuildAgentUtil.KEY_SCM_CHANGES, getScmChanges( scmResult ) );
+
         return result;
     }
 
@@ -474,7 +514,7 @@
         throw exception;
     }
     
-    private void buildProjects( List<BuildContext> buildContexts )
+    public void buildProjects( List<BuildContext> buildContexts )
         throws ContinuumException
     {
         for ( BuildContext buildContext : buildContexts )
@@ -510,7 +550,7 @@
                 {
                     stop = true;
                 }
-            }   
+            }
         }
         catch ( TaskQueueManagerException e )
         {
@@ -518,4 +558,113 @@
         }
     }
 
+    private List<Map> getScmChanges( ScmResult scmResult )
+    {
+        List<Map> scmChanges = new ArrayList<Map>();
+
+        List<ChangeSet> changes = scmResult.getChanges();
+
+        if ( changes != null )
+        {
+            for ( ChangeSet cs : changes )
+            {
+                Map changeSet = new HashMap();
+
+                if ( StringUtils.isNotEmpty( cs.getAuthor() ) )
+                {
+                    changeSet.put( ContinuumBuildAgentUtil.KEY_CHANGESET_AUTHOR, cs.getAuthor() );
+                }
+                else
+                {
+                    changeSet.put( ContinuumBuildAgentUtil.KEY_CHANGESET_AUTHOR, "" );
+                }
+                if ( StringUtils.isNotEmpty( cs.getComment() ) ) 
+                {
+                    changeSet.put( ContinuumBuildAgentUtil.KEY_CHANGESET_COMMENT, cs.getComment() );
+                }
+                else
+                {
+                    changeSet.put( ContinuumBuildAgentUtil.KEY_CHANGESET_COMMENT, "" );
+                }
+                changeSet.put( ContinuumBuildAgentUtil.KEY_CHANGESET_DATE, cs.getDateAsDate() );
+                changeSet.put( ContinuumBuildAgentUtil.KEY_CHANGESET_FILES, getChangeFiles( cs.getFiles() ) );
+
+                scmChanges.add( changeSet );
+            }
+        }
+
+        return scmChanges;
+    }
+
+    private List getChangeFiles( List<ChangeFile> changeFiles )
+    {
+        List<Map> files = new ArrayList<Map>();
+
+        if ( changeFiles != null )
+        {
+            for ( ChangeFile file : changeFiles )
+            {
+                Map changeFile = new HashMap();
+                if ( StringUtils.isNotEmpty( file.getName() ) )
+                {
+                    changeFile.put( ContinuumBuildAgentUtil.KEY_CHANGEFILE_NAME, file.getName() );
+                }
+                else
+                {
+                    changeFile.put( ContinuumBuildAgentUtil.KEY_CHANGEFILE_NAME, "" );
+                }
+                if ( StringUtils.isNotEmpty( file.getRevision() ) )
+                {
+                    changeFile.put( ContinuumBuildAgentUtil.KEY_CHANGEFILE_REVISION, file.getRevision() );
+                }
+                else
+                {
+                    changeFile.put( ContinuumBuildAgentUtil.KEY_CHANGEFILE_REVISION, "" );
+                }
+                if ( StringUtils.isNotEmpty( file.getStatus() ) )
+                {
+                    changeFile.put( ContinuumBuildAgentUtil.KEY_CHANGEFILE_STATUS, file.getStatus() );
+                }
+                else
+                {
+                    changeFile.put( ContinuumBuildAgentUtil.KEY_CHANGEFILE_STATUS, "" );
+                }
+
+                files.add( changeFile );
+            }
+        }
+
+        return files;
+    }
+
+    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 );
+            }
+        }
+    }
 }



Mime
View raw message