continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r475310 - in /maven/continuum/trunk: continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/ continuum-core/src/main/java/org/apache/maven/continuum/core/action/ continuum-core/src/test/java/org/apache/maven/continuum/build...
Date Wed, 15 Nov 2006 17:10:56 GMT
Author: evenisse
Date: Wed Nov 15 09:10:55 2006
New Revision: 475310

URL: http://svn.apache.org/viewvc?view=rev&rev=475310
Log:
[CONTINUUM-232] Build when a dependency has been changed

Modified:
    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/AbstractContinuumAction.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-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
    maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp

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=475310&r1=475309&r2=475310
==============================================================================
--- 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 Nov 15 09:10:55 2006
@@ -223,6 +223,7 @@
         }
         else
         {
+            updateBuildResult( build, context );
 
             build.setError( error );
 
@@ -250,6 +251,29 @@
         }
     }
 
+    private void updateBuildResult( BuildResult build, BuildContext context )
+    {
+        if ( build.getScmResult() == null && context.getScmResult() != null )
+        {
+            build.setScmResult( context.getScmResult() );
+        }
+
+        if ( build.getModifiedDependencies() == null && context.getModifiedDependencies()
!= null )
+        {
+            List dependencies = context.getModifiedDependencies();
+            if ( dependencies != null && !dependencies.isEmpty() )
+            {
+                List modifiedDependencies = new ArrayList();
+                for ( Iterator i = dependencies.iterator(); i.hasNext(); )
+                {
+                    ProjectDependency dep = (ProjectDependency) i.next();
+                    modifiedDependencies.add( dep.getGroupId() + ":" + dep.getArtifactId()
+ ":" + dep.getVersion() );
+                }
+                build.setModifiedDependencies( modifiedDependencies );
+            }
+        }
+    }
+
     private void startBuild( BuildContext context )
         throws TaskExecutionException
     {
@@ -299,18 +323,13 @@
 
             context.setBuildDefinition( buildDefinition );
 
-            try
-            {
-                BuildResult oldBuildResult = store.getBuildResult( buildDefinition.getLatestBuildId()
);
+            BuildResult oldBuildResult = store.getLatestBuildResultForProject( projectId
);
 
-                context.setOldBuildResult( oldBuildResult );
+            context.setOldBuildResult( oldBuildResult );
 
-                context.setOldScmResult( getOldScmResult( projectId, oldBuildResult.getEndTime()
) );
-
-            }
-            catch ( ContinuumObjectNotFoundException ex )
+            if ( oldBuildResult != null )
             {
-                // Nothing to do
+                context.setOldScmResult( getOldScmResult( projectId, oldBuildResult.getEndTime()
) );
             }
         }
         catch ( ContinuumStoreException e )
@@ -439,54 +458,53 @@
 
         Project project = context.getProject();
 
-        // Check SCM changes
-        boolean allChangesUnknown = checkAllChangesUnknown( context.getScmResult().getChanges()
);
-
-        if ( allChangesUnknown && project.getOldState() != ContinuumProjectState.NEW
&&
+        if ( project.getOldState() != ContinuumProjectState.NEW &&
             project.getOldState() != ContinuumProjectState.CHECKEDOUT &&
             context.getTrigger() != ContinuumProjectState.TRIGGER_FORCED &&
             project.getState() != ContinuumProjectState.NEW && project.getState()
!= ContinuumProjectState.CHECKEDOUT )
         {
-            if ( !context.getScmResult().getChanges().isEmpty() )
-            {
-                getLogger().info( "The project was not built because all changes are unknown."
);
-            }
-            else
+            // Check SCM changes
+            boolean allChangesUnknown = checkAllChangesUnknown( context.getScmResult().getChanges()
);
+
+            if ( allChangesUnknown )
             {
-                getLogger().info( "The project was not built because there are no changes."
);
-            }
+                if ( !context.getScmResult().getChanges().isEmpty() )
+                {
+                    getLogger().info( "The project was not built because all changes are
unknown." );
+                }
+                else
+                {
+                    getLogger().info( "The project was not built because there are no changes."
);
+                }
 
-            project.setState( project.getOldState() );
+                project.setState( project.getOldState() );
 
-            project.setOldState( 0 );
+                project.setOldState( 0 );
 
-            try
-            {
-                store.updateProject( project );
-            }
-            catch ( ContinuumStoreException e )
-            {
-                throw new TaskExecutionException( "Error storing project", e );
-            }
+                try
+                {
+                    store.updateProject( project );
+                }
+                catch ( ContinuumStoreException e )
+                {
+                    throw new TaskExecutionException( "Error storing project", e );
+                }
 
-            shouldBuild = false;
+                shouldBuild = false;
 
-            // Check dependencies changes
-            if ( context.getModifiedDependencies() != null && !context.getModifiedDependencies().isEmpty()
)
-            {
-                shouldBuild = true;
-            }
-        }
-        else
-        {
-            // Check dependencies changes
-            if ( context.getModifiedDependencies() != null && !context.getModifiedDependencies().isEmpty()
)
-            {
-                shouldBuild = true;
+                // Check dependencies changes
+                if ( context.getModifiedDependencies() != null && !context.getModifiedDependencies().isEmpty()
)
+                {
+                    shouldBuild = true;
+                }
             }
             else
             {
-                shouldBuild = false;
+                // Check dependencies changes
+                if ( context.getModifiedDependencies() != null && !context.getModifiedDependencies().isEmpty()
)
+                {
+                    shouldBuild = true;
+                }
             }
         }
 
@@ -531,8 +549,19 @@
 
             if ( dependencies == null )
             {
+                dependencies = new ArrayList();
+            }
+
+            if ( project.getParent() != null )
+            {
+                dependencies.add( project.getParent() );
+            }
+
+            if ( dependencies.isEmpty() )
+            {
                 return;
             }
+
             List modifiedDependencies = new ArrayList();
 
             for ( Iterator i = dependencies.iterator(); i.hasNext(); )
@@ -550,6 +579,11 @@
                             dep.getVersion() );
                         modifiedDependencies.add( dep );
                     }
+                    else
+                    {
+                        getLogger().debug( "Dependency not changed: " + dep.getGroupId()
+ ":" + dep.getArtifactId() +
+                            ":" + dep.getVersion() );
+                    }
                 }
                 else
                 {
@@ -559,6 +593,7 @@
             }
 
             context.setModifiedDependencies( modifiedDependencies );
+            context.getActionContext().put( AbstractContinuumAction.KEY_UPDATE_DEPENDENCIES,
modifiedDependencies );
         }
         catch ( ContinuumStoreException e )
         {
@@ -628,19 +663,9 @@
 
         build.setEndTime( System.currentTimeMillis() );
 
-        build.setScmResult( context.getScmResult() );
+        updateBuildResult( build, context );
 
-        List dependencies = context.getModifiedDependencies();
-        if ( dependencies != null && !dependencies.isEmpty() )
-        {
-            List modifiedDependencies = new ArrayList();
-            for ( Iterator i = dependencies.iterator(); i.hasNext(); )
-            {
-                ProjectDependency dep = (ProjectDependency) i.next();
-                modifiedDependencies.add( dep.getGroupId() + ":" + dep.getArtifactId() +
":" + dep.getVersion() );
-            }
-            build.setModifiedDependencies( modifiedDependencies );
-        }
+        build.setScmResult( context.getScmResult() );
 
         if ( error != null )
         {

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java?view=diff&rev=475310&r1=475309&r2=475310
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
Wed Nov 15 09:10:55 2006
@@ -24,6 +24,7 @@
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -61,6 +62,8 @@
 
     public static final String KEY_UPDATE_SCM_RESULT = "update-result";
 
+    public static final String KEY_UPDATE_DEPENDENCIES = "update-dependencies";
+
     public static final String KEY_TRIGGER = "trigger";
 
     public static final String KEY_FIRST_RUN = "first-run";
@@ -146,6 +149,16 @@
     public static ScmResult getUpdateScmResult( Map context, ScmResult defaultValue )
     {
         return (ScmResult) getObject( context, KEY_UPDATE_SCM_RESULT, defaultValue );
+    }
+
+    public static List getUpdatedDependencies( Map context )
+    {
+        return (List) getObject( context, KEY_UPDATE_DEPENDENCIES );
+    }
+
+    public static List getUpdatedDependencies( Map context, List defaultValue )
+    {
+        return (List) getObject( context, KEY_UPDATE_DEPENDENCIES, defaultValue );
     }
 
     // ----------------------------------------------------------------------

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=475310&r1=475309&r2=475310
==============================================================================
--- 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 Nov 15 09:10:55 2006
@@ -32,6 +32,7 @@
 
 import java.io.File;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -80,6 +81,10 @@
 
         ScmResult scmResult = getUpdateScmResult( context );
 
+        List updatedDependencies = getUpdatedDependencies( context );
+
+        boolean hasUpdatedDependencies = updatedDependencies != null && !updatedDependencies.isEmpty();
+
         boolean isFirstRun = ( (Boolean) context.get( AbstractContinuumAction.KEY_FIRST_RUN
) ).booleanValue();
 
         ContinuumBuildExecutor buildExecutor = buildExecutorManager.getBuildExecutor( project.getExecutorId()
);
@@ -89,7 +94,8 @@
         // ----------------------------------------------------------------------
 
         if ( !isFirstRun && project.getOldState() != ContinuumProjectState.NEW &&
-            project.getOldState() != ContinuumProjectState.CHECKEDOUT && scmResult.getChanges().size()
== 0 &&
+            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()
+ "'." );
@@ -170,17 +176,20 @@
             // Set the test result
             // ----------------------------------------------------------------------
 
-             try {
-                 TestResult testResult = buildExecutor.getTestResults( project );
-                 build.setTestResult(testResult);
-            } catch (Throwable t) {
-                getLogger().error("Error getting test results", t);
+            try
+            {
+                TestResult testResult = buildExecutor.getTestResults( project );
+                build.setTestResult( testResult );
+            }
+            catch ( Throwable t )
+            {
+                getLogger().error( "Error getting test results", t );
             }
 
             // ----------------------------------------------------------------------
             // Copy over the build result
             // ----------------------------------------------------------------------
-                                                          
+
             store.updateBuildResult( build );
 
             build = store.getBuildResult( build.getId() );

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=475310&r1=475309&r2=475310
==============================================================================
--- 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
Wed Nov 15 09:10:55 2006
@@ -47,18 +47,21 @@
         Project project1 = createProject( "project1" );
         BuildDefinition bd1 = createBuildDefinition();
         project1.addBuildDefinition( bd1 );
+        project1.setState( ContinuumProjectState.OK );
         projectId1 = addProject( getStore(), project1 ).getId();
         buildDefinitionId1 = getStore().getDefaultBuildDefinition( projectId1 ).getId();
         project1 = getStore().getProject( projectId1 );
         BuildResult buildResult1 = new BuildResult();
         buildResult1.setStartTime( Calendar.getInstance().getTimeInMillis() );
         buildResult1.setEndTime( Calendar.getInstance().getTimeInMillis() );
+        buildResult1.setState( ContinuumProjectState.OK);
         buildResult1.setSuccess( true );
         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);
         getStore().addBuildResult( project1, buildResult2 );
 
         Project project2 = createProject( "project2" );
@@ -74,6 +77,7 @@
         project2.addDependency( dep2 );
         BuildDefinition bd2 = createBuildDefinition();
         project2.addBuildDefinition( bd2 );
+        project2.setState( ContinuumProjectState.OK );
         projectId2 = addProject( getStore(), project2 ).getId();
         buildDefinitionId2 = getStore().getDefaultBuildDefinition( projectId2 ).getId();
 
@@ -119,6 +123,23 @@
         controller.checkProjectDependencies( context );
         assertEquals( 0, context.getModifiedDependencies().size() );
         assertFalse( controller.shouldBuild( context ) );
+    }
+
+    public void testWithNewProjects()
+        throws Exception
+    {
+        Project p1 = getStore().getProject( projectId1 );
+        p1.setState( ContinuumProjectState.NEW );
+        getStore().updateProject( p1 );
+
+        Project p2 = getStore().getProject( projectId2 );
+        p2.setState( ContinuumProjectState.NEW );
+        getStore().updateProject( p2 );
+
+        BuildContext context = getContext( +1 );
+        controller.checkProjectDependencies( context );
+        assertEquals( 0, context.getModifiedDependencies().size() );
+        assertTrue( controller.shouldBuild( context ) );
     }
 
     public void testWithDependencyChanges()

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=475310&r1=475309&r2=475310
==============================================================================
--- 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
Wed Nov 15 09:10:55 2006
@@ -29,6 +29,7 @@
 import org.apache.maven.continuum.model.system.Permission;
 import org.apache.maven.continuum.model.system.SystemConfiguration;
 import org.apache.maven.continuum.model.system.UserGroup;
+import org.apache.maven.continuum.project.ContinuumProjectState;
 import org.codehaus.plexus.jdo.JdoFactory;
 import org.codehaus.plexus.jdo.PlexusJdoUtils;
 import org.codehaus.plexus.jdo.PlexusObjectNotFoundException;
@@ -1008,7 +1009,7 @@
             for ( Iterator i = buildResults.iterator(); i.hasNext(); )
             {
                 BuildResult res = (BuildResult) i.next();
-                if ( res.isSuccess() )
+                if ( res.getState() == ContinuumProjectState.OK )
                 {
                     results.add( res );
                 }

Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties?view=diff&rev=475310&r1=475309&r2=475310
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
Wed Nov 15 09:10:55 2006
@@ -334,12 +334,15 @@
 buildResult.buildError = Build Error
 buildResult.buildOutput = Output
 buildResult.noOutput = No output.
-buildResult.changes = Changes
-buildResult.noChanges = No changes
-buildResult.changes.author = Author
-buildResult.changes.date = Date
-buildResult.changes.comment = Comment
-buildResult.changes.files = Files
+buildResult.scmResult.changes = SCM Changes
+buildResult.scmResult.noChanges = No SCM changes
+buildResult.scmResult.changes.author = Author
+buildResult.scmResult.changes.date = Date
+buildResult.scmResult.changes.comment = Comment
+buildResult.scmResult.changes.files = Files
+buildResult.dependencies.changes = Dependencies Changes
+buildResult.dependencies.noChanges = No dependencies changes
+buildResult.dependencies.title = Dependencies
 buildResult.changesSinceLastSuccess = Other Changes Since Last Success
 buildResult.generatedReports.title = Generated Reports
 buildResult.generatedReports.surefire = Surefire Report

Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp?view=diff&rev=475310&r1=475309&r2=475310
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp Wed
Nov 15 09:10:55 2006
@@ -45,7 +45,7 @@
           </table>
         </div>
 
-        <h4><ww:text name="buildResult.changes"/></h4>
+        <h4><ww:text name="buildResult.scmResult.changes"/></h4>
         <ww:if test="buildResult.scmResult.changes != null && buildResult.scmResult.changes.size()
> 0">
             <ww:set name="changes" value="buildResult.scmResult.changes" scope="request"/>
             <ec:table items="changes"
@@ -56,10 +56,10 @@
                       sortable="false"
                       filterable="false">
               <ec:row>
-                <ec:column property="author" title="buildResult.changes.author"/>
-                <ec:column property="date" title="buildResult.changes.date" cell="date"/>
-                <ec:column property="comment" title="buildResult.changes.comment" />
-                <ec:column property="files" title="buildResult.changes.files">
+                <ec:column property="author" title="buildResult.scmResult.changes.author"/>
+                <ec:column property="date" title="buildResult.scmResult.changes.date"
cell="date"/>
+                <ec:column property="comment" title="buildResult.scmResult.changes.comment"
/>
+                <ec:column property="files" title="buildResult.scmResult.changes.files">
                     <c:forEach var="scmFile" items="${pageScope.change.files}">
                         <c:out value="${scmFile.name}"/><br />
                     </c:forEach>
@@ -68,7 +68,29 @@
             </ec:table>
         </ww:if>
         <ww:else>
-          <b><ww:text name="buildResult.noChanges"/></b>
+          <b><ww:text name="buildResult.scmResult.noChanges"/></b>
+        </ww:else>
+
+        <h4><ww:text name="buildResult.dependencies.changes"/></h4>
+        <ww:if test="buildResult.modifiedDependencies != null && buildResult.modifiedDependencies.size()
> 0">
+            aaa
+            <ww:set name="changes" value="buildResult.modifiedDependencies" scope="request"/>
+            <ec:table items="changes"
+                      var="change"
+                      showExports="false"
+                      showPagination="false"
+                      showStatusBar="false"
+                      sortable="false"
+                      filterable="false">
+              <ec:row>
+                <ec:column property="dependency" title="buildResult.dependencies.title">
+                  <c:out value="${pageScope.change}"/><br />
+                </ec:column>
+              </ec:row>
+            </ec:table>
+        </ww:if>
+        <ww:else>
+          <b><ww:text name="buildResult.dependencies.noChanges"/>${buildResult.modifiedDependencies}</b>
         </ww:else>
 
         <ww:if test="hasSurefireResults">



Mime
View raw message