continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r494852 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/notification/ continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/ continuum-core/src/main/java/org/apache/maven/continuum/core/...
Date Wed, 10 Jan 2007 15:33:07 GMT
Author: evenisse
Date: Wed Jan 10 07:33:05 2007
New Revision: 494852

URL: http://svn.apache.org/viewvc?view=rev&rev=494852
Log:
Put the build definition in the notification dispatcher context

Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.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/core/action/ExecuteBuilderContinuumAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java?view=diff&rev=494852&r1=494851&r2=494852
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java
Wed Jan 10 07:33:05 2007
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 
@@ -53,6 +54,8 @@
 
     String CONTEXT_PROJECT = "project";
 
+    String CONTEXT_BUILD_DEFINITION = "buildDefinition";
+
     String CONTEXT_PROJECT_NOTIFIER = "projectNotifier";
 
     String CONTEXT_BUILD_RESULT = "result";
@@ -63,15 +66,15 @@
     //
     // ----------------------------------------------------------------------
 
-    void buildStarted( Project project );
+    void buildStarted( Project project, BuildDefinition buildDefinition );
 
-    void checkoutStarted( Project project );
+    void checkoutStarted( Project project, BuildDefinition buildDefinition );
 
-    void checkoutComplete( Project project );
+    void checkoutComplete( Project project, BuildDefinition buildDefinition );
 
-    void runningGoals( Project project, BuildResult build );
+    void runningGoals( Project project, BuildDefinition buildDefinition, BuildResult buildResult
);
 
-    void goalsCompleted( Project project, BuildResult build );
+    void goalsCompleted( Project project, BuildDefinition buildDefinition, BuildResult buildResult
);
 
-    void buildComplete( Project project, BuildResult build );
+    void buildComplete( Project project, BuildDefinition buildDefinition, BuildResult buildResult
);
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?view=diff&rev=494852&r1=494851&r2=494852
==============================================================================
--- 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
Wed Jan 10 07:33:05 2007
@@ -141,7 +141,7 @@
                 //just log the error but don't stop the build from progressing in order not
to suppress any build result messages there 
                 getLogger().error( "Error executing action update-project-from-working-directory
'", e );
             }
-            
+
             performAction( "execute-builder", context );
 
             performAction( "deploy-artifact", context );
@@ -216,7 +216,7 @@
         }
         finally
         {
-            notifierDispatcher.buildComplete( project, context.getBuildResult() );
+            notifierDispatcher.buildComplete( project, context.getBuildDefinition(), context.getBuildResult()
);
         }
     }
 
@@ -293,7 +293,7 @@
             throw new TaskExecutionException( "Error persisting project", e );
         }
 
-        notifierDispatcher.buildStarted( project );
+        notifierDispatcher.buildStarted( project, context.getBuildDefinition() );
 
     }
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java?view=diff&rev=494852&r1=494851&r2=494852
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
Wed Jan 10 07:33:05 2007
@@ -41,10 +41,8 @@
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
- *
- * @plexus.component
- *   role="org.codehaus.plexus.action.Action"
- *   role-hint="execute-builder"
+ * @plexus.component role="org.codehaus.plexus.action.Action"
+ * role-hint="execute-builder"
  */
 public class ExecuteBuilderContinuumAction
     extends AbstractContinuumAction
@@ -97,9 +95,8 @@
         // ----------------------------------------------------------------------
 
         if ( !isFirstRun && project.getOldState() != ContinuumProjectState.NEW &&
-            project.getOldState() != ContinuumProjectState.CHECKEDOUT &&
-            scmResult.getChanges().size() == 0 && !hasUpdatedDependencies &&
-            trigger != ContinuumProjectState.TRIGGER_FORCED && !isNew( project )
)
+            project.getOldState() != ContinuumProjectState.CHECKEDOUT && scmResult.getChanges().size()
== 0 &&
+            !hasUpdatedDependencies && trigger != ContinuumProjectState.TRIGGER_FORCED
&& !isNew( project ) )
         {
             getLogger().info( "No files updated, not building. Project id '" + project.getId()
+ "'." );
 
@@ -113,69 +110,70 @@
         }
 
         // ----------------------------------------------------------------------
-        // Make the build
+        // Make the buildResult
         // ----------------------------------------------------------------------
 
-        BuildResult build = new BuildResult();
+        BuildResult buildResult = new BuildResult();
 
-        build.setStartTime( new Date().getTime() );
+        buildResult.setStartTime( new Date().getTime() );
 
-        build.setState( ContinuumProjectState.BUILDING );
+        buildResult.setState( ContinuumProjectState.BUILDING );
 
-        build.setTrigger( trigger );
+        buildResult.setTrigger( trigger );
 
-        build.setScmResult( scmResult );
-        
-        build.setModifiedDependencies( updatedDependencies );
+        buildResult.setScmResult( scmResult );
 
-        store.addBuildResult( project, build );
+        buildResult.setModifiedDependencies( updatedDependencies );
 
-        context.put( KEY_BUILD_ID, Integer.toString( build.getId() ) );
+        store.addBuildResult( project, buildResult );
 
-        build = store.getBuildResult( build.getId() );
+        context.put( KEY_BUILD_ID, Integer.toString( buildResult.getId() ) );
+
+        buildResult = store.getBuildResult( buildResult.getId() );
 
         try
         {
-            notifier.runningGoals( project, build );
+            notifier.runningGoals( project, buildDefinition, buildResult );
 
-            File buildOutputFile = configurationService.getBuildOutputFile( build.getId(),
project.getId() );
+            File buildOutputFile = configurationService.getBuildOutputFile( buildResult.getId(),
project.getId() );
 
             ContinuumBuildExecutionResult result = buildExecutor.build( project, buildDefinition,
buildOutputFile );
 
-            build.setState( result.getExitCode() == 0 ? ContinuumProjectState.OK : ContinuumProjectState.FAILED
);
+            buildResult.setState( result.getExitCode() == 0 ? ContinuumProjectState.OK :
ContinuumProjectState.FAILED );
 
-            build.setExitCode( result.getExitCode() );
+            buildResult.setExitCode( result.getExitCode() );
         }
         catch ( Throwable e )
         {
-            getLogger().error( "Error running build", e );
+            getLogger().error( "Error running buildResult", e );
 
-            build.setState( ContinuumProjectState.ERROR );
+            buildResult.setState( ContinuumProjectState.ERROR );
 
-            build.setError( ContinuumUtils.throwableToString( e ) );
+            buildResult.setError( ContinuumUtils.throwableToString( e ) );
         }
         finally
         {
-            build.setEndTime( new Date().getTime() );
+            buildResult.setEndTime( new Date().getTime() );
 
-            if ( build.getState() == ContinuumProjectState.OK )
+            if ( buildResult.getState() == ContinuumProjectState.OK )
             {
                 project.setBuildNumber( project.getBuildNumber() + 1 );
             }
 
-            project.setLatestBuildId( build.getId() );
+            project.setLatestBuildId( buildResult.getId() );
 
-            buildDefinition.setLatestBuildId( build.getId() );
+            buildDefinition.setLatestBuildId( buildResult.getId() );
 
-            build.setBuildNumber( project.getBuildNumber() );
+            buildResult.setBuildNumber( project.getBuildNumber() );
 
-            if ( build.getState() != ContinuumProjectState.OK && build.getState()
!= ContinuumProjectState.FAILED &&
-                build.getState() != ContinuumProjectState.ERROR )
+            if ( buildResult.getState() != ContinuumProjectState.OK &&
+                buildResult.getState() != ContinuumProjectState.FAILED &&
+                buildResult.getState() != ContinuumProjectState.ERROR )
             {
-                build.setState( ContinuumProjectState.ERROR );
+                buildResult.setState( ContinuumProjectState.ERROR );
             }
 
-            project.setState( build.getState() );
+            project.setState( buildResult.getState() );
 
             // ----------------------------------------------------------------------
             // Set the test result
@@ -184,7 +182,7 @@
             try
             {
                 TestResult testResult = buildExecutor.getTestResults( project );
-                build.setTestResult( testResult );
+                buildResult.setTestResult( testResult );
             }
             catch ( Throwable t )
             {
@@ -192,18 +190,18 @@
             }
 
             // ----------------------------------------------------------------------
-            // Copy over the build result
+            // Copy over the buildResult result
             // ----------------------------------------------------------------------
 
-            store.updateBuildResult( build );
+            store.updateBuildResult( buildResult );
 
-            build = store.getBuildResult( build.getId() );
+            buildResult = store.getBuildResult( buildResult.getId() );
 
             store.storeBuildDefinition( buildDefinition );
 
             store.updateProject( project );
 
-            notifier.goalsCompleted( project, build );
+            notifier.goalsCompleted( project, buildDefinition, buildResult );
         }
     }
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java?view=diff&rev=494852&r1=494851&r2=494852
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
Wed Jan 10 07:33:05 2007
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+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;
@@ -31,11 +32,8 @@
 /**
  * @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
@@ -60,6 +58,8 @@
     {
         Project project = getProject( context );
 
+        BuildDefinition buildDefinition = getBuildDefinition( context );
+
         int state = project.getState();
 
         project.setState( ContinuumProjectState.UPDATING );
@@ -70,7 +70,7 @@
 
         try
         {
-            notifier.checkoutStarted( project );
+            notifier.checkoutStarted( project, buildDefinition );
 
             scmResult = scm.updateProject( project );
 
@@ -82,7 +82,7 @@
 
             store.updateProject( project );
 
-            notifier.checkoutComplete( project );
+            notifier.checkoutComplete( project, buildDefinition );
         }
     }
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java?view=diff&rev=494852&r1=494851&r2=494852
==============================================================================
--- 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
Wed Jan 10 07:33:05 2007
@@ -21,10 +21,11 @@
 
 import org.apache.maven.continuum.configuration.ConfigurationException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
+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.project.ProjectNotifier;
 import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
@@ -41,10 +42,8 @@
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
- *
- * @plexus.component
- *   role="org.apache.maven.continuum.notification.ContinuumNotificationDispatcher"
- *   role-hint="default"
+ * @plexus.component role="org.apache.maven.continuum.notification.ContinuumNotificationDispatcher"
+ * role-hint="default"
  */
 public class DefaultContinuumNotificationDispatcher
     extends AbstractLogEnabled
@@ -74,41 +73,42 @@
     // ContinuumNotificationDispatcher Implementation
     // ----------------------------------------------------------------------
 
-    public void buildStarted( Project project )
+    public void buildStarted( Project project, BuildDefinition buildDefinition )
     {
-        sendNotification( MESSAGE_ID_BUILD_STARTED, project, null );
+        sendNotification( MESSAGE_ID_BUILD_STARTED, project, buildDefinition, null );
     }
 
-    public void checkoutStarted( Project project )
+    public void checkoutStarted( Project project, BuildDefinition buildDefinition )
     {
-        sendNotification( MESSAGE_ID_CHECKOUT_STARTED, project, null );
+        sendNotification( MESSAGE_ID_CHECKOUT_STARTED, project, buildDefinition, null );
     }
 
-    public void checkoutComplete( Project project )
+    public void checkoutComplete( Project project, BuildDefinition buildDefinition )
     {
-        sendNotification( MESSAGE_ID_CHECKOUT_COMPLETE, project, null );
+        sendNotification( MESSAGE_ID_CHECKOUT_COMPLETE, project, buildDefinition, null );
     }
 
-    public void runningGoals( Project project, BuildResult build )
+    public void runningGoals( Project project, BuildDefinition buildDefinition, BuildResult
buildResult )
     {
-        sendNotification( MESSAGE_ID_RUNNING_GOALS, project, build );
+        sendNotification( MESSAGE_ID_RUNNING_GOALS, project, buildDefinition, buildResult
);
     }
 
-    public void goalsCompleted( Project project, BuildResult build )
+    public void goalsCompleted( Project project, BuildDefinition buildDefinition, BuildResult
buildResult )
     {
-        sendNotification( MESSAGE_ID_GOALS_COMPLETED, project, build );
+        sendNotification( MESSAGE_ID_GOALS_COMPLETED, project, buildDefinition, buildResult
);
     }
 
-    public void buildComplete( Project project, BuildResult build )
+    public void buildComplete( Project project, BuildDefinition buildDefinition, BuildResult
buildResult )
     {
-        sendNotification( MESSAGE_ID_BUILD_COMPLETE, project, build );
+        sendNotification( MESSAGE_ID_BUILD_COMPLETE, project, buildDefinition, buildResult
);
     }
 
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
 
-    private void sendNotification( String messageId, Project project, BuildResult build )
+    private void sendNotification( String messageId, Project project, BuildDefinition buildDefinition,
+                                   BuildResult buildResult )
     {
         Map context = new HashMap();
 
@@ -127,21 +127,21 @@
             project = store.getProjectWithAllDetails( project.getId() );
 
             context.put( CONTEXT_PROJECT, project );
+            context.put( CONTEXT_BUILD_DEFINITION, buildDefinition );
 
-            if ( build != null )
+            if ( buildResult != null )
             {
-                context.put( CONTEXT_BUILD, build );
+                context.put( CONTEXT_BUILD, buildResult );
 
-                if ( build.getEndTime() != 0 )
+                if ( buildResult.getEndTime() != 0 )
                 {
                     context.put( CONTEXT_BUILD_OUTPUT,
-                                 configurationService.getBuildOutput( build.getId(), project.getId()
) );
+                                 configurationService.getBuildOutput( buildResult.getId(),
project.getId() ) );
                 }
 
-                context.put( CONTEXT_UPDATE_SCM_RESULT, build.getScmResult() );
+                context.put( CONTEXT_UPDATE_SCM_RESULT, buildResult.getScmResult() );
             }
 
-
             ProjectGroup projectGroup = store.getProjectGroupWithBuildDetails( project.getProjectGroup().getId()
);
 
             // perform the project lvl notifications
@@ -157,7 +157,7 @@
                 {
                     sendNotification( messageId, (ProjectNotifier) i.next(), context );
                 }
-            }            
+            }
         }
         catch ( ContinuumStoreException e )
         {

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java?view=diff&rev=494852&r1=494851&r2=494852
==============================================================================
--- 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
Wed Jan 10 07:33:05 2007
@@ -56,6 +56,6 @@
 
         build = store.getBuildResult( build.getId() );
 
-        notificationDispatcher.buildComplete( project, build );
+        notificationDispatcher.buildComplete( project, null, build );
     }
 }



Mime
View raw message