continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r653954 - in /continuum/trunk: ./ continuum-api/src/main/java/org/apache/maven/continuum/execution/ continuum-base/ continuum-base/continuum-scm/ continuum-base/continuum-scm/src/ continuum-base/continuum-scm/src/main/ continuum-base/contin...
Date Tue, 06 May 2008 23:56:37 GMT
Author: brett
Date: Tue May  6 16:56:35 2008
New Revision: 653954

URL: http://svn.apache.org/viewvc?rev=653954&view=rev
Log:
[CONTINUUM-1745] decouple SCM code from continuum model
Merged from: r647659:653953 on builder branch

Added:
    continuum/trunk/continuum-base/   (props changed)
      - copied from r653952, continuum/branches/builder/continuum-base/
    continuum/trunk/continuum-base/continuum-scm/   (props changed)
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/
    continuum/trunk/continuum-base/continuum-scm/pom.xml
      - copied unchanged from r653952, continuum/branches/builder/continuum-base/continuum-scm/pom.xml
    continuum/trunk/continuum-base/continuum-scm/src/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/
    continuum/trunk/continuum-base/continuum-scm/src/main/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/
    continuum/trunk/continuum-base/continuum-scm/src/main/java/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/java/
    continuum/trunk/continuum-base/continuum-scm/src/main/java/org/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/java/org/
    continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/java/org/apache/
    continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/java/org/apache/continuum/
    continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/
    continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/ContinuumScm.java
      - copied unchanged from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/ContinuumScm.java
    continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/ContinuumScmConfiguration.java
      - copied unchanged from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/ContinuumScmConfiguration.java
    continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/DefaultContinuumScm.java
      - copied unchanged from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/DefaultContinuumScm.java
    continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/
    continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/ScmManager.java
      - copied unchanged from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/ScmManager.java
    continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/Slf4jScmLogger.java
      - copied unchanged from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/Slf4jScmLogger.java
    continuum/trunk/continuum-base/continuum-scm/src/main/resources/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/resources/
    continuum/trunk/continuum-base/continuum-scm/src/main/resources/META-INF/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/resources/META-INF/
    continuum/trunk/continuum-base/continuum-scm/src/main/resources/META-INF/spring-context.xml
      - copied unchanged from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/main/resources/META-INF/spring-context.xml
    continuum/trunk/continuum-base/continuum-scm/src/test/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/
    continuum/trunk/continuum-base/continuum-scm/src/test/java/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/java/
    continuum/trunk/continuum-base/continuum-scm/src/test/java/org/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/java/org/
    continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/java/org/apache/
    continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/java/org/apache/continuum/
    continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/
    continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/manager/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/manager/
    continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/manager/ScmManagerTest.java
      - copied unchanged from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/manager/ScmManagerTest.java
    continuum/trunk/continuum-base/continuum-scm/src/test/resources/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/resources/
    continuum/trunk/continuum-base/continuum-scm/src/test/resources/org/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/resources/org/
    continuum/trunk/continuum-base/continuum-scm/src/test/resources/org/apache/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/resources/org/apache/
    continuum/trunk/continuum-base/continuum-scm/src/test/resources/org/apache/continuum/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/resources/org/apache/continuum/
    continuum/trunk/continuum-base/continuum-scm/src/test/resources/org/apache/continuum/scm/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/resources/org/apache/continuum/scm/
    continuum/trunk/continuum-base/continuum-scm/src/test/resources/org/apache/continuum/scm/manager/
      - copied from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/resources/org/apache/continuum/scm/manager/
    continuum/trunk/continuum-base/continuum-scm/src/test/resources/org/apache/continuum/scm/manager/ScmManagerTest.xml
      - copied unchanged from r653952, continuum/branches/builder/continuum-base/continuum-scm/src/test/resources/org/apache/continuum/scm/manager/ScmManagerTest.xml
    continuum/trunk/continuum-base/pom.xml
      - copied unchanged from r653952, continuum/branches/builder/continuum-base/pom.xml
Removed:
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/shell/
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/scm/
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/utils/shell/
Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
    continuum/trunk/continuum-core/pom.xml
    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/CheckoutProjectContinuumAction.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
    continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
    continuum/trunk/continuum-data-management/   (props changed)
    continuum/trunk/continuum-notifiers/   (props changed)
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/applicationContext.xml
    continuum/trunk/continuum-xmlrpc/   (props changed)
    continuum/trunk/pom.xml

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java?rev=653954&r1=653953&r2=653954&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
(original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
Tue May  6 16:56:35 2008
@@ -33,9 +33,11 @@
 {
     String ROLE = ContinuumBuildExecutor.class.getName();
 
+    // TODO: stream the build output
     ContinuumBuildExecutionResult build( Project project, BuildDefinition buildDefinition,
File buildOutput )
         throws ContinuumBuildExecutorException;
 
+    // TODO: rename to be clearer
     void updateProjectFromCheckOut( File workingDirectory, Project project, BuildDefinition
buildDefinition )
         throws ContinuumBuildExecutorException;
 
@@ -43,8 +45,10 @@
 
     void killProcess( Project project );
 
+    // TODO: are these part of the builder interface, or a separate project/build definition
interface?
     List getDeployableArtifacts( Project project, File workingDirectory, BuildDefinition
buildDefinition )
         throws ContinuumBuildExecutorException;
 
+    //TODO: Move as a plugin
     void backupTestFiles( Project project, int buildId );
 }

Propchange: continuum/trunk/continuum-base/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May  6 16:56:35 2008
@@ -0,0 +1,4 @@
+target
+.classpath
+.project
+.settings

Propchange: continuum/trunk/continuum-base/continuum-scm/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May  6 16:56:35 2008
@@ -0,0 +1,3 @@
+.classpath
+target
+.project

Modified: continuum/trunk/continuum-core/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/pom.xml?rev=653954&r1=653953&r2=653954&view=diff
==============================================================================
--- continuum/trunk/continuum-core/pom.xml (original)
+++ continuum/trunk/continuum-core/pom.xml Tue May  6 16:56:35 2008
@@ -128,6 +128,10 @@
       <artifactId>continuum-security</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.continuum</groupId>
+      <artifactId>continuum-scm</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.codehaus.plexus.redback</groupId>
       <artifactId>redback-rbac-role-manager</artifactId>
     </dependency>

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=653954&r1=653953&r2=653954&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
Tue May  6 16:56:35 2008
@@ -29,12 +29,13 @@
 import org.apache.maven.continuum.model.scm.ScmResult;
 import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
 import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.apache.maven.continuum.scm.ContinuumScmException;
 import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.apache.maven.continuum.utils.ContinuumUtils;
 import org.apache.maven.continuum.utils.WorkingDirectoryService;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.repository.ScmRepositoryException;
 import org.codehaus.plexus.action.ActionManager;
 import org.codehaus.plexus.action.ActionNotFoundException;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
@@ -413,19 +414,15 @@
             error = ContinuumUtils.throwableToString( e );
             exception = new TaskExecutionException( "Error looking up action '" + actionName
+ "'", e );
         }
-        catch ( ContinuumScmException e )
+        catch ( ScmRepositoryException e )
         {
-            ScmResult result = e.getResult();
+            error = getValidationMessages( e ) + "\n" + ContinuumUtils.throwableToString(
e );
 
-            if ( result != null )
-            {
-                error = convertScmResultToError( result );
-            }
-
-            if ( error == null )
-            {
-                error = ContinuumUtils.throwableToString( e );
-            }
+            exception = new TaskExecutionException( "SCM error while executing '" + actionName
+ "'", e );
+        }
+        catch ( ScmException e )
+        {
+            error = ContinuumUtils.throwableToString( e );
 
             exception = new TaskExecutionException( "SCM error while executing '" + actionName
+ "'", e );
         }
@@ -571,6 +568,27 @@
         return true;
     }
 
+    private String getValidationMessages( ScmRepositoryException ex )
+    {
+        List<String> messages = ex.getValidationMessages();
+
+        StringBuffer message = new StringBuffer();
+
+        if ( messages != null && !messages.isEmpty() )
+        {
+            for ( Iterator<String> i = messages.iterator(); i.hasNext(); )
+            {
+                message.append( (String) i.next() );
+
+                if ( i.hasNext() )
+                {
+                    message.append( System.getProperty( "line.separator" ) );
+                }
+            }
+        }
+        return message.toString();
+    }
+
     protected void checkProjectDependencies( BuildContext context )
     {
         if ( context.getOldBuildResult() == null )

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java?rev=653954&r1=653953&r2=653954&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
Tue May  6 16:56:35 2008
@@ -19,27 +19,32 @@
  * under the License.
  */
 
-import org.apache.maven.continuum.Continuum;
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.continuum.scm.ContinuumScm;
+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.ScmResult;
 import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
 import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.apache.maven.continuum.scm.ContinuumScm;
-import org.apache.maven.continuum.scm.ContinuumScmException;
+import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStore;
+import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.apache.maven.continuum.utils.ContinuumUtils;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
 import org.apache.maven.scm.manager.NoSuchScmProviderException;
+import org.apache.maven.scm.repository.ScmRepositoryException;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.File;
-import java.util.Map;
-
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
- * @plexus.component role="org.codehaus.plexus.action.Action"
- * role-hint="checkout-project"
+ * @plexus.component role="org.codehaus.plexus.action.Action" role-hint="checkout-project"
  */
 public class CheckoutProjectContinuumAction
     extends AbstractContinuumAction
@@ -60,7 +65,7 @@
     private ContinuumStore store;
 
     public void execute( Map context )
-        throws Exception
+        throws ContinuumObjectNotFoundException, ContinuumStoreException
     {
         Project project = store.getProject( getProject( context ).getId() );
 
@@ -85,39 +90,71 @@
 
         try
         {
-            result = scm.checkOut( project, workingDirectory, context );
-            //CONTINUUM-1394
-            result.setChanges( null );
-        }
-        catch ( ContinuumScmException e )
-        {
-            // TODO: Dissect the scm exception to be able to give better feedback
-            Throwable cause = e.getCause();
+            ContinuumScmConfiguration config = createScmConfiguration( project, workingDirectory
);
 
-            if ( cause instanceof NoSuchScmProviderException )
-            {
-                result = new ScmResult();
+            String tag = config.getTag();
+            getLogger().info(
+                              "Checking out project: '" + project.getName() + "', id: '"
+ project.getId() + "' "
+                                  + "to '" + workingDirectory + "'"
+                                  + ( tag != null ? " with branch/tag " + tag + "." : "."
) );
 
-                result.setSuccess( false );
-
-                result.setProviderMessage( cause.getMessage() );
+            CheckOutScmResult checkoutResult = scm.checkout( config );
+            if ( StringUtils.isNotEmpty( checkoutResult.getRelativePathProjectDirectory()
) )
+            {
+                context.put( AbstractContinuumAction.KEY_PROJECT_RELATIVE_PATH,
+                             checkoutResult.getRelativePathProjectDirectory() );
             }
-            else if ( e.getResult() != null )
+
+            if ( !checkoutResult.isSuccess() )
             {
-                result = e.getResult();
+                // TODO: is it more appropriate to return this in the converted result so
that it can be presented to
+                // the user?
+                String msg =
+                    "Error while checking out the code for project: '" + project.getName()
+ "', id: '"
+                        + project.getId() + "' to '" + workingDirectory.getAbsolutePath()
+ "'"
+                        + ( tag != null ? " with branch/tag " + tag + "." : "." );
+                getLogger().warn( msg );
+
+                getLogger().warn( "Command output: " + checkoutResult.getCommandOutput()
);
+
+                getLogger().warn( "Provider message: " + checkoutResult.getProviderMessage()
);
             }
             else
             {
-                result = new ScmResult();
+                getLogger().info( "Checked out " + checkoutResult.getCheckedOutFiles().size()
+ " files." );
+            }
+
+            result = convertScmResult( checkoutResult );
+        }
+        catch ( ScmRepositoryException e )
+        {
+            result = new ScmResult();
 
-                result.setSuccess( false );
+            result.setSuccess( false );
 
-                result.setException( ContinuumUtils.throwableMessagesToString( e ) );
-            }
+            result.setProviderMessage( e.getMessage() + ": " + getValidationMessages( e )
);
+        }
+        catch ( NoSuchScmProviderException e )
+        {
+            // TODO: this is not making it back into a result of any kind - log it at least.
Same is probably the case for ScmException
+            result = new ScmResult();
+
+            result.setSuccess( false );
+
+            result.setProviderMessage( e.getMessage() );
+        }
+        catch ( ScmException e )
+        {
+            result = new ScmResult();
+
+            result.setSuccess( false );
+
+            result.setException( ContinuumUtils.throwableMessagesToString( e ) );
         }
         catch ( Throwable t )
         {
             // TODO: do we want this here, or should it be to the logs?
+            // TODO: what throwables do we really get here that we can cope with?
             result = new ScmResult();
 
             result.setSuccess( false );
@@ -129,9 +166,7 @@
             String relativePath = (String) getObject( context, KEY_PROJECT_RELATIVE_PATH,
"" );
             if ( StringUtils.isNotEmpty( relativePath ) )
             {
-
                 project.setRelativePath( relativePath );
-
             }
 
             project = store.getProject( project.getId() );
@@ -145,4 +180,73 @@
 
         context.put( KEY_CHECKOUT_SCM_RESULT, result );
     }
+
+    private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory
)
+    {
+        ContinuumScmConfiguration config = new ContinuumScmConfiguration();
+        config.setUrl( project.getScmUrl() );
+        config.setUsername( project.getScmUsername() );
+        config.setPassword( project.getScmPassword() );
+        config.setUseCredentialsCache( project.isScmUseCache() );
+        config.setWorkingDirectory( workingDirectory );
+        config.setTag( project.getScmTag() );
+        return config;
+    }
+
+    private ScmResult convertScmResult( CheckOutScmResult scmResult )
+    {
+        ScmResult result = new ScmResult();
+
+        result.setSuccess( scmResult.isSuccess() );
+
+        result.setCommandLine( maskPassword( scmResult.getCommandLine() ) );
+
+        result.setCommandOutput( scmResult.getCommandOutput() );
+
+        result.setProviderMessage( scmResult.getProviderMessage() );
+
+        return result;
+    }
+
+    private String maskPassword( String commandLine )
+    {
+        String cmd = commandLine;
+
+        if ( cmd != null && cmd.startsWith( "svn" ) )
+        {
+            String pwdString = "--password";
+
+            if ( cmd.indexOf( pwdString ) > 0 )
+            {
+                int index = cmd.indexOf( pwdString ) + pwdString.length() + 1;
+
+                int nextSpace = cmd.indexOf( " ", index );
+
+                cmd = cmd.substring( 0, index ) + "********" + cmd.substring( nextSpace );
+            }
+        }
+
+        return cmd;
+    }
+
+    private String getValidationMessages( ScmRepositoryException ex )
+    {
+        List<String> messages = ex.getValidationMessages();
+
+        StringBuffer message = new StringBuffer();
+
+        if ( messages != null && !messages.isEmpty() )
+        {
+            for ( Iterator<String> i = messages.iterator(); i.hasNext(); )
+            {
+                message.append( (String) i.next() );
+
+                if ( i.hasNext() )
+                {
+                    message.append( System.getProperty( "line.separator" ) );
+                }
+            }
+        }
+        return message.toString();
+    }
 }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java?rev=653954&r1=653953&r2=653954&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
Tue May  6 16:56:35 2008
@@ -19,21 +19,36 @@
  * under the License.
  */
 
+import org.apache.continuum.scm.ContinuumScm;
+import org.apache.continuum.scm.ContinuumScmConfiguration;
 import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildResult;
 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.notification.ContinuumNotificationDispatcher;
 import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.apache.maven.continuum.scm.ContinuumScm;
+import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStore;
-
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.apache.maven.continuum.utils.WorkingDirectoryService;
+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;
+
+import java.io.File;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
- * @plexus.component role="org.codehaus.plexus.action.Action"
- * role-hint="update-working-directory-from-scm"
+ * @plexus.component role="org.codehaus.plexus.action.Action" role-hint="update-working-directory-from-scm"
  */
 public class UpdateWorkingDirectoryFromScmContinuumAction
     extends AbstractContinuumAction
@@ -49,12 +64,18 @@
     private ContinuumScm scm;
 
     /**
+     * @plexus.requirement
+     */
+    private WorkingDirectoryService workingDirectoryService;
+
+    /**
      * @plexus.requirement role-hint="jdo"
      */
     private ContinuumStore store;
 
     public void execute( Map context )
-        throws Exception
+        throws ScmRepositoryException, NoSuchScmProviderException, ScmException, ContinuumObjectNotFoundException,
+        ContinuumStoreException
     {
         Project project = store.getProject( getProject( context ).getId() );
 
@@ -66,25 +87,187 @@
 
         store.updateProject( project );
 
-        ScmResult scmResult;
+        UpdateScmResult scmResult;
+
+        Date latestUpdateDate = null;
+        try
+        {
+            BuildResult result = store.getLatestBuildResultForProject( project.getId() );
+
+            latestUpdateDate = new Date( result.getStartTime() );
+        }
+        catch ( Exception e )
+        {
+        }
 
         try
         {
             notifier.checkoutStarted( project, buildDefinition );
 
-            scmResult = scm.updateProject( project, context );
+            // TODO: not sure why this is different to the context, but it all needs to change
+            File workingDirectory = workingDirectoryService.getWorkingDirectory( project
);
+            ContinuumScmConfiguration config = createScmConfiguration( project, workingDirectory
);
+            config.setLatestUpdateDate( latestUpdateDate );
+            String tag = config.getTag();
+            String msg =
+                project.getName() + "', id: '" + project.getId() + "' to '" + workingDirectory.getAbsolutePath()
+ "'"
+                    + ( tag != null ? " with branch/tag " + tag + "." : "." );
+            getLogger().info( "Updating project: " + msg );
+            scmResult = scm.update( config );
+
+            if ( !scmResult.isSuccess() )
+            {
+                getLogger().warn( "Error while updating the code for project: '" + msg );
+
+                getLogger().warn( "Command output: " + scmResult.getCommandOutput() );
+
+                getLogger().warn( "Provider message: " + scmResult.getProviderMessage() );
+            }
+
+            if ( scmResult.getUpdatedFiles() != null && scmResult.getUpdatedFiles().size()
> 0 )
+            {
+                getLogger().info( "Updated " + scmResult.getUpdatedFiles().size() + " files."
);
+            }
 
-            context.put( KEY_UPDATE_SCM_RESULT, scmResult );
+            context.put( KEY_UPDATE_SCM_RESULT, convertScmResult( scmResult ) );
         }
         finally
         {
-            project = store.getProject( project.getId() );
+            // set back to the original state
+            // TODO: transient states!
+            try
+            {
+                project = store.getProject( project.getId() );
+
+                project.setState( state );
+
+                store.updateProject( project );
+            }
+            catch ( Exception e )
+            {
+                // nasty nasty, but we're in finally, so just sacrifice the state to keep
the original exception
+                getLogger().error( e.getMessage(), e );
+            }
 
-            project.setState( state );
+            notifier.checkoutComplete( project, buildDefinition );
+        }
+    }
 
-            store.updateProject( project );
+    private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory
)
+    {
+        ContinuumScmConfiguration config = new ContinuumScmConfiguration();
+        config.setUrl( project.getScmUrl() );
+        config.setUsername( project.getScmUsername() );
+        config.setPassword( project.getScmPassword() );
+        config.setUseCredentialsCache( project.isScmUseCache() );
+        config.setWorkingDirectory( workingDirectory );
+        config.setTag( project.getScmTag() );
+        return config;
+    }
 
-            notifier.checkoutComplete( project, buildDefinition );
+    private ScmResult convertScmResult( UpdateScmResult scmResult )
+    {
+        ScmResult result = new ScmResult();
+
+        result.setCommandLine( maskPassword( scmResult.getCommandLine() ) );
+
+        result.setSuccess( scmResult.isSuccess() );
+
+        result.setCommandOutput( scmResult.getCommandOutput() );
+
+        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;
+    }
+
+    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;
+    }
+
+    private String maskPassword( String commandLine )
+    {
+        String cmd = commandLine;
+
+        if ( cmd != null && cmd.startsWith( "svn" ) )
+        {
+            String pwdString = "--password";
+
+            if ( cmd.indexOf( pwdString ) > 0 )
+            {
+                int index = cmd.indexOf( pwdString ) + pwdString.length() + 1;
+
+                int nextSpace = cmd.indexOf( " ", index );
+
+                cmd = cmd.substring( 0, index ) + "********" + cmd.substring( nextSpace );
+            }
+        }
+
+        return cmd;
     }
 }

Modified: continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml?rev=653954&r1=653953&r2=653954&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml Tue May
 6 16:56:35 2008
@@ -20,32 +20,6 @@
 <component-set>
   <components>
 
-    <!-- not using plexus-maven-plugin because of configuration complexity -->
-    <component>
-      <role>org.apache.maven.continuum.scm.ContinuumScm</role>
-      <implementation>org.apache.maven.continuum.scm.DefaultContinuumScm</implementation>
-      <requirements>
-        <requirement>
-          <role>org.apache.maven.scm.manager.ScmManager</role>
-        </requirement>
-        <requirement>
-          <role>org.apache.maven.continuum.utils.WorkingDirectoryService</role>
-        </requirement>
-        <requirement>
-          <role>org.apache.maven.continuum.store.ContinuumStore</role>
-          <role-hint>jdo</role-hint>
-        </requirement>
-      </requirements>
-      <configuration>
-        <updateProperties>
-          <property>
-            <name>maven.scm.starteam.deleteLocal</name>
-            <value>true</value>
-          </property>
-        </updateProperties>
-      </configuration>
-    </component>
-
     <!--
      |
      | Build Project Task Queue

Propchange: continuum/trunk/continuum-data-management/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue May  6 16:56:35 2008
@@ -1,3 +1,4 @@
+.project
 target
 *.iml
 *.ipr

Propchange: continuum/trunk/continuum-notifiers/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue May  6 16:56:35 2008
@@ -1,3 +1,4 @@
+.settings
 target
 *~
 *.log

Modified: continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/applicationContext.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/applicationContext.xml?rev=653954&r1=653953&r2=653954&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/applicationContext.xml (original)
+++ continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/applicationContext.xml Tue May
 6 16:56:35 2008
@@ -30,4 +30,55 @@
   </bean>
   <bean id="workingDirectoryService" class="org.apache.maven.continuum.utils.ChrootJailWorkingDirectoryService"
autowire="byName"/>
   -->
+  
+  <bean id="scmManager"
+    class="org.apache.continuum.scm.manager.ScmManager">
+    <!--  TODO: better way to add the providers without having to redeclare all this?
-->
+    <property name="scmLogger" ref="scmLogger" />
+    <property name="scmProviders">
+      <map>
+        <entry key="svn">
+          <bean
+            class="org.apache.maven.scm.provider.svn.svnexe.SvnExeScmProvider" />
+        </entry>
+        <entry key="bazaar">
+          <bean
+            class="org.apache.maven.scm.provider.bazaar.BazaarScmProvider" />
+        </entry>
+        <entry key="clearcase">
+          <bean
+            class="org.apache.maven.scm.provider.clearcase.ClearCaseScmProvider" />
+        </entry>
+        <entry key="cvs">
+          <bean
+            class="org.apache.maven.scm.provider.cvslib.cvsjava.CvsJavaScmProvider" />
+        </entry>
+        <entry key="cvs_native">
+          <bean
+            class="org.apache.maven.scm.provider.cvslib.cvsexe.CvsExeScmProvider" />
+        </entry>
+        <entry key="local">
+          <bean
+            class="org.apache.maven.scm.provider.local.LocalScmProvider" />
+        </entry>
+        <entry key="perforce">
+          <bean
+            class="org.apache.maven.scm.provider.perforce.PerforceScmProvider" />
+        </entry>
+        <entry key="starteam">
+          <bean
+            class="org.apache.maven.scm.provider.starteam.StarteamScmProvider" />
+        </entry>
+        <entry key="synergy">
+          <bean
+            class="org.apache.maven.scm.provider.synergy.SynergyScmProvider" />
+        </entry>
+        <entry key="vss">
+          <bean
+            class="org.apache.maven.scm.provider.vss.VssScmProvider" />
+        </entry>
+      </map>
+    </property>
+  </bean>
+  
 </beans>

Propchange: continuum/trunk/continuum-xmlrpc/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue May  6 16:56:35 2008
@@ -1,3 +1,4 @@
+.settings
 target
 *~
 *.log

Modified: continuum/trunk/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/pom.xml?rev=653954&r1=653953&r2=653954&view=diff
==============================================================================
--- continuum/trunk/pom.xml (original)
+++ continuum/trunk/pom.xml Tue May  6 16:56:35 2008
@@ -16,8 +16,7 @@
   ~ KIND, either express or implied.  See the License for the
   ~ specific language governing permissions and limitations
   ~ under the License.
-  -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  --><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.apache.continuum</groupId>
@@ -171,6 +170,7 @@
     <module>maven-continuum-plugin</module>
     <module>continuum-docs</module>
     <module>continuum-jetty</module>
+    <module>continuum-base</module>
   </modules>
   <repositories>
     <repository>
@@ -236,6 +236,7 @@
       <version>3.8.1</version>
       <scope>test</scope>
     </dependency>
+    <!-- TODO: remove the below, they should not be universal -->
     <dependency>
       <groupId>jmock</groupId>
       <artifactId>jmock</artifactId>
@@ -414,6 +415,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.continuum</groupId>
+        <artifactId>continuum-scm</artifactId>
+        <version>${pom.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.continuum</groupId>
         <artifactId>continuum-store</artifactId>
         <classifier>tests</classifier>
         <version>${pom.version}</version>
@@ -878,5 +884,6 @@
     <maven-scm.version>1.1-SNAPSHOT</maven-scm.version>
     <redback.version>1.0.1</redback.version>
     <mail-sender.version>1.0-alpha-7</mail-sender.version>
+    <spring.version>2.5.1</spring.version>
   </properties>
 </project>



Mime
View raw message