continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r553552 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/store/ continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/ continuum-core/src/main/java/org/apache/maven/continuum/core/action/...
Date Thu, 05 Jul 2007 16:23:04 GMT
Author: evenisse
Date: Thu Jul  5 09:22:58 2007
New Revision: 553552

URL: http://svn.apache.org/viewvc?view=rev&rev=553552
Log:
[CONTINUUM-1226] Fix builds with multiple schedule

Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.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/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
    maven/continuum/trunk/continuum-model/src/main/mdo/continuum.xml
    maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java?view=diff&rev=553552&r1=553551&r2=553552
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
Thu Jul  5 09:22:58 2007
@@ -241,6 +241,8 @@
 
     BuildResult getLatestBuildResultForProject( int projectId );
 
+    BuildResult getLatestBuildResultForBuildDefinition( int projectId, int buildDefinitionId
);
+
     List getBuildResultsInSuccessForProject( int projectId, long fromDate );
 
     List getBuildResultsForProject( int projectId, long fromDate );

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=553552&r1=553551&r2=553552
==============================================================================
--- 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
Thu Jul  5 09:22:58 2007
@@ -323,7 +323,7 @@
 
             context.setBuildDefinition( buildDefinition );
 
-            BuildResult oldBuildResult = store.getLatestBuildResultForProject( projectId
);
+            BuildResult oldBuildResult = store.getLatestBuildResultForBuildDefinition( projectId,
buildDefinitionId );
 
             context.setOldBuildResult( oldBuildResult );
 
@@ -455,6 +455,12 @@
     protected boolean shouldBuild( BuildContext context )
         throws TaskExecutionException
     {
+        if ( context.getOldBuildResult() == null )
+        {
+            //The project was never be built with the current build definition
+            return true;
+        }
+
         boolean shouldBuild = true;
 
         Project project = context.getProject();

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=553552&r1=553551&r2=553552
==============================================================================
--- 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
Thu Jul  5 09:22:58 2007
@@ -162,7 +162,7 @@
 
             project.setLatestBuildId( buildResult.getId() );
 
-            buildDefinition.setLatestBuildId( buildResult.getId() );
+            buildResult.setBuildDefinition( buildDefinition);
 
             buildResult.setBuildNumber( project.getBuildNumber() );
 

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java?view=diff&rev=553552&r1=553551&r2=553552
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
Thu Jul  5 09:22:58 2007
@@ -59,12 +59,14 @@
         buildResult1.setEndTime( Calendar.getInstance().getTimeInMillis() );
         buildResult1.setState( ContinuumProjectState.OK );
         buildResult1.setSuccess( true );
+        buildResult1.setBuildDefinition( bd1 );
         getStore().addBuildResult( project1, buildResult1 );
         BuildResult buildResult2 = new BuildResult();
         buildResult2.setStartTime( Calendar.getInstance().getTimeInMillis() - 7200000 );
         buildResult2.setEndTime( Calendar.getInstance().getTimeInMillis() - 7200000 );
         buildResult2.setSuccess( true );
         buildResult2.setState( ContinuumProjectState.OK );
+        buildResult2.setBuildDefinition( bd1 );
         getStore().addBuildResult( project1, buildResult2 );
 
         Project project2 = createProject( "project2" );
@@ -107,11 +109,17 @@
         return builddef;
     }
 
+    private BuildContext getContext()
+        throws Exception
+    {
+        return controller.initializeBuildContext( projectId2, buildDefinitionId2,
+                                                  ContinuumProjectState.TRIGGER_SCHEDULED
);
+    }
+
     private BuildContext getContext( int hourOfLastExecution )
         throws Exception
     {
-        BuildContext context = controller.initializeBuildContext( projectId2, buildDefinitionId2,
-                                                                  ContinuumProjectState.TRIGGER_SCHEDULED
);
+        BuildContext context = getContext();
         BuildResult oldBuildResult = new BuildResult();
         oldBuildResult.setEndTime( Calendar.getInstance().getTimeInMillis() + ( hourOfLastExecution
* 3600000 ) );
         context.setOldBuildResult( oldBuildResult );
@@ -139,12 +147,20 @@
         p2.setState( ContinuumProjectState.NEW );
         getStore().updateProject( p2 );
 
-        BuildContext context = getContext( +1 );
+        BuildContext context = getContext();
         controller.checkProjectDependencies( context );
         assertEquals( 0, context.getModifiedDependencies().size() );
         assertTrue( controller.shouldBuild( context ) );
     }
 
+    public void testWithNewBuildDefinition()
+        throws Exception
+    {
+        BuildContext context = getContext();
+        assertNull( context.getOldBuildResult() );
+        assertTrue( controller.shouldBuild( context ) );
+    }
+
     public void testWithDependencyChanges()
         throws Exception
     {
@@ -153,4 +169,4 @@
         assertEquals( 1, context.getModifiedDependencies().size() );
         assertTrue( controller.shouldBuild( context ) );
     }
-}
\ No newline at end of file
+}

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java?view=diff&rev=553552&r1=553551&r2=553552
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
Thu Jul  5 09:22:58 2007
@@ -74,6 +74,10 @@
         ContinuumProjectBuildingResult result = (ContinuumProjectBuildingResult) context
             .get( CreateProjectsFromMetadataAction.KEY_PROJECT_BUILDING_RESULT );
 
+        if ( result.hasErrors() )
+        {
+            System.out.println( "Errors=" + result.getErrorsAsString() );
+        }
         assertFalse( "Should not have errors", result.hasErrors() );
     }
 

Modified: maven/continuum/trunk/continuum-model/src/main/mdo/continuum.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-model/src/main/mdo/continuum.xml?view=diff&rev=553552&r1=553551&r2=553552
==============================================================================
--- maven/continuum/trunk/continuum-model/src/main/mdo/continuum.xml (original)
+++ maven/continuum/trunk/continuum-model/src/main/mdo/continuum.xml Thu Jul  5 09:22:58 2007
@@ -471,6 +471,13 @@
           </association>
         </field>
         <field>
+          <name>buildDefinition</name>
+          <version>1.1.0+</version>
+          <association xml.reference="true" stash.part="true" jpox.dependent="false">
+            <type>BuildDefinition</type>
+          </association>
+        </field>
+        <field>
           <name>id</name>
           <version>1.0.9+</version>
           <type>int</type>
@@ -888,7 +895,7 @@
         </field>
         <field jpox.null-value="default">
           <name>latestBuildId</name>
-          <version>1.0.9+</version>
+          <version>1.0.9</version>
           <type>int</type>
           <defaultValue>0</defaultValue>
         </field>

Modified: maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java?view=diff&rev=553552&r1=553551&r2=553552
==============================================================================
--- maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
(original)
+++ maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
Thu Jul  5 09:22:58 2007
@@ -487,6 +487,47 @@
         return null;
     }
 
+    public BuildResult getLatestBuildResultForBuildDefinition( int projectId, int buildDefinitionId
)
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( BuildResult.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareParameters( "int projectId, int buildDefinitionId" );
+
+            query.setFilter( "this.project.id == projectId && this.buildDefinition.id
== buildDefinitionId" );
+            query.setOrdering( "id descending" );
+
+            Object[] params = new Object[2];
+            params[0] = new Integer( projectId );
+            params[1] = new Integer( buildDefinitionId );
+
+            List result = (List) query.executeWithArray( params );
+
+            result = (List) pm.detachCopyAll( result );
+
+            tx.commit();
+
+            if ( result != null && !result.isEmpty() )
+            {
+                return (BuildResult) result.get( 0 );
+            }
+        }
+        finally
+        {
+            rollback( tx );
+        }
+        return null;
+    }
+
     public Map getLatestBuildResultsByProjectGroupId( int projectGroupId )
     {
         PersistenceManager pm = getPersistenceManager();



Mime
View raw message