continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r985992 - in /continuum/trunk: continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/ continuum-core/src/test/java/org/apache/maven/continuum/ continuum-core/s...
Date Mon, 16 Aug 2010 15:29:13 GMT
Author: oching
Date: Mon Aug 16 15:29:12 2010
New Revision: 985992

URL: http://svn.apache.org/viewvc?rev=985992&view=rev
Log:
[CONTINUUM-2563]
o add a default project level build definition with '--non-recursive' flag stripped if adding
a multi-module project as a single Continuum project
  to an existing project group
o added test + docs

Modified:
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
    continuum/trunk/continuum-docs/src/site/apt/user_guides/managing_project/addProject.apt

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=985992&r1=985991&r2=985992&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Mon Aug 16 15:29:12 2010
@@ -101,7 +101,6 @@ import org.springframework.beans.BeanUti
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -110,7 +109,6 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.Properties;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -1756,8 +1754,12 @@ public class DefaultContinuum
                 for ( Project project : projects )
                 {
                 	context = new HashMap<String, Object>();
+
+                    Project fetchedProject = projectDao.getProjectWithBuildDetails( project.getId()
);
+
             	    addProjectToCheckoutQueue( projectBuilderId, buildDefinitionTemplateId,
context,
-            				                                               projectGroupCreation, scmUserName,
scmPassword, project );    
+            				                                               projectGroupCreation, scmUserName,
scmPassword, project,
+                                                                           isDefaultProjectBuildDefSet(
fetchedProject ) );
                 }
             }
             else
@@ -1778,9 +1780,11 @@ public class DefaultContinuum
                     }
 
                     AbstractContinuumAction.setListOfProjectsInGroupWithCommonScmRoot( context,
projectsWithSimilarScmRoot );
-                    
+
+                    Project fetchedProject = projectDao.getProjectWithBuildDetails( project.getId()
);
+
                     addProjectToCheckoutQueue( projectBuilderId, buildDefinitionTemplateId,
context, projectGroupCreation,
-                                               scmUserName, scmPassword, project );    
+                                               scmUserName, scmPassword, project, isDefaultProjectBuildDefSet(
fetchedProject ) );
                 }
             }
         }
@@ -1801,15 +1805,29 @@ public class DefaultContinuum
         }
         return result;
     }
-    
+
+    private boolean isDefaultProjectBuildDefSet( Project project )
+    {
+        for ( BuildDefinition bd : project.getBuildDefinitions() )
+        {
+            if ( bd.isDefaultForProject() )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     private void addProjectToCheckoutQueue( String projectBuilderId, int buildDefinitionTemplateId,
                                             Map<String, Object> context, boolean projectGroupCreation,
-                                            String scmUserName, String scmPassword, Project
project )
+                                            String scmUserName, String scmPassword, Project
project,
+                                            boolean defaultProjectBuildDefSet )
         throws BuildDefinitionServiceException, ContinuumStoreException, ContinuumException
     {
         // CONTINUUM-1953 olamy : attached buildDefs from template here
         // if no group creation
-        if ( !projectGroupCreation && buildDefinitionTemplateId > 0 )
+        if ( !projectGroupCreation && buildDefinitionTemplateId > 0 &&
!defaultProjectBuildDefSet )
         {
             buildDefinitionService.addTemplateInProject( buildDefinitionTemplateId,
                                                          projectDao.getProject( project.getId()
) );

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java?rev=985992&r1=985991&r2=985992&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
Mon Aug 16 15:29:12 2010
@@ -171,9 +171,11 @@ public class MavenTwoContinuumProjectBui
             }
         }
         log.debug( "groupPom " + groupPom );
+
+        ProjectGroup projectGroup = null;
         if ( groupPom )
         {
-            ProjectGroup projectGroup = buildProjectGroup( mavenProject, result );
+            projectGroup = buildProjectGroup( mavenProject, result );
 
             // project groups have the top lvl build definition which is the default build
defintion for the sub
             // projects
@@ -269,9 +271,41 @@ public class MavenTwoContinuumProjectBui
             {
                 continuumProject.setScmTag( mavenProject.getScm().getTag() );
             }
+
+            // CONTINUUM-2563
+            if ( !loadRecursiveProjects )
+            {
+                // should only contain 1 project group
+                ProjectGroup pg = result.getProjectGroups().iterator().next();
+                if ( pg.equals( projectGroup ) )
+                {
+                    List<BuildDefinition> pgBuildDefs = pg.getBuildDefinitions();
+                    for ( BuildDefinition bD : pgBuildDefs )
+                    {
+                        if ( bD.isDefaultForProject() )
+                        {
+                            // create a default build definition at the project
+                            // level
+                            BuildDefinition projectBuildDef = buildDefinitionService.cloneBuildDefinition(
bD );
+                            projectBuildDef.setDefaultForProject( true );
+
+                            String arguments = projectBuildDef.getArguments().replace( "--non-recursive",
"" );
+                            arguments = arguments.replace( "-N", "" );
+                            projectBuildDef.setArguments( arguments );
+
+                            log.info( "Adding default build definition for project '" + continuumProject.getName()
+                                + "' without '--non-recursive' flag." );
+
+                            continuumProject.addBuildDefinition( projectBuildDef );
+
+                            break;
+                        }
+                    }
+                }
+            }
+
             result.addProject( continuumProject, MavenTwoBuildExecutor.ID );
-            
-                        
+
 	        if( checkoutInSingleDirectory && rootProject == null )
 	        {
 	            rootProject = continuumProject;

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java?rev=985992&r1=985991&r2=985992&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
(original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
Mon Aug 16 15:29:12 2010
@@ -212,7 +212,7 @@ public class AddMaven2ProjectTest
         assertNotNull( project );
         pg = getContinuum().getProjectGroupWithBuildDetails( pg.getId() );
         log.info( "project buildDef list size : " + project.getBuildDefinitions().size()
);
-        assertEquals( 0, project.getBuildDefinitions().size() );
+        assertEquals( 1, project.getBuildDefinitions().size() );
         pg = result.getProjectGroups().get( 0 );
 
         pg = getContinuum().getProjectGroupWithBuildDetails( pg.getId() );

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java?rev=985992&r1=985991&r2=985992&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
(original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
Mon Aug 16 15:29:12 2010
@@ -345,8 +345,10 @@ public class DefaultContinuumTest
 
         assertTrue( "project group build definition is not default", pgbd.isDefaultForProject()
);
 
-        assertTrue( "project group build definition not default for project",
-                    continuum.getDefaultBuildDefinition( project.getId() ).getId() == pgbd.getId()
);
+        // project was added as a single project (loadRecursiveProjects == false) so project
should not
+        //   get the PG's build def which has '--non-recursive' flag set in its argument
+        assertTrue( "project group build definition should not be the default for project",
+                    continuum.getDefaultBuildDefinition( project.getId() ).getId() != pgbd.getId()
);
 
         BuildDefinition nbd = new BuildDefinition();
         nbd.setGoals( "clean" );

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java?rev=985992&r1=985991&r2=985992&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
(original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
Mon Aug 16 15:29:12 2010
@@ -435,6 +435,67 @@ public class MavenTwoContinuumProjectBui
 	    }
 	}
 
+    // CONTINUUM-2563
+    public void testCreateMultiModuleProjectLoadRecursiveProjectsIsFalse()
+        throws Exception
+    {
+        ContinuumProjectBuilder projectBuilder =
+            (ContinuumProjectBuilder) lookup( ContinuumProjectBuilder.ROLE, MavenTwoContinuumProjectBuilder.ID
);
+
+        URL url = getClass().getClassLoader().getResource( "projects/continuum/pom.xml" );
+
+        ContinuumProjectBuildingResult result =
+            projectBuilder.buildProjectsFromMetadata( url, null, null, false, false );
+
+        assertNotNull( result );
+
+        // ----------------------------------------------------------------------
+        // Assert the project group built
+        // ----------------------------------------------------------------------
+
+        assertNotNull( result.getProjectGroups() );
+
+        assertEquals( 1, result.getProjectGroups().size() );
+
+        ProjectGroup projectGroup = result.getProjectGroups().iterator().next();
+
+        assertEquals( "projectGroup.groupId", "org.apache.maven.continuum", projectGroup.getGroupId()
);
+
+        assertEquals( "projectGroup.name", "Continuum Parent Project", projectGroup.getName()
);
+
+        assertEquals( "projectGroup.description", "Continuum Project Description", projectGroup.getDescription()
);
+
+        // ----------------------------------------------------------------------
+        // Assert the projects built
+        // ----------------------------------------------------------------------
+
+        assertNotNull( result.getProjects() );
+
+        assertEquals( 1, result.getProjects().size() );
+
+        Map<String, Project> projects = new HashMap<String, Project>();
+
+        Project project = result.getProjects().iterator().next();
+        assertNotNull( project.getName() );
+        assertNotNull( project.getDescription() );
+        projects.put( project.getName(), project );
+
+        assertMavenTwoProject( "Continuum Parent Project", projects );
+
+        // assert the default project build definition
+        List<BuildDefinition> buildDefs = project.getBuildDefinitions();
+        assertEquals( 1, buildDefs.size() );
+        for ( BuildDefinition buildDef : buildDefs )
+        {
+            if ( buildDef.isDefaultForProject() )
+            {
+                assertEquals( "--batch-mode ", buildDef.getArguments() );
+                assertEquals( "clean install", buildDef.getGoals() );
+                assertEquals( "pom.xml", buildDef.getBuildFile() );
+            }
+        }
+    }
+
     private void assertDependency( String dep, String proj, Map<String, Project> projects
)
     {
         Project p = projects.get( proj );

Modified: continuum/trunk/continuum-docs/src/site/apt/user_guides/managing_project/addProject.apt
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-docs/src/site/apt/user_guides/managing_project/addProject.apt?rev=985992&r1=985991&r2=985992&view=diff
==============================================================================
--- continuum/trunk/continuum-docs/src/site/apt/user_guides/managing_project/addProject.apt
(original)
+++ continuum/trunk/continuum-docs/src/site/apt/user_guides/managing_project/addProject.apt
Mon Aug 16 15:29:12 2010
@@ -137,7 +137,14 @@ simple-flat-multi-module
            `-- ...
 +----------------------------+
 
-  If you want to add only the root POM without sub-modules, select the <<load only
root as recursive build>> radio box. 
+  If you want to add the multi-module project as a single Continuum project, select the <<load
only root as recursive build>>
+  radio box.
+
+  For a project or POM that was added as a single Continuum project and as it's own project
group, the <<<--non-recursive>>>
+  flag in the default project group build definition will be removed. But if the project
or POM was added as a single
+  Continuum project to an already existing project group, a project level build definition
with the <<<--non-recursive>>> flag
+  stripped from the <<<arguments>>> field will be created for the project
and will be set as the project's default build definition.
+  See {{{http://jira.codehaus.org/browse/CONTINUUM-2563} CONTINUUM-2563}} for the related
issue.
 
   You can choose a <<Build Definition Template>> which will be applied to your
project.  If you choose a <<Build Definition
   Template>>, the build definitions from the template will be added in addition to
any build definitions that are defined



Mime
View raw message