continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tryg...@apache.org
Subject svn commit: r168554 - /maven/continuum/trunk/continuum-core-it /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/evaluator /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/console /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/state /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/trigger/socket /maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus /maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue /maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification /maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store /maven/continuum/trunk/continuum-model/src/main/resources /maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc
Date Fri, 06 May 2005 07:30:28 GMT
Author: trygvis
Date: Fri May  6 00:30:25 2005
New Revision: 168554

URL: http://svn.apache.org/viewcvs?rev=168554&view=rev
Log:
Fixing CONTINUUM-110: "do not add a build result when no build occurs"
o Removing the "build executed" flag from the build.
o When enqueuing a project the build id won't be returned.
o The internal passing of ContinuumBuild objects have been removed as it's not
  created until a build actually is executed. The BuildProjectTask is now the
  context for a build containing the project id and the force flag.

Modified:
    maven/continuum/trunk/continuum-core-it/continuum.py
    maven/continuum/trunk/continuum-core-it/continuum_cli.py
    maven/continuum/trunk/continuum-core-it/it.py
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/Continuum.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildController.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutor.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/BuildProjectTask.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/evaluator/BuildProjectTaskViabilityEvaluator.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/console/ConsoleNotifier.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/state/ContinuumProjectStateGuard.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/state/DefaultContinuumProjectStateGuard.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/DefaultContinuumScm.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/trigger/socket/SimpleSocketTrigger.java
    maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java
    maven/continuum/trunk/continuum-model/src/main/resources/continuum.mdo
    maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java

Modified: maven/continuum/trunk/continuum-core-it/continuum.py
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/continuum.py?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core-it/continuum.py (original)
+++ maven/continuum/trunk/continuum-core-it/continuum.py Fri May  6 00:30:25 2005
@@ -88,9 +88,7 @@
 def buildProject( projectId, force=False ):
     result = checkResult( server.continuum.buildProject( projectId, force ) )
 
-    return result[ "buildId" ]
-
-def getBuildsForProject( projectId, start, end ):
+def getBuildsForProject( projectId, start=0, end=0 ):
     result = checkResult( server.continuum.getBuildsForProject( projectId, start, end ) )
 
     builds = []
@@ -227,27 +225,21 @@
     def __init__( self, map ):
         # This is the common stuff between all ContinuumBuildResult objects
         self.success = map[ "success" ] == "true"
-        self.buildExecuted = map[ "buildExecuted" ] == "true"
-        #self.changedFiles = map[ "changedFiles" ]
 
-        # These fields just happen to be the same for all the build results
-        if ( self.buildExecuted ):
-            self.exitCode = int( map[ "exitCode" ] )
-            self.standardOutput = map[ "standardOutput" ]
-            self.standardError = map[ "standardError" ]
+        self.exitCode = int( map[ "exitCode" ] )
+        self.standardOutput = map[ "standardOutput" ]
+        self.standardError = map[ "standardError" ]
 
     def __str__( self ):
-        value = "Success: " + str( self.success ) + os.linesep +\
-                "Build executed: " + str( self.buildExecuted )
+        value = "Success: " + str( self.success )
 
-        if ( self.buildExecuted ):
-            value += os.linesep + "Exit code: " + str( self.exitCode )
+        value += os.linesep + "Exit code: " + str( self.exitCode )
 
-            if ( len( self.standardOutput ) > 0 ):
-                  value += os.linesep + "Standard output: " + self.standardOutput
+        if ( len( self.standardOutput ) > 0 ):
+              value += os.linesep + "Standard output: " + self.standardOutput
 
-            if ( len( self.standardError ) > 0 ):
-                   value += os.linesep + "Standard error: " + self.standardError
+        if ( len( self.standardError ) > 0 ):
+               value += os.linesep + "Standard error: " + self.standardError
 
         return value
 

Modified: maven/continuum/trunk/continuum-core-it/continuum_cli.py
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/continuum_cli.py?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core-it/continuum_cli.py (original)
+++ maven/continuum/trunk/continuum-core-it/continuum_cli.py Fri May  6 00:30:25 2005
@@ -97,9 +97,9 @@
         """Build a Continuum project.
         Use this command to signal a build for a Continuum project."""
 
-        buildId = continuum.buildProject( args[ 0 ] )
+        continuum.buildProject( args[ 0 ] )
 
-        print "Enqueued project, build id: " + buildId
+        print "Enqueued project"
 
     def do_showBuild( self, args ):
         """Shows the result of a build."""

Modified: maven/continuum/trunk/continuum-core-it/it.py
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/it.py?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core-it/it.py (original)
+++ maven/continuum/trunk/continuum-core-it/it.py Fri May  6 00:30:25 2005
@@ -6,7 +6,7 @@
 import traceback
 
 def progress( message ):
-    print "* " + message
+    print "[" + time.strftime( "%c" ) + "] * " + message
 
 def fail( message ):
     print "FAILURE: " + message
@@ -24,9 +24,9 @@
     if( expected == actual ):
         return
 
-    fail( message, expected, actual )
+    assertionFailed( message, expected, actual )
 
-def fail( message, expected, actual ):
+def assertionFailed( message, expected, actual ):
     print
     print "##############################################"
     print "ASSERTION FAILURE!"
@@ -53,7 +53,7 @@
     if ( condition != None ):
         return
 
-    fail( message, None, condition )
+    assertionFailed( message, "Not None", condition )
 
 def assertProject( projectId, name, nagEmailAddress, state, version, builderId, project ):
     assertNotNull( "project.id", projectId )
@@ -91,7 +91,6 @@
     buildResult = continuum.getBuildResult( buildId )
     assertNotNull( "Build result was null.", buildResult )
     assertTrue( "The build wasn't successful", buildResult.success )
-    assertFalse( "The build was executed", buildResult.buildExecuted )
 
 def assertSuccessfulMaven1Build( buildId ):
     build = waitForBuild( buildId )
@@ -99,7 +98,6 @@
     buildResult = continuum.getBuildResult( buildId )
     assertNotNull( "Build result was null.", buildResult )
     assertTrue( "The build wasn't successful", buildResult.success )
-    assertTrue( "The build wasn't executed", buildResult.buildExecuted )
     assertTrue( "Standard output didn't contain the 'BUILD SUCCESSFUL' message.", buildResult.standardOutput.find( "BUILD SUCCESSFUL" ) != -1 )
     assertEquals( "Standard error wasn't empty.", 0, len( buildResult.standardError ) )
 
@@ -109,7 +107,6 @@
     buildResult = continuum.getBuildResult( buildId )
     assertNotNull( "Build result was null.", buildResult )
     assertTrue( "The build wasn't successful", buildResult.success )
-    assertTrue( "The build wasn't executed", buildResult.buildExecuted )
     assertTrue( "Standard output didn't contain the 'BUILD SUCCESSFUL' message.", buildResult.standardOutput.find( "BUILD SUCCESSFUL" ) != -1 )
     assertEquals( "Standard error wasn't empty.", 0, len( buildResult.standardError ) )
 
@@ -121,7 +118,6 @@
     buildResult = continuum.getBuildResult( buildId )
     assertNotNull( "Build result was null.", buildResult )
     assertTrue( "The build wasn't successful", buildResult.success )
-    assertTrue( "The build wasn't executed", buildResult.buildExecuted )
     assertTrue( "Standard output didn't contain the 'BUILD SUCCESSFUL' message.", buildResult.standardOutput.find( "BUILD SUCCESSFUL" ) != -1 )
     assertEquals( "Standard error wasn't empty.", 0, len( buildResult.standardError ) )
 
@@ -131,12 +127,32 @@
     buildResult = continuum.getBuildResult( buildId )
     assertNotNull( "Build result was null.", buildResult )
     assertTrue( "The build wasn't successful", buildResult.success )
-    assertTrue( "The build wasn't executed", buildResult.buildExecuted )
     assertEquals( "Standard output didn't contain the expected output.", expectedStandardOutput, buildResult.standardOutput )
     assertEquals( "Standard error wasn't empty.", 0, len( buildResult.standardError ) )
 
+def buildProject( projectId, force=False ):
+    count = 600;
+
+    originalSize = len( continuum.getBuildsForProject( projectId ) )
+
+    continuum.buildProject( projectId, force )
+
+    while( True ):
+        builds = continuum.getBuildsForProject( projectId )
+
+        size = len( builds )
+
+        count = count - 1
+        if ( count == 0 ):
+            fail( "Timeout while waiting for build result." )
+
+        if ( size == originalSize ):
+            time.sleep( 0.1 )
+            continue
+
+        return builds[ 0 ]
+
 def removeProject( projectId ):
-    return
     continuum.removeProject( projectId )
 
     map = continuum.server.continuum.getProject( projectId )
@@ -163,21 +179,25 @@
     return output
 
 def waitForBuild( buildId ):
-    timeout = 60
+    timeout = 120                # seconds
     sleepInterval = 0.1
 
+    print "waiting for build: " + buildId
     build = continuum.getBuild( buildId )
 
     while( build.state == continuum.STATE_BUILD_SIGNALED or 
-           build.state == continuum.STATE_BUILDING or
-           build.state == continuum.STATE_UPDATING ):
-        build = continuum.getBuild( buildId )
-        time.sleep( sleepInterval )
-        timeout -= sleepInterval
+           build.state == continuum.STATE_UPDATING or
+           build.state == continuum.STATE_BUILDING ):
 
         if ( timeout <= 0 ):
             fail( "Timeout while waiting for build (id=%(id)s) to complete" % { "id" : buildId } )
 
+        time.sleep( sleepInterval )
+
+        timeout -= sleepInterval
+
+        build = continuum.getBuild( buildId )
+
     return build
 
 def waitForCheckOut( projectId ):
@@ -367,7 +387,7 @@
     assertCheckedOutFiles( maven1, [ "/project.xml", "/src/main/java/Foo.java" ] )
 
     progress( "Building Maven 1 project" )
-    buildId = continuum.buildProject( maven1.id )
+    buildId = buildProject( maven1.id ).id
     assertSuccessfulMaven1Build( buildId )
 
     progress( "Testing that the POM is updated before each build." )
@@ -403,17 +423,24 @@
     assertProject( maven2Id, "Maven 2 Project", email, continuum.STATE_NEW, "2.0-SNAPSHOT", "maven2", maven2 )
 
     progress( "Building Maven 2 project" )
-    build = continuum.buildProject( maven2.id )
-    assertSuccessfulMaven2Build( build )
+    buildId = buildProject( maven2.id ).id
+    print "original buildId: " + buildId
+    assertSuccessfulMaven2Build( buildId )
 
     progress( "Test that a build without any files changed won't execute the builder" )
-    build = continuum.buildProject( maven2.id )
-    assertSuccessfulNoBuildPerformed( build )
+    expectedSize = len( continuum.getBuildsForProject( maven2.id ) )
+    continuum.buildProject( maven2.id )
+    time.sleep( 3.0 )
+    actualSize = len( continuum.getBuildsForProject( maven2.id ) )
+    assertEquals( "A build has unexpectedly been executed.", expectedSize, actualSize )
 
     progress( "Test that a forced build without any files changed executes the builder" )
-    build = continuum.buildProject( maven2.id, True )
-    build = assertSuccessfulMaven2Build( build )
-    assertTrue( "The 'build forces' flag wasn't true", build.forced );
+    buildId = buildProject( maven2.id, True ).id
+    print "forced buildId: " + buildId
+    build = assertSuccessfulMaven2Build( buildId )
+    assertTrue( "The 'build forced' flag wasn't true", build.forced );
+    build = continuum.getBuild( buildId )
+    print "build.state: " + build.state
 
     removeProject( maven2Id )
 
@@ -432,8 +459,8 @@
     antSvn = continuum.getProject( antSvnId )
     assertProject( antSvnId, "Ant SVN Project", email, continuum.STATE_NEW, "3.0", "ant", antSvn )
     progress( "Building SVN Ant project" )
-    build = continuum.buildProject( antSvn.id )
-    assertSuccessfulAntBuild( build )
+    buildId = buildProject( antSvn.id ).id
+    assertSuccessfulAntBuild( buildId )
 
     removeProject( antSvnId )
 
@@ -447,8 +474,8 @@
     antCvs = continuum.getProject( antCvsId )
     assertProject( antCvsId, "Ant CVS Project", email, continuum.STATE_NEW, "3.0", "ant", antCvs )
     progress( "Building CVS Ant project" )
-    build = continuum.buildProject( antCvs.id )
-    assertSuccessfulAntBuild( build )
+    buildId = buildProject( antCvs.id ).id
+    assertSuccessfulAntBuild( buildId )
     removeProject( antCvsId )
 
 if 1:
@@ -467,8 +494,8 @@
     assertProject( shellId, "Shell Project", email, continuum.STATE_NEW, "3.0", "shell", shell )
 
     progress( "Building Shell project" )
-    build = continuum.buildProject( shell.id )
-    assertSuccessfulShellBuild( build, "" )
+    buildId = buildProject( shell.id ).id
+    assertSuccessfulShellBuild( buildId, "" )
 
     # Test project reconfiguration
     # Test that a project will be built after a changed file is committed
@@ -490,8 +517,8 @@
     configuration[ "arguments" ] = "a b";
     continuum.updateProjectConfiguration( shell.id, configuration );
     shell = continuum.getProject( shell.id )
-    build = continuum.buildProject( shell.id )
-    assertSuccessfulShellBuild( build, """a
+    buildId = buildProject( shell.id ).id
+    assertSuccessfulShellBuild( buildId, """a
 b
 """ )
     removeProject( shellId )

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/Continuum.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/Continuum.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/Continuum.java Fri May  6 00:30:25 2005
@@ -29,7 +29,6 @@
 import org.apache.maven.continuum.project.MavenTwoProject;
 import org.apache.maven.continuum.project.ShellProject;
 import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.apache.maven.project.MavenProject;
 
 /**
  * This is the main entry point for Continuum. Projects are added to Continuum
@@ -77,7 +76,7 @@
     Iterator getAllProjects( int start, int end )
         throws ContinuumException;
 
-    String buildProject( String projectId, boolean force )
+    void buildProject( String projectId, boolean force )
         throws ContinuumException;
 
     // ----------------------------------------------------------------------

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java Fri May  6 00:30:25 2005
@@ -339,22 +339,18 @@
         }
     }
 
-    public String buildProject( String projectId, boolean force )
+    public void buildProject( String projectId, boolean force )
         throws ContinuumException
     {
         try
         {
             ContinuumProject project = store.getProject( projectId );
 
-            getLogger().info( "Enqueuing '" + project.getName() + "'." );
-
-            String buildId = store.createBuild( project.getId(), force );
+            store.setBuildSignalled( projectId );
 
-            getLogger().info( "Build id: '" + buildId + "'." );
-
-            buildQueue.put( new BuildProjectTask( projectId, buildId, force ) );
+            getLogger().info( "Enqueuing '" + project.getName() + "'." );
 
-            return buildId;
+            buildQueue.put( new BuildProjectTask( projectId, force ) );
         }
         catch ( ContinuumStoreException e )
         {

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildController.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildController.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildController.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildController.java Fri May  6 00:30:25 2005
@@ -24,5 +24,5 @@
 {
     String ROLE = BuildController.class.getName();
 
-    void build( String buildId );
+    void build( String projectId, boolean forced );
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutor.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutor.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutor.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutor.java Fri May  6 00:30:25 2005
@@ -17,10 +17,13 @@
  */
 
 import org.apache.maven.continuum.buildqueue.BuildProjectTask;
+import org.apache.maven.continuum.store.ContinuumStore;
+import org.apache.maven.continuum.store.ContinuumStoreException;
 
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.taskqueue.Task;
 import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -30,16 +33,21 @@
     extends AbstractLogEnabled
     implements TaskExecutor
 {
+    /** @requirement */
     private BuildController controller;
 
+    /** @requirement */
+    private ContinuumStore store;
+
     // ----------------------------------------------------------------------
     // TaskExecutor Implementation
     // ----------------------------------------------------------------------
 
     public void executeTask( Task task )
+        throws TaskExecutionException
     {
         BuildProjectTask buildProjectTask = (BuildProjectTask) task;
 
-        controller.build( buildProjectTask.getBuildId() );
+        controller.build( buildProjectTask.getProjectId(), buildProjectTask.isForced() );
     }
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java Fri May  6 00:30:25 2005
@@ -28,11 +28,13 @@
 import org.apache.maven.continuum.project.ContinuumProject;
 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.scm.UpdateScmResult;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 
 import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.CollectionUtils;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -55,20 +57,48 @@
     private ContinuumScm scm;
 
     // ----------------------------------------------------------------------
-    // BuildController Implementation
+    //
     // ----------------------------------------------------------------------
 
-    public void build( String buildId )
+    private static class BuildContext
     {
         ContinuumProject project;
 
+        ContinuumBuilder builder;
+
+        boolean forced;
+
+        UpdateScmResult scmResult;
+
+        ContinuumBuildResult result;
+
+        int state;
+
+        Throwable cause;
+
         ContinuumBuild build;
+    }
+
+    // ----------------------------------------------------------------------
+    // BuildController Implementation
+    // ----------------------------------------------------------------------
+
+    public void build( String projectId, boolean forced )
+    {
+        BuildContext context = new BuildContext();
+
+        context.forced = forced;
+
+        // ----------------------------------------------------------------------
+        // Initialize the context
+        // ----------------------------------------------------------------------
+
+        // if these calls fail we're screwed anyway
+        // and it will only be logged through the logger.
 
         try
         {
-            project = store.getProjectByBuild( buildId );
-
-            build = store.getBuild( buildId );
+            context.project = store.getProject( projectId );
         }
         catch ( ContinuumStoreException ex )
         {
@@ -79,11 +109,61 @@
 
         try
         {
-            notifier.buildStarted( build );
+            context.builder = builderManager.getBuilder( context.project.getBuilderId() );
+        }
+        catch ( ContinuumException e )
+        {
+            getLogger().fatalError( "Error while getting builder '" + context.project.getBuilderId() + "'. " +
+                                    "Project Id: '" + projectId + "'.", e );
+
+            return;
+        }
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
+        try
+        {
+            notifier.buildStarted( context.project );
+
+            // ----------------------------------------------------------------------
+            // Update the project
+            //
+            // If this fails, create a build, store the scm result and set the
+            // build status to error.
+            // ----------------------------------------------------------------------
+
+            if ( !update( context ) )
+            {
+                return;
+            }
+
+            if ( !updateProjectMetadata( context ) )
+            {
+                return;
+            }
+
+            // ----------------------------------------------------------------------
+            // Figure out if the project needs to be built
+            // ----------------------------------------------------------------------
+
+            if ( context.scmResult.getUpdatedFiles().size() == 0 &&
+                 !forced &&
+                 !isNew( context.project ) )
+            {
+                getLogger().info( "No files updated, not building. Project id '" + context.project.getId() + "'." );
+
+                store.setBuildNotExecuted( projectId );
+
+                return;
+            }
 
-            buildProject( project, build );
+            makeBuild( context );
+
+            buildProject( context );
         }
-        catch ( ContinuumException ex )
+        catch ( ContinuumStoreException ex )
         {
             if ( !Thread.interrupted() )
             {
@@ -94,17 +174,7 @@
         }
         finally
         {
-            // Reload the build as setBuildResult() will update the build
-            try
-            {
-                build = store.getBuild( buildId );
-
-                notifier.buildComplete( build );
-            }
-            catch ( ContinuumStoreException e )
-            {
-                getLogger().error( "Error while loading the build. id: '" + buildId + "'." );
-            }
+            notifier.buildComplete( context.project, context.build );
         }
     }
 
@@ -112,169 +182,144 @@
     //
     // ----------------------------------------------------------------------
 
-    /**
-     * This method shall not throw any exceptions unless there
-     * is something internally wrong. It shall NOT throw a exception when a build fails.
-     *
-     * @param project
-     * @param build
-     * @throws ContinuumException
-     */
-    private void buildProject( ContinuumProject project, ContinuumBuild build )
-        throws ContinuumException
+    private boolean update( BuildContext context )
+        throws ContinuumStoreException
     {
-        // if these calls fail we're screwed anyway
-        // and it will only be logged through the logger.
-
-        ContinuumBuilder builder = builderManager.getBuilder( project.getBuilderId() );
-
-        int state = -1;
-
-        ContinuumBuildResult result = null;
-
-        Throwable error = null;
-
-        // ----------------------------------------------------------------------
-        // Build the project
-        // ----------------------------------------------------------------------
-
         try
         {
-            result = build( builder, build );
+            store.setIsUpdating( context.project.getId() );
 
-            if ( result.isSuccess() )
-            {
-                state = ContinuumProjectState.OK;
-            }
-            else
-            {
-                state = ContinuumProjectState.FAILED;
-            }
-        }
-        catch ( Throwable ex )
-        {
-            getLogger().fatalError( "Error building the project, build id: '" + build.getId() + "'.", ex );
+            notifier.checkoutStarted( context.project );
 
-            error = ex;
+            context.scmResult = scm.updateProject( context.project );
 
-            state = ContinuumProjectState.ERROR;
+            store.setUpdateDone( context.project.getId() );
+
+            return true;
         }
+        catch ( ContinuumScmException e )
+        {
+            getLogger().fatalError( "Error while updating from SCM. Project id '" + context.project.getId() + "'." );
 
-        // ----------------------------------------------------------------------
-        // Store the result
-        // ----------------------------------------------------------------------
+            makeAndSetErrorBuildResult( context, e );
 
-        try
-        {
-            store.setBuildResult( build.getId(), state, result, error );
+            return false;
         }
-        catch ( ContinuumStoreException e )
+        finally
         {
-            getLogger().error( "Error while setting the build result.", e );
+            notifier.checkoutComplete( context.project, context.scmResult );
         }
     }
 
-    private ContinuumBuildResult build( ContinuumBuilder builder, ContinuumBuild build )
-        throws Exception
+    private boolean updateProjectMetadata( BuildContext context )
+        throws ContinuumStoreException
     {
-        ContinuumProject project = store.getProjectByBuild( build.getId() );
-
         // TODO: Update the metadata files and then update the project descriptor
         // before updating the project itself. This will make it possible to migrate
         // a project from one SCM to another.
 
-        UpdateScmResult scmResult;
+        ContinuumBuilder builder = context.builder;
 
-        try
-        {
-            store.setIsUpdating( build.getId() );
-
-            notifier.checkoutStarted( build );
+        ContinuumProject project = context.project;
 
-            scmResult = scm.updateProject( project );
+        File workingDirectory = new File( project.getWorkingDirectory() );
 
-            store.setUpdateDone( build.getId(), scmResult );
-        }
-        finally
+        try
         {
-            notifier.checkoutComplete( build );
+            builder.updateProjectFromCheckOut( workingDirectory, project );
         }
-
-        ContinuumBuildResult result;
-
-        // ----------------------------------------------------------------------
-        // Build the project if
-        // * there was any updated files
-        // * the project is new (never been built before)
-        // * the build is "forced"
-        // ----------------------------------------------------------------------
-
-        if ( scmResult.getUpdatedFiles().size() > 0 ||
-             isNew( project ) ||
-             build.isForced() )
+        catch ( ContinuumException e )
         {
-            File workingDirectory = new File( project.getWorkingDirectory() );
+            getLogger().fatalError( "Error while updating project metadata from check out.", e );
 
-            builder.updateProjectFromCheckOut( workingDirectory, project );
+            makeAndSetErrorBuildResult( context, e );
 
-            String projectId = project.getId();
+            return false;
+        }
+
+        String projectId = project.getId();
 
-            store.updateProject( projectId,
-                                 project.getName(),
-                                 project.getScmUrl(),
-                                 project.getNagEmailAddress(),
-                                 project.getVersion() );
+        store.updateProject( projectId,
+                             project.getName(),
+                             project.getScmUrl(),
+                             project.getNagEmailAddress(),
+                             project.getVersion() );
 
 //            store.updateProjectConfiguration( projectId, project.getConfiguration() );
 
-            try
-            {
-                notifier.runningGoals( build );
+        return true;
+    }
 
-                result = runGoals( builder, project );
+    private void buildProject( BuildContext context )
+        throws ContinuumStoreException
+    {
+        try
+        {
+            notifier.runningGoals( context.project, context.build );
 
-                if ( result == null )
-                {
-                    return null;
-                }
+            context.result = context.builder.build( context.project );
 
-                result.setBuildExecuted( true );
+            if ( context.result.isSuccess() )
+            {
+                context.state = ContinuumProjectState.OK;
             }
-            finally
+            else
             {
-                notifier.goalsCompleted( build );
+                context.state = ContinuumProjectState.FAILED;
             }
+
+            setBuildResult( context.build.getId(), context.state, context.result, context.scmResult, null );
         }
-        else
+        catch ( Throwable ex )
         {
-            getLogger().info( "No files updated, not building. Build id '" + build.getId() + "'." );
+            getLogger().fatalError( "Error building the project, project id: '" + context.project.getId() + "'.", ex );
 
-            result = new ContinuumBuildResult();
+            makeAndSetErrorBuildResult( context, ex );
+        }
+        finally
+        {
+            notifier.goalsCompleted( context.project, context.build );
+        }
+    }
 
-            result.setSuccess( true );
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
 
-            result.setBuildExecuted( false );
-        }
+    private void makeAndSetErrorBuildResult( BuildContext context, Throwable e )
+        throws ContinuumStoreException
+    {
+        makeBuild( context );
+
+        context.result = new ContinuumBuildResult();
+
+        context.result.setSuccess( false );
 
-        return result;
+        context.state = ContinuumProjectState.ERROR;
+
+        setBuildResult( context.build.getId(), context.state, context.result, context.scmResult, e );
     }
 
-    private ContinuumBuildResult runGoals( ContinuumBuilder builder, ContinuumProject project )
-        throws ContinuumException
+    private void setBuildResult( String buildId, int state, ContinuumBuildResult result, UpdateScmResult scmResult,
+                                 Throwable e )
+        throws ContinuumStoreException
     {
-        ContinuumBuildResult result = builder.build( project );
+        System.err.println( "Setting the build id '" + buildId + "' state to " + state );
 
-        if ( result == null )
-        {
-            getLogger().fatalError( "Internal error: the builder returned null." );
-        }
-
-        return result;
+        store.setBuildResult( buildId, state, result, scmResult, e );
     }
 
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
+    private void makeBuild( BuildContext context )
+        throws ContinuumStoreException
+    {
+        String buildId = store.createBuild( context.project.getId(), context.forced );
+
+        getLogger().info( "Build id: '" + buildId + "'." );
+
+        context.build = store.getBuild( buildId );
+
+        context.build.setUpdateScmResult( context.scmResult );
+    }
 
     // Check to see if there is only a single build in the builds list.
     public boolean isNew( ContinuumProject project )
@@ -282,18 +327,6 @@
     {
         Iterator it = store.getBuildsForProject( project.getId(), 0, 0 );
 
-        if ( !it.hasNext() )
-        {
-            return true;
-        }
-
-        it.next();
-
-        if ( it.hasNext() )
-        {
-            return false;
-        }
-
-        return true;
+        return CollectionUtils.iteratorToList( it ).size() == 0;
     }
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/BuildProjectTask.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/BuildProjectTask.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/BuildProjectTask.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/BuildProjectTask.java Fri May  6 00:30:25 2005
@@ -27,21 +27,17 @@
 {
     private String projectId;
 
-    private String buildId;
-
     private long timestamp;
 
-    private boolean force;
+    private boolean forced;
 
-    public BuildProjectTask( String projectId, String buildId, boolean force )
+    public BuildProjectTask( String projectId, boolean forced )
     {
         this.projectId = projectId;
 
-        this.buildId = buildId;
-
         this.timestamp = System.currentTimeMillis();
 
-        this.force = force;
+        this.forced = forced;
     }
 
     public String getProjectId()
@@ -49,18 +45,13 @@
         return projectId;
     }
 
-    public String getBuildId()
-    {
-        return buildId;
-    }
-
     public long getTimestamp()
     {
         return timestamp;
     }
 
-    public boolean isForce()
+    public boolean isForced()
     {
-        return force;
+        return forced;
     }
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/evaluator/BuildProjectTaskViabilityEvaluator.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/evaluator/BuildProjectTaskViabilityEvaluator.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/evaluator/BuildProjectTaskViabilityEvaluator.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/evaluator/BuildProjectTaskViabilityEvaluator.java Fri May  6 00:30:25 2005
@@ -106,7 +106,7 @@
             // If this build is forces, don't remove it
             // ----------------------------------------------------------------------
 
-            if ( buildProjectTask.isForce() )
+            if ( buildProjectTask.isForced() )
             {
                 continue;
             }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java Fri May  6 00:30:25 2005
@@ -17,6 +17,8 @@
  */
 
 import org.apache.maven.continuum.project.ContinuumBuild;
+import org.apache.maven.continuum.project.ContinuumProject;
+import org.apache.maven.continuum.scm.UpdateScmResult;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -26,6 +28,10 @@
 {
     String ROLE = ContinuumNotificationDispatcher.class.getName();
 
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
     String MESSAGE_ID_BUILD_STARTED = "BuildStarted";
 
     String MESSAGE_ID_CHECKOUT_STARTED = "CheckoutStarted";
@@ -42,17 +48,23 @@
 
     String CONTEXT_PROJECT = "project";
 
-    Object CONTEXT_BUILD_RESULT = "result";
+    String CONTEXT_BUILD_RESULT = "result";
+
+    String CONTEXT_UPDATE_SCM_RESULT = "updateScmResult";
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
 
-    void buildStarted( ContinuumBuild build );
+    void buildStarted( ContinuumProject project );
 
-    void checkoutStarted( ContinuumBuild build );
+    void checkoutStarted( ContinuumProject project );
 
-    void checkoutComplete( ContinuumBuild build );
+    void checkoutComplete( ContinuumProject project, UpdateScmResult scmResult );
 
-    void runningGoals( ContinuumBuild build );
+    void runningGoals( ContinuumProject project, ContinuumBuild build );
 
-    void goalsCompleted( ContinuumBuild build );
+    void goalsCompleted( ContinuumProject project, ContinuumBuild build );
 
-    void buildComplete( ContinuumBuild build );
+    void buildComplete( ContinuumProject project, ContinuumBuild build );
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java Fri May  6 00:30:25 2005
@@ -20,8 +20,10 @@
 import java.util.Map;
 
 import org.apache.maven.continuum.project.ContinuumBuild;
+import org.apache.maven.continuum.project.ContinuumProject;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.apache.maven.continuum.scm.UpdateScmResult;
 
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.notification.NotificationDispatcher;
@@ -45,51 +47,74 @@
     // ContinuumNotificationDispatcher Implementation
     // ----------------------------------------------------------------------
 
-    public void buildStarted( ContinuumBuild build )
+    public void buildStarted( ContinuumProject project )
     {
-        sendNotifiaction( MESSAGE_ID_BUILD_STARTED, build );
+        sendNotifiaction( MESSAGE_ID_BUILD_STARTED, project, null );
     }
 
-    public void checkoutStarted( ContinuumBuild build )
+    public void checkoutStarted( ContinuumProject project )
     {
-        sendNotifiaction( MESSAGE_ID_CHECKOUT_STARTED, build );
+        sendNotifiaction( MESSAGE_ID_CHECKOUT_STARTED, project, null );
     }
 
-    public void checkoutComplete( ContinuumBuild build )
+    public void checkoutComplete( ContinuumProject project, UpdateScmResult scmResult )
     {
-        sendNotifiaction( MESSAGE_ID_CHECKOUT_COMPLETE, build );
+        sendNotifiaction( MESSAGE_ID_CHECKOUT_COMPLETE, project, null );
     }
 
-    public void runningGoals( ContinuumBuild build )
+    public void runningGoals( ContinuumProject project, ContinuumBuild build )
     {
-        sendNotifiaction( MESSAGE_ID_RUNNING_GOALS, build );
+        sendNotifiaction( MESSAGE_ID_RUNNING_GOALS, project, build );
     }
 
-    public void goalsCompleted( ContinuumBuild build )
+    public void goalsCompleted( ContinuumProject project, ContinuumBuild build )
     {
-        sendNotifiaction( MESSAGE_ID_GOALS_COMPLETED, build );
+        sendNotifiaction( MESSAGE_ID_GOALS_COMPLETED, project, build );
     }
 
-    public void buildComplete( ContinuumBuild build )
+    public void buildComplete( ContinuumProject project, ContinuumBuild build )
     {
-        sendNotifiaction( MESSAGE_ID_BUILD_COMPLETE, build );
+        sendNotifiaction( MESSAGE_ID_BUILD_COMPLETE, project, build );
     }
 
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
 
-    private void sendNotifiaction( String messageId, ContinuumBuild build )
+
+    private void sendNotifiaction( String messageId,
+                                   ContinuumProject project,
+                                   ContinuumBuild build )
+    {
+        sendNotifiaction( messageId, project, build, null );
+    }
+
+    private void sendNotifiaction( String messageId,
+                                   ContinuumProject project,
+                                   ContinuumBuild build,
+                                   UpdateScmResult scmResult )
     {
         Map context = new HashMap();
 
+        // The objects are reread from the store to make sure they're getting the "final"
+        // state of the objects. Ideally this should be done on a pr notifier basis or the
+        // objects should be made read only.
+
         try
         {
-            context.put( CONTEXT_PROJECT, store.getProjectByBuild( build.getId() ) );
-
-            context.put( CONTEXT_BUILD, build );
+            context.put( CONTEXT_PROJECT, store.getProject( project.getId() ) );
 
-            context.put( CONTEXT_BUILD_RESULT, store.getBuildResultForBuild( build.getId() ) );
+            if ( build != null )
+            {
+                context.put( CONTEXT_BUILD, store.getBuild( build.getId() ) );
+
+                context.put( CONTEXT_BUILD_RESULT, store.getBuildResultForBuild( build.getId() ) );
+            }
+
+            if ( scmResult != null )
+            {
+                context.put( CONTEXT_UPDATE_SCM_RESULT, scmResult );
+            }
         }
         catch ( ContinuumStoreException e )
         {

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/console/ConsoleNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/console/ConsoleNotifier.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/console/ConsoleNotifier.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/console/ConsoleNotifier.java Fri May  6 00:30:25 2005
@@ -52,15 +52,15 @@
 
         if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_STARTED ) )
         {
-            buildStarted( project, build );
+            buildStarted( project );
         }
         else if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_CHECKOUT_STARTED ) )
         {
-            checkoutStarted( project, build );
+            checkoutStarted( project );
         }
         else if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_CHECKOUT_COMPLETE ) )
         {
-            checkoutComplete( project, build );
+            checkoutComplete( project );
         }
         else if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_RUNNING_GOALS ) )
         {
@@ -84,19 +84,19 @@
     //
     // ----------------------------------------------------------------------
 
-    private void buildStarted( ContinuumProject project, ContinuumBuild build )
+    private void buildStarted( ContinuumProject project )
     {
-        out( project, build, "Build started." );
+        out( project, null, "Build started." );
     }
 
-    private void checkoutStarted( ContinuumProject project, ContinuumBuild build )
+    private void checkoutStarted( ContinuumProject project )
     {
-        out( project, build, "Checkout started." );
+        out( project, null, "Checkout started." );
     }
 
-    private void checkoutComplete( ContinuumProject project, ContinuumBuild build )
+    private void checkoutComplete( ContinuumProject project )
     {
-        out( project, build, "Checkout complete." );
+        out( project, null, "Checkout complete." );
     }
 
     private void runningGoals( ContinuumProject project, ContinuumBuild build )
@@ -132,7 +132,7 @@
     {
         System.out.println( "Build event for project '" + project.getName() + "':" + msg );
 
-        if ( !StringUtils.isEmpty( build.getError() ) )
+        if ( build != null && !StringUtils.isEmpty( build.getError() ) )
         {
             System.out.println( build.getError() );
         }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java Fri May  6 00:30:25 2005
@@ -152,6 +152,19 @@
 
         ContinuumBuildResult result = (ContinuumBuildResult) context.get( ContinuumNotificationDispatcher.CONTEXT_BUILD_RESULT );
 
+        // ----------------------------------------------------------------------
+        // If there wasn't any building done, don't notify
+        // ----------------------------------------------------------------------
+
+        if ( build == null )
+        {
+            return;
+        }
+
+        // ----------------------------------------------------------------------
+        // Generate and send email
+        // ----------------------------------------------------------------------
+
         try
         {
             if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE ) )
@@ -243,7 +256,7 @@
         // Send the mail
         // ----------------------------------------------------------------------
 
-        String subject = generateSubject( project, build, buildResult );
+        String subject = generateSubject( project );
 
         sendMessage( project, recipients, subject, content );
     }
@@ -252,28 +265,27 @@
     //
     // ----------------------------------------------------------------------
 
-    private static String generateSubject( ContinuumProject project, ContinuumBuild build, ContinuumBuildResult result )
+    private String generateSubject( ContinuumProject project )
     {
-        int state = build.getState();
+        int state = project.getState();
 
-        if ( state == ContinuumProjectState.ERROR )
+        if ( state == ContinuumProjectState.OK )
         {
-            return "[continuum] BUILD ERROR: " + project.getName();
+            return "[continuum] BUILD SUCCESSFUL: " + project.getName();
         }
-        else if ( state == ContinuumProjectState.OK || state == ContinuumProjectState.FAILED )
+        else if ( state == ContinuumProjectState.FAILED )
         {
-            if ( !result.isSuccess() )
-            {
-                return "[continuum] BUILD FAILURE: " + project.getName();
-            }
-            else
-            {
-                return "[continuum] BUILD SUCCESSFUL: " + project.getName();
-            }
+            return "[continuum] BUILD FAILURE: " + project.getName();
+        }
+        else if ( state == ContinuumProjectState.ERROR )
+        {
+            return "[continuum] BUILD ERROR: " + project.getName();
         }
         else
         {
-            return "[continuum] ERROR: Unknown build state";
+            getLogger().warn( "Unknown build state " + project.getState() );
+
+            return "[continuum] ERROR: Unknown build state " + project.getState();
         }
     }
 
@@ -346,8 +358,14 @@
 
     private boolean shouldNotify( ContinuumBuild build, ContinuumBuild previousBuild )
     {
+        if ( build == null )
+        {
+            return true;
+        }
+
         // Always send if the project failed
-        if ( build.getState() == ContinuumProjectState.FAILED )
+        if ( build.getState() == ContinuumProjectState.FAILED ||
+             build.getState() == ContinuumProjectState.ERROR)
         {
             return true;
         }
@@ -392,7 +410,7 @@
 
         ContinuumBuild build = (ContinuumBuild) it.next();
 
-        if ( !build.getId().equals( currentBuild.getId() ) )
+        if ( currentBuild != null && !build.getId().equals( currentBuild.getId() ) )
         {
             throw new ContinuumException( "INTERNAL ERROR: The current build wasn't the first in the build list. " +
                                           "Current build: '" + currentBuild.getId() + "', " +

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/state/ContinuumProjectStateGuard.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/state/ContinuumProjectStateGuard.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/state/ContinuumProjectStateGuard.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/state/ContinuumProjectStateGuard.java Fri May  6 00:30:25 2005
@@ -26,6 +26,9 @@
 {
     String ROLE = ContinuumProjectStateGuard.class.getName();
 
+    void assertInState( ContinuumProject project, int state )
+        throws ContinuumProjectStateGuardException;
+
     void assertTransition( ContinuumProject project, int newState )
         throws ContinuumProjectStateGuardException;
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/state/DefaultContinuumProjectStateGuard.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/state/DefaultContinuumProjectStateGuard.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/state/DefaultContinuumProjectStateGuard.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/state/DefaultContinuumProjectStateGuard.java Fri May  6 00:30:25 2005
@@ -89,6 +89,18 @@
     // ContinuumProjectStateGuard Implementation
     // ----------------------------------------------------------------------
 
+    public void assertInState( ContinuumProject project, int state )
+        throws ContinuumProjectStateGuardException
+    {
+        if ( project.getState() == state )
+        {
+            return;
+        }
+
+        throw new ContinuumProjectStateGuardException( "Expected project to be in state '" + decodeState( state ) + "', " +
+                                                       "but it was in the state '" + decodeState( project.getState() ) + "'." );
+    }
+
     public void assertTransition( ContinuumProject project, int newState )
         throws ContinuumProjectStateGuardException
     {

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/DefaultContinuumScm.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/DefaultContinuumScm.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/DefaultContinuumScm.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/DefaultContinuumScm.java Fri May  6 00:30:25 2005
@@ -84,6 +84,8 @@
                 throw new ContinuumScmException( "Error while checking out the project.", result );
             }
 
+            getLogger().info( "Checked out " + result.getCheckedOutFiles().size() + " files." );
+
             return result;
         }
         catch ( ScmRepositoryException e )
@@ -152,6 +154,8 @@
 
                 throw new ContinuumScmException( "Error while checking out the project.", result );
             }
+
+            getLogger().info( "Updated " + result.getUpdatedFiles().size() + " files." );
 
             return result;
         }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java Fri May  6 00:30:25 2005
@@ -85,7 +85,7 @@
     String createBuild( String projectId, boolean forced )
         throws ContinuumStoreException;
 
-    void setBuildResult( String buildId, int state, ContinuumBuildResult result, Throwable error )
+    void setBuildResult( String buildId, int state, ContinuumBuildResult result, UpdateScmResult scmResult, Throwable error )
         throws ContinuumStoreException;
 
     ContinuumBuild getBuild( String buildId )
@@ -104,15 +104,21 @@
         throws ContinuumStoreException;
 
     // ----------------------------------------------------------------------
-    // SCM
+    // Project and Build state transitions
     // ----------------------------------------------------------------------
 
+    void setBuildSignalled( String projectId )
+        throws ContinuumStoreException;
+
     void setCheckoutDone( String projectId, CheckOutScmResult scmResult )
         throws ContinuumStoreException;
 
-    void setIsUpdating( String buildId )
+    void setIsUpdating( String projectId )
+        throws ContinuumStoreException;
+
+    void setUpdateDone( String projectId )
         throws ContinuumStoreException;
 
-    void setUpdateDone( String buildId, UpdateScmResult scmResult )
+    void setBuildNotExecuted( String projectId )
         throws ContinuumStoreException;
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java Fri May  6 00:30:25 2005
@@ -392,15 +392,13 @@
 
             ContinuumProject project = store.getContinuumProject( projectId, false );
 
-            projectStateGuard.assertTransition( project, ContinuumProjectState.BUILD_SIGNALED );
-
-            project.setState( ContinuumProjectState.BUILD_SIGNALED );
+            projectStateGuard.assertInState( project, ContinuumProjectState.BUILDING );
 
             ContinuumBuild build = new ContinuumBuild();
 
             build.setStartTime( System.currentTimeMillis() );
 
-            build.setState( ContinuumProjectState.BUILD_SIGNALED );
+            build.setState( ContinuumProjectState.BUILDING );
 
             build.setProject( project );
 
@@ -422,7 +420,7 @@
         }
     }
 
-    public void setBuildResult( String buildId, int state, ContinuumBuildResult result, Throwable error )
+    public void setBuildResult( String buildId, int state, ContinuumBuildResult result, UpdateScmResult scmResult, Throwable error )
         throws ContinuumStoreException
     {
         try
@@ -443,6 +441,8 @@
 
             build.setError( throwableToString( error ) );
 
+            build.setUpdateScmResult( scmResult );
+
             store.commit();
 
             // ----------------------------------------------------------------------
@@ -482,6 +482,8 @@
     public ContinuumBuild getLatestBuildForProject( String projectId )
         throws ContinuumStoreException
     {
+        // TODO: Find a better way to query for this object.
+
         try
         {
             List builds = store.getContinuumProject( projectId, true ).getBuilds();
@@ -562,10 +564,6 @@
                 return null;
             }
 
-            Object id = JDOHelper.getObjectId( build.getBuildResult() );
-
-            ContinuumBuildResult result = store.getContinuumBuildResultByJdoId( id, false );
-
             // TODO: Having to copy the objects feels a /bit/ strange.
 
             List changedFiles = new ArrayList();
@@ -597,6 +595,29 @@
     //
     // ----------------------------------------------------------------------
 
+    public void setBuildSignalled( String projectId )
+        throws ContinuumStoreException
+    {
+        try
+        {
+            store.begin();
+
+            ContinuumProject project = store.getContinuumProject( projectId, false );
+
+            projectStateGuard.assertTransition( project, ContinuumProjectState.BUILD_SIGNALED );
+
+            project.setState( ContinuumProjectState.BUILD_SIGNALED );
+
+            store.commit();
+        }
+        catch ( Exception e )
+        {
+            rollback( store );
+
+            throw new ContinuumStoreException( "Error while setting project state: '" + projectId + "'.", e );
+        }
+    }
+
     public void setCheckoutDone( String projectId, CheckOutScmResult scmResult )
         throws ContinuumStoreException
     {
@@ -633,23 +654,19 @@
         }
     }
 
-    public void setIsUpdating( String buildId )
+    public void setIsUpdating( String projectId )
         throws ContinuumStoreException
     {
         try
         {
             store.begin();
 
-            ContinuumBuild build = store.getContinuumBuild( buildId, false );
-
-            ContinuumProject project = build.getProject();
+            ContinuumProject project = store.getContinuumProject( projectId, false );
 
             projectStateGuard.assertTransition( project, ContinuumProjectState.UPDATING );
 
             project.setState( ContinuumProjectState.UPDATING );
 
-            build.setState( ContinuumProjectState.UPDATING );
-
             store.commit();
         }
         catch ( Exception e )
@@ -660,24 +677,54 @@
         }
     }
 
-    public void setUpdateDone( String buildId, UpdateScmResult scmResult )
+    public void setUpdateDone( String projectId )
         throws ContinuumStoreException
     {
         try
         {
             store.begin();
 
-            ContinuumBuild build = store.getContinuumBuild( buildId, false );
-
-            build.setUpdateScmResult( scmResult );
-
-            ContinuumProject project = build.getProject();
+            ContinuumProject project = store.getContinuumProject( projectId, false );
 
             projectStateGuard.assertTransition( project, ContinuumProjectState.BUILDING );
 
             project.setState( ContinuumProjectState.BUILDING );
 
-            build.setState( ContinuumProjectState.BUILDING );
+            store.commit();
+        }
+        catch ( Exception e )
+        {
+            rollback( store );
+
+            throw new ContinuumStoreException( "Error while setting update scm result.", e );
+        }
+    }
+
+    public void setBuildNotExecuted( String projectId )
+        throws ContinuumStoreException
+    {
+        try
+        {
+            store.begin();
+
+            ContinuumProject project = store.getContinuumProject( projectId, false );
+
+            int state;
+
+            ContinuumBuild latestBuild = getLatestBuildForProject( projectId );
+
+            if ( latestBuild == null )
+            {
+                state = ContinuumProjectState.NEW;
+            }
+            else
+            {
+                state = latestBuild.getState();
+            }
+
+            projectStateGuard.assertTransition( project, state );
+
+            project.setState( state );
 
             store.commit();
         }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/trigger/socket/SimpleSocketTrigger.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/trigger/socket/SimpleSocketTrigger.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/trigger/socket/SimpleSocketTrigger.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/trigger/socket/SimpleSocketTrigger.java Fri May  6 00:30:25 2005
@@ -68,11 +68,9 @@
                 return;
             }
 
-            String buildId = getContinuum().buildProject( id, false );
+            getContinuum().buildProject( id, false );
 
             out( printer, "OK" );
-
-            out( printer, "id=" + buildId );
 
             out( printer, "Build of " + id + " scheduled." );
         }

Modified: maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml Fri May  6 00:30:25 2005
@@ -286,6 +286,9 @@
         <requirement>
           <role>org.apache.maven.continuum.buildcontroller.BuildController</role>
         </requirement>
+        <requirement>
+          <role>org.apache.maven.continuum.store.ContinuumStore</role>
+        </requirement>
       </requirements>
     </component>
 

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java Fri May  6 00:30:25 2005
@@ -18,7 +18,6 @@
 
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ModelloJPoxContinuumStoreTest;
-import org.apache.maven.continuum.project.ContinuumProject;
 
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.taskqueue.Task;
@@ -50,22 +49,22 @@
     {
         String name = "Project 1";
 
-        String project = ModelloJPoxContinuumStoreTest.addProject( store, name );
+        String projectId = ModelloJPoxContinuumStoreTest.addProject( store, name );
 
-        String build = buildProject( project, false );
+        buildProject( projectId, false );
 
-        assertNextBuildIs( build );
+        assertNextBuildIs( projectId );
 
         assertNextBuildIsNull();
 
-        String buildX = buildProject( project, false );
+        buildProject( projectId, false );
 
-        buildProject( project, false );
-        buildProject( project, false );
-        buildProject( project, false );
-        buildProject( project, false );
+        buildProject( projectId, false );
+        buildProject( projectId, false );
+        buildProject( projectId, false );
+        buildProject( projectId, false );
 
-        assertNextBuildIs( buildX );
+        assertNextBuildIs( projectId );
 
         assertNextBuildIsNull();
     }
@@ -77,35 +76,35 @@
 
         String name2 = "Project 2";
 
-        String project1 = ModelloJPoxContinuumStoreTest.addProject( store, name1 );
+        String projectId1 = ModelloJPoxContinuumStoreTest.addProject( store, name1 );
 
-        String project2 = ModelloJPoxContinuumStoreTest.addProject( store, name2 );
+        String projectId2 = ModelloJPoxContinuumStoreTest.addProject( store, name2 );
 
-        String build1 = buildProject( project1, false );
+        buildProject( projectId1, false );
 
-        String build2 = buildProject( project2, false );
+        buildProject( projectId2, false );
 
-        assertNextBuildIs( build1 );
+        assertNextBuildIs( projectId1 );
 
-        assertNextBuildIs( build2 );
+        assertNextBuildIs( projectId2 );
 
         assertNextBuildIsNull();
 
-        String buildX1 = buildProject( project1, false );
+        buildProject( projectId1, false );
 
-        String buildX2 = buildProject( project2, false );
+        buildProject( projectId2, false );
 
-        buildProject( project1, false );
-        buildProject( project2, false );
-        buildProject( project1, false );
-        buildProject( project2, false );
-        buildProject( project1, false );
-        buildProject( project2, false );
-        buildProject( project1, false );
-        buildProject( project2, false );
+        buildProject( projectId1, false );
+        buildProject( projectId2, false );
+        buildProject( projectId1, false );
+        buildProject( projectId2, false );
+        buildProject( projectId1, false );
+        buildProject( projectId2, false );
+        buildProject( projectId1, false );
+        buildProject( projectId2, false );
 
-        assertNextBuildIs( buildX1 );
-        assertNextBuildIs( buildX2 );
+        assertNextBuildIs( projectId1 );
+        assertNextBuildIs( projectId2 );
 
         assertNextBuildIsNull();
     }
@@ -115,25 +114,25 @@
     {
         String name = "Project 1";
 
-        String project = ModelloJPoxContinuumStoreTest.addProject( store, name );
+        String projectId = ModelloJPoxContinuumStoreTest.addProject( store, name );
 
-        String build = buildProject( project, true );
+        buildProject( projectId, true );
 
-        assertNextBuildIs( build );
+        assertNextBuildIs( projectId );
 
         assertNextBuildIsNull();
 
-        String build1 = buildProject( project, true );
-        String build2 = buildProject( project, true );
-        String build3 = buildProject( project, true );
-        String build4 = buildProject( project, true );
-        String build5 = buildProject( project, true );
+        buildProject( projectId, true );
+        buildProject( projectId, true );
+        buildProject( projectId, true );
+        buildProject( projectId, true );
+        buildProject( projectId, true );
 
-        assertNextBuildIs( build1 );
-        assertNextBuildIs( build2 );
-        assertNextBuildIs( build3 );
-        assertNextBuildIs( build4 );
-        assertNextBuildIs( build5 );
+        assertNextBuildIs( projectId );
+        assertNextBuildIs( projectId );
+        assertNextBuildIs( projectId );
+        assertNextBuildIs( projectId );
+        assertNextBuildIs( projectId );
 
         assertNextBuildIsNull();
     }
@@ -142,19 +141,13 @@
     //
     // ----------------------------------------------------------------------
 
-    private String buildProject( String projectId, boolean force )
+    private void buildProject( String projectId, boolean force )
         throws Exception
     {
-        ContinuumProject project = store.getProject( projectId );
-
-        String buildId = store.createBuild( project.getId(), force );
-
-        buildQueue.put( new BuildProjectTask( projectId, buildId, force ) );
-
-        return buildId;
+        buildQueue.put( new BuildProjectTask( projectId, force ) );
     }
 
-    private void assertNextBuildIs( String expectedBuildId )
+    private void assertNextBuildIs( String expectedProjectId )
         throws Exception
     {
         Task task = buildQueue.take();
@@ -163,7 +156,7 @@
 
         BuildProjectTask buildProjectTask = ( BuildProjectTask ) task;
 
-        assertEquals( "Didn't get the expected build id.", expectedBuildId, buildProjectTask.getBuildId() );
+        assertEquals( "Didn't get the expected project id.", expectedProjectId, buildProjectTask.getProjectId() );
     }
 
     private void assertNextBuildIsNull()
@@ -173,7 +166,7 @@
 
         if ( task != null )
         {
-            fail( "Got a non-null build id returned: " + (( BuildProjectTask ) task ).getBuildId() );
+            fail( "Got a non-null build task returned. Project id: " + ( (BuildProjectTask) task ).getProjectId() );
         }
     }
 }

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java Fri May  6 00:30:25 2005
@@ -16,10 +16,6 @@
  * limitations under the License.
  */
 
-import java.util.Properties;
-
-import org.apache.maven.continuum.project.AntProject;
-import org.apache.maven.continuum.project.ContinuumBuild;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ModelloJPoxContinuumStoreTest;
 
@@ -42,10 +38,14 @@
 
         String projectId = ModelloJPoxContinuumStoreTest.addProject( store, "Test Project" );
 
-        String buildId = store.createBuild( projectId, false );
+        store.setBuildSignalled( projectId );
+
+        store.setIsUpdating( projectId );
 
-        ContinuumBuild build = store.getBuild( buildId );
+        store.setUpdateDone( projectId );
+
+        String buildId = store.createBuild( projectId, false );
 
-        notificationDispatcher.buildComplete( build );
+        notificationDispatcher.buildComplete( store.getProject( projectId ), store.getBuild( buildId ) );
     }
 }

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java Fri May  6 00:30:25 2005
@@ -29,9 +29,9 @@
 import org.apache.maven.continuum.project.ContinuumJPoxStore;
 import org.apache.maven.continuum.project.ContinuumProject;
 import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.apache.maven.continuum.scm.CheckOutScmResult;
 import org.apache.maven.continuum.scm.ScmFile;
 import org.apache.maven.continuum.scm.UpdateScmResult;
-import org.apache.maven.continuum.scm.CheckOutScmResult;
 
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.jdo.JdoFactory;
@@ -45,19 +45,25 @@
 public class ModelloJPoxContinuumStoreTest
     extends PlexusTestCase
 {
+    private ContinuumStore store;
+
+    private JdoFactory jdoFactory;
+
     public void setUp()
         throws Exception
     {
         super.setUp();
 
         FileUtils.cleanDirectory( getTestPath( "target/plexus-home" ) );
+
+        jdoFactory = (JdoFactory) lookup( JdoFactory.ROLE );
+
+        store = (ContinuumStore) lookup( ContinuumStore.ROLE );
     }
 
     public void testTransactionHandling()
         throws Exception
     {
-        JdoFactory jdoFactory = (JdoFactory) lookup( JdoFactory.ROLE );
-
         ContinuumJPoxStore store = new ContinuumJPoxStore( jdoFactory.getPersistenceManagerFactory() );
 
         // ----------------------------------------------------------------------
@@ -172,16 +178,10 @@
 
         String projectId = store.addProject( name, scmUrl, nagEmailAddress, version, builderId, workingDirectory, configuration );
 
-        System.err.println( "Added project, id: " + projectId );
-
         assertNotNull( "The project id is null.", projectId );
 
-        System.err.println( "Loading project" );
-
         ContinuumProject project = store.getProject( projectId );
 
-        System.err.println( "project.id: " + project.getId() );
-
         assertProjectEquals( projectId, name, scmUrl, nagEmailAddress, version, builderId, workingDirectory,
                              configuration, project );
     }
@@ -298,9 +298,6 @@
 
         String id1 = store.addProject( name1, scmUrl1, nagEmailAddress1, version1, builderId1, workingDirectory1, configuration1 );
 
-        ContinuumProject a = store.getProject( id1 );
-        System.err.println( "a.name: " + a.getName() );
-
         String name2 = "Test Project 2";
         String scmUrl2 = "scm:local:src/test/repo";
         String nagEmailAddress2 = "foo@bar.com";
@@ -374,23 +371,25 @@
 
         String projectId = addProject( "Test Project" );
 
-        String buildId = store.createBuild( projectId, false );
+        store.setBuildSignalled( projectId );
 
-        store.setIsUpdating( buildId );
+        store.setIsUpdating( projectId );
 
-        UpdateScmResult updateScmResult = new UpdateScmResult();
+        store.setUpdateDone( projectId );
+
+        String buildId = store.createBuild( projectId, false );
+
+        UpdateScmResult scmResult = new UpdateScmResult();
 
         ScmFile file = new ScmFile();
 
         file.setPath( "foo" );
 
-        updateScmResult.addUpdatedFile( file );
-
-        store.setUpdateDone( buildId, updateScmResult );
+        scmResult.addUpdatedFile( file );
 
         ContinuumBuildResult result = new ShellBuildResult();
 
-        store.setBuildResult( buildId, ContinuumProjectState.OK, result, null );
+        store.setBuildResult( buildId, ContinuumProjectState.OK, result, scmResult, null );
 
         store.removeProject( projectId );
     }
@@ -410,6 +409,12 @@
 
         String projectId = addProject( "Test Project" );
 
+        store.setBuildSignalled( projectId );
+
+        store.setIsUpdating( projectId );
+
+        store.setUpdateDone( projectId );
+
         String buildId = store.createBuild( projectId, false );
 
         Iterator it = store.getBuildsForProject( projectId, 0, 0 );
@@ -437,15 +442,37 @@
         jdoFactory.getPersistenceManagerFactory().close();
 
         // ----------------------------------------------------------------------
-        //
+        // Set up projects
         // ----------------------------------------------------------------------
 
         String projectId = addProject( "Test Project" );
 
+        store.setBuildSignalled( projectId );
+
+        store.setIsUpdating( projectId );
+
+        store.setUpdateDone( projectId );
+
         String projectIdFoo = addProject( "Foo Project" );
 
+        store.setBuildSignalled( projectIdFoo );
+
+        store.setIsUpdating( projectIdFoo );
+
+        store.setUpdateDone( projectIdFoo );
+
         String projectIdBar = addProject( "Bar Project" );
 
+        store.setBuildSignalled( projectIdBar );
+
+        store.setIsUpdating( projectIdBar );
+
+        store.setUpdateDone( projectIdBar );
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
         List expectedBuilds = new ArrayList();
 
         for ( int i = 0; i < 10; i++ )
@@ -498,23 +525,37 @@
 
         String projectId = addProject( "Test Project" );
 
+        store.setBuildSignalled( projectId );
+
+        assertInState( projectId, ContinuumProjectState.BUILD_SIGNALED );
+
+        store.setIsUpdating( projectId );
+
+        assertInState( projectId, ContinuumProjectState.UPDATING );
+
+        store.setUpdateDone( projectId );
+
+        assertInState( projectId, ContinuumProjectState.BUILDING );
+
         long now = System.currentTimeMillis();
 
         String buildId = store.createBuild( projectId, false );
 
+        assertInState( projectId, ContinuumProjectState.BUILDING );
+
         assertIsCommitted( store );
 
         assertNotNull( buildId );
 
         // ----------------------------------------------------------------------
-        // Check that the project's has been updated
+        // Check that the project's state has been updated
         // ----------------------------------------------------------------------
 
         ContinuumProject project = store.getProject( projectId );
 
         assertIsCommitted( store );
 
-        assertEquals( ContinuumProjectState.BUILD_SIGNALED, project.getState() );
+        assertEquals( ContinuumProjectState.BUILDING, project.getState() );
 
         // ----------------------------------------------------------------------
         // Check the build
@@ -532,11 +573,7 @@
 
         assertNull( build.getError() );
 
-        assertEquals( ContinuumProjectState.BUILD_SIGNALED, build.getState() );
-
-        store.setIsUpdating( buildId );
-
-        store.setUpdateDone( buildId, new UpdateScmResult() );
+        assertEquals( ContinuumProjectState.BUILDING, build.getState() );
 
         // ----------------------------------------------------------------------
         // Check the build result
@@ -548,6 +585,8 @@
 
         assertNull( result );
 
+        UpdateScmResult scmResult = new UpdateScmResult();
+
         ShellBuildResult shellBuildResult = new ShellBuildResult();
 
         shellBuildResult.setExitCode( 1 );
@@ -556,7 +595,7 @@
 
         shellBuildResult.setStandardError( "error" );
 
-        store.setBuildResult( buildId, ContinuumProjectState.OK, shellBuildResult, null );
+        store.setBuildResult( buildId, ContinuumProjectState.OK, shellBuildResult, scmResult, null );
 
         assertIsCommitted( store );
 
@@ -573,11 +612,19 @@
         assertEquals( "output", shellBuildResult.getStandardOutput() );
 
         assertEquals( "error", shellBuildResult.getStandardError() );
-   }
+    }
 
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
+
+    private void assertInState( String projectId, int state )
+        throws ContinuumStoreException
+    {
+        ContinuumProject project = store.getProject( projectId );
+
+        assertEquals( state, project.getState() );
+    }
 
     private void assertIsCommitted( ContinuumStore store )
     {

Modified: maven/continuum/trunk/continuum-model/src/main/resources/continuum.mdo
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-model/src/main/resources/continuum.mdo?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-model/src/main/resources/continuum.mdo (original)
+++ maven/continuum/trunk/continuum-model/src/main/resources/continuum.mdo Fri May  6 00:30:25 2005
@@ -264,11 +264,6 @@
           <version>1.0.0</version>
           <type>boolean</type>
         </field>
-        <field>
-          <name>buildExecuted</name>
-          <version>1.0.0</version>
-          <type>boolean</type>
-        </field>
       </fields>
     </class>
 

Modified: maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java?rev=168554&r1=168553&r2=168554&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java (original)
+++ maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java Fri May  6 00:30:25 2005
@@ -290,7 +290,9 @@
     {
         try
         {
-            return makeHashtable( "buildId", continuum.buildProject( projectId, force ) );
+            continuum.buildProject( projectId, force );
+
+            return makeHashtable();
         }
         catch ( Throwable e )
         {



Mime
View raw message