continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r771228 - in /continuum/branches/continuum-flat-multi-module: continuum-commons/src/main/java/org/apache/maven/continuum/utils/ continuum-commons/src/test/java/org/apache/maven/continuum/utils/ continuum-core/src/main/java/org/apache/maven/...
Date Mon, 04 May 2009 07:55:21 GMT
Author: oching
Date: Mon May  4 07:55:20 2009
New Revision: 771228

URL: http://svn.apache.org/viewvc?rev=771228&view=rev
Log:
[CONTINUUM-2193]
0 fix prepare build when building multi-module projects

Modified:
    continuum/branches/continuum-flat-multi-module/continuum-commons/src/main/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryService.java
    continuum/branches/continuum-flat-multi-module/continuum-commons/src/test/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryServiceTest.java
    continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
    continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java

Modified: continuum/branches/continuum-flat-multi-module/continuum-commons/src/main/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryService.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-commons/src/main/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryService.java?rev=771228&r1=771227&r2=771228&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-commons/src/main/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryService.java
(original)
+++ continuum/branches/continuum-flat-multi-module/continuum-commons/src/main/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryService.java
Mon May  4 07:55:20 2009
@@ -99,7 +99,14 @@
                     int indexDiff = StringUtils.differenceAt( projectScmUrl, projectScmRoot
);
                     
                     String pathToProject = projectScmUrl.substring( indexDiff );      
-                    project.setWorkingDirectory( Integer.toString( rootProject.getId() )
+ pathToProject );
+                    if( pathToProject.startsWith( "\\" ) || pathToProject.startsWith( "/"
) )
+                    {
+                        project.setWorkingDirectory( Integer.toString( rootProject.getId()
) + pathToProject );
+                    }
+                    else
+                    {
+                        project.setWorkingDirectory( Integer.toString( rootProject.getId()
) + "/" + pathToProject );
+                    }
                 }
             }
         }

Modified: continuum/branches/continuum-flat-multi-module/continuum-commons/src/test/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryServiceTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-commons/src/test/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryServiceTest.java?rev=771228&r1=771227&r2=771228&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-commons/src/test/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryServiceTest.java
(original)
+++ continuum/branches/continuum-flat-multi-module/continuum-commons/src/test/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryServiceTest.java
Mon May  4 07:55:20 2009
@@ -100,7 +100,7 @@
         context.checking( new Expectations()
         {
             {
-                one( configurationService ).getWorkingDirectory();
+                exactly( 2 ).of( configurationService ).getWorkingDirectory();
                 will( returnValue( unixBaseWorkingDirectory ) );
                 
                 one( configurationService ).getWorkingDirectory();
@@ -114,6 +114,15 @@
         
         assertEquals( "Incorrect working directory for multi-module project", "/target/working-directory/6/module-a",
                       projectWorkingDirectory.getPath() );
+        
+        // test if separator is appended at the end of the scm root url
+        projectWorkingDirectory =
+            workingDirectoryService.getWorkingDirectory( project, "scm:local:src/test-projects:flat-multi-module/",
+                                                         projects );
+        
+        assertEquals( "Incorrect working directory for multi-module project", "/target/working-directory/6/module-a",
+                      projectWorkingDirectory.getPath() );
+        
             
         project.setWorkingDirectory( null );
         
@@ -123,7 +132,7 @@
                                                          projects );
         
         assertEquals( "Incorrect working directory for multi-module project", "c:\\target\\working-directory\\6\\module-a",
-                      projectWorkingDirectory.getPath() );
+                      projectWorkingDirectory.getPath() );        
 
     }
     

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=771228&r1=771227&r2=771228&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Mon May  4 07:55:20 2009
@@ -23,7 +23,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -3355,9 +3354,27 @@
                 projectsAndBuildDefinitionsMap = new HashMap<Integer, Integer>();
             }
 
-            projectsAndBuildDefinitionsMap.put( projectId, buildDefId );
-
-            map.put( scmRoot, projectsAndBuildDefinitionsMap );
+            // TODO: deng - do we still need a projects and build definitions map?
+            //    consider migrated multi-module projects which were checked out in separate
directories!
+            //    how would they be affected by these changes?
+            Set<Integer> keys = projectsAndBuildDefinitionsMap.keySet();
+            if( keys != null && !keys.isEmpty() )
+            {                
+                for( Integer key : keys )
+                {
+                    if( key.intValue() > projectId )
+                    {
+                        projectsAndBuildDefinitionsMap.put( projectId, buildDefId );
+                        map.put( scmRoot, projectsAndBuildDefinitionsMap );
+                    }
+                } 
+            }
+            else
+            {
+                projectsAndBuildDefinitionsMap.put( projectId, buildDefId );
+                
+                map.put( scmRoot, projectsAndBuildDefinitionsMap );
+            }   
         }
 
         prepareBuildProjects( map, trigger );
@@ -3388,8 +3405,6 @@
 
                 ProjectScmRoot scmRoot = getProjectScmRootByProject( projectId );
 
-                // TODO: deng - do we still need a projectsAndBuildDefinitionsMap? All multi-module
projects
-                //    are now checked out in a single directory so once they are built
                 Map<Integer, Integer> projectsAndBuildDefinitionsMap = map.get( scmRoot
);
 
                 if ( projectsAndBuildDefinitionsMap == null )
@@ -3397,9 +3412,33 @@
                     projectsAndBuildDefinitionsMap = new HashMap<Integer, Integer>();
                 }
                 
-                projectsAndBuildDefinitionsMap.put( projectId, buildDefinitionId );     
          
+             // TODO: deng - do we still need a projects and build definitions map?
+                // All multi-module projects
+                //    are now checked out in a single directory so once they are built
+                //    consider migrated multi-module projects which were checked out in separate
directories!
+                //    how would they be affected by these changes?
+                Set<Integer> keys = projectsAndBuildDefinitionsMap.keySet();
+                if( keys != null && !keys.isEmpty() )
+                {                
+                    for( Integer key : keys )
+                    {
+                        if( key.intValue() > projectId )
+                        {
+                            projectsAndBuildDefinitionsMap.put( projectId, buildDefinitionId
);
+                            map.put( scmRoot, projectsAndBuildDefinitionsMap );
+                        }
+                    } 
+                }
+                else
+                {
+                    projectsAndBuildDefinitionsMap.put( projectId, buildDefinitionId );
+                    
+                    map.put( scmRoot, projectsAndBuildDefinitionsMap );
+                }   
+                
+                /*projectsAndBuildDefinitionsMap.put( projectId, buildDefinitionId );   
            
 
-                map.put( scmRoot, projectsAndBuildDefinitionsMap );
+                map.put( scmRoot, projectsAndBuildDefinitionsMap );*/
             }
             catch ( BuildManagerException e )
             {

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java?rev=771228&r1=771227&r2=771228&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
(original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
Mon May  4 07:55:20 2009
@@ -120,7 +120,8 @@
             File workingDirectory =
                 workingDirectoryService.getWorkingDirectory( project, projectScmRoot.getScmRootAddress(),
                                                              projectsWithSimilarScmRoot );
-            ContinuumScmConfiguration config = createScmConfiguration( project, workingDirectory
);
+            
+            ContinuumScmConfiguration config = createScmConfiguration( project, workingDirectory,
projectScmRoot.getScmRootAddress() );
             config.setLatestUpdateDate( latestUpdateDate );
             String tag = config.getTag();
             String msg = project.getName() + "', id: '" + project.getId() + "' to '" +
@@ -200,10 +201,17 @@
         context.put( KEY_PROJECT, project );
     }
 
-    private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory
)
+    private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory,
String scmRootUrl )
     {
         ContinuumScmConfiguration config = new ContinuumScmConfiguration();
-        config.setUrl( project.getScmUrl() );
+        if( scmRootUrl != null && !"".equals( scmRootUrl ) )
+        {
+            config.setUrl( scmRootUrl );
+        }
+        else
+        {
+            config.setUrl( project.getScmUrl() );
+        }
         config.setUsername( project.getScmUsername() );
         config.setPassword( project.getScmPassword() );
         config.setUseCredentialsCache( project.isScmUseCache() );

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java?rev=771228&r1=771227&r2=771228&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
(original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
Mon May  4 07:55:20 2009
@@ -28,6 +28,7 @@
 import org.apache.continuum.dao.BuildDefinitionDao;
 import org.apache.continuum.dao.BuildResultDao;
 import org.apache.continuum.dao.ProjectDao;
+import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.continuum.dao.ProjectScmRootDao;
 import org.apache.continuum.model.project.ProjectScmRoot;
 import org.apache.continuum.taskqueue.PrepareBuildProjectsTask;
@@ -99,6 +100,11 @@
      * @plexus.requirement
      */
     private ContinuumNotificationDispatcher notifierDispatcher;
+    
+    /**
+     * @plexus.requirement
+     */
+    private ProjectGroupDao projectGroupDao;
 
     public void executeTask( Task task )
         throws TaskExecutionException
@@ -209,7 +215,8 @@
 
           //TODO: deng - put all projects in group with the same scm root in the context!

             //  this, together with the project scm root, will be used to determine the working
dir            
-            List<Project> projectsInGroup = projectGroup.getProjects();
+            List<Project> projectsInGroup =
+                projectGroupDao.getProjectGroupWithProjects( projectGroup.getId() ).getProjects();

             List<Project> projectsWithCommonScmRoot = new ArrayList<Project>();
           
             for( Project projectInGroup : projectsInGroup )
             {



Mime
View raw message