continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r726239 - in /continuum/branches/continuum-1.2.x: continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/java/org/apache/maven/continuum/core/...
Date Sat, 13 Dec 2008 17:34:07 GMT
Author: olamy
Date: Sat Dec 13 09:34:07 2008
New Revision: 726239

URL: http://svn.apache.org/viewvc?rev=726239&view=rev
Log:
[CONTINUUM-1953]  Build definitions not linked when creating a new project with a given build
defintion template in an existing project group


Added:
    continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
  (with props)
Modified:
    continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java
    continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
    continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
    continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/projects/continuum/continuum-core/pom.xml

Modified: continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java?rev=726239&r1=726238&r2=726239&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java
Sat Dec 13 09:34:07 2008
@@ -115,7 +115,7 @@
 
     public List<BuildDefinitionTemplate> getBuildDefinitionTemplatesWithType( String
type )
         throws BuildDefinitionServiceException;
-
+    
     public ProjectGroup addBuildDefinitionTemplateToProjectGroup( int projectGroupId,
                                                                   BuildDefinitionTemplate
buildDefinitionTemplate )
         throws BuildDefinitionServiceException, ContinuumObjectNotFoundException;

Modified: continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=726239&r1=726238&r2=726239&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Sat Dec 13 09:34:07 2008
@@ -1877,6 +1877,8 @@
 
         ProjectGroup projectGroup = (ProjectGroup) result.getProjectGroups().iterator().next();
 
+        boolean projectGroupCreation = false;
+        
         try
         {
             if ( projectGroupId == -1 )
@@ -1906,6 +1908,8 @@
                     executeAction( "store-project-group", pgContext );
 
                     projectGroupId = AbstractContinuumAction.getProjectGroupId( pgContext
);
+                    
+                    projectGroupCreation = true;
                 }
             }
 
@@ -1955,6 +1959,14 @@
             {
                 context = new HashMap();
 
+                // CONTINUUM-1953 olamy : attached buildDefs from template here
+                // if no group creation 
+                if ( !projectGroupCreation && buildDefintionTemplateId > 0 )
+                {
+                    buildDefinitionService.addTemplateInProject( buildDefintionTemplateId,
projectDao
+                        .getProject( project.getId() ) );
+                }                
+                
                 context.put( AbstractContinuumAction.KEY_UNVALIDATED_PROJECT, project );
                 //
                 //            executeAction( "validate-project", context );
@@ -1980,6 +1992,10 @@
                 executeAction( "add-project-to-checkout-queue", context );
             }
         }
+        catch ( BuildDefinitionServiceException e )
+        {
+            throw new ContinuumException( "Error attaching buildDefintionTemplate to project
", e );
+        }
         catch ( ContinuumStoreException e )
         {
             throw new ContinuumException( "Error adding projects from modules", e );

Modified: continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java?rev=726239&r1=726238&r2=726239&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
Sat Dec 13 09:34:07 2008
@@ -98,11 +98,18 @@
 
         try
         {
+            BuildDefinitionTemplate buildDefinitionTemplate = getBuildDefinitionTemplate(
context );
+            if ( buildDefinitionTemplate == null )
+            {
+                buildDefinitionTemplate = projectBuilder.getDefaultBuildDefinitionTemplate();
+            }            
             if ( !curl.startsWith( "http" ) )
             {
                 url = new URL( curl );
 
-                result = projectBuilder.buildProjectsFromMetadata( url, null, null );
+                result = projectBuilder.buildProjectsFromMetadata( url, null, null, loadRecursiveProjects,
+                                                                   buildDefinitionTemplate
);
+
             }
             else
             {
@@ -138,11 +145,7 @@
 
                 if ( urlValidator.isValid( curl ) )
                 {
-                    BuildDefinitionTemplate buildDefinitionTemplate = getBuildDefinitionTemplate(
context );
-                    if ( buildDefinitionTemplate == null )
-                    {
-                        buildDefinitionTemplate = projectBuilder.getDefaultBuildDefinitionTemplate();
-                    }
+
                     result = projectBuilder.buildProjectsFromMetadata( url, username, password,
loadRecursiveProjects,
                                                                        buildDefinitionTemplate
);
 

Added: continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java?rev=726239&view=auto
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
(added)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
Sat Dec 13 09:34:07 2008
@@ -0,0 +1,230 @@
+package org.apache.maven.continuum;
+
+import java.io.File;
+
+import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * @author olamy
+ * @since 
+ * @version $Id$
+ */
+public class AddMaven2ProjectTest
+    extends AbstractContinuumTest
+{
+    protected Logger log = LoggerFactory.getLogger( getClass() );
+
+    protected BuildDefinitionTemplate bdt;
+
+    protected BuildDefinition bd;
+    
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        bd = new BuildDefinition();
+        bd.setGoals( "clean deploy" );
+        bd.setBuildFile( "pom.xml" );
+        bd.setDescription( "my foo" );
+        bd.setTemplate( true );
+        BuildDefinitionService bds = (BuildDefinitionService) lookup( BuildDefinitionService.class.getName(),
"default" );
+        bd = bds.addBuildDefinition( bd );
+        
+        
+        assertEquals( 5, bds.getAllBuildDefinitions().size() );
+
+        bdt = new BuildDefinitionTemplate();
+        bdt.setName( "bdt foo" );
+        
+        bdt = bds.addBuildDefinitionTemplate( bdt );
+        
+        bdt = bds.addBuildDefinitionInTemplate( bdt, bd, false );        
+    }    
+    
+    
+    
+    public void testAddProjectWithBuildDefTemplateToExistingGroup()
+        throws Exception
+    {
+
+        ProjectGroup pg = new ProjectGroup();
+        pg.setName( "foo" );
+        pg.setDescription( "foo pg" );
+        getContinuum().addProjectGroup( pg );
+        pg = getContinuum().getAllProjectGroups().get( 1 );
+        assertEquals( 2, getContinuum().getAllProjectGroups().size() );
+
+        File rootPom = getTestFile( "src/test/resources/projects/continuum/continuum-core/pom.xml"
);
+
+        assertTrue( rootPom.exists() );
+        //String url = getTestFile( "src/test-projects/project1/pom.xml" ).toURL().toExternalForm();
+        ContinuumProjectBuildingResult result = getContinuum().addMavenTwoProject(
+                                                                                   rootPom.toURI().toURL()
+                                                                                       .toExternalForm(),
pg.getId(),
+                                                                                   true,
false, false, bdt.getId() );
+        assertNotNull( result );
+
+        assertEquals( 1, result.getProjects().size() );
+
+        Project project = result.getProjects().get( 0 );
+        project = getContinuum().getProjectWithBuildDetails( project.getId() );
+        assertNotNull( project );
+        pg = getContinuum().getProjectGroupWithBuildDetails( pg.getId() );
+        log.info( "project buildDef list size : " + project.getBuildDefinitions().size()
);
+        assertEquals( 1, project.getBuildDefinitions().size() );
+        assertEquals( "clean deploy", ( (BuildDefinition) project.getBuildDefinitions().get(
0 ) ).getGoals() );
+    }
+    
+    public void testAddProjectWithBuildDefTemplateWithGroupCreation()
+        throws Exception
+    {
+
+        //bdt = bds.addBuildDefinitionInTemplate( bdt, bd, true );
+        File rootPom = getTestFile( "src/test/resources/projects/continuum/continuum-core/pom.xml"
);
+
+        assertTrue( rootPom.exists() );
+
+        ContinuumProjectBuildingResult result = getContinuum().addMavenTwoProject(
+                                                                                   rootPom.toURI().toURL()
+                                                                                       .toExternalForm(),
-1, true,
+                                                                                   false,
true, bdt.getId() );
+        assertNotNull( result );
+
+        assertEquals( 1, result.getProjects().size() );
+
+        Project project = result.getProjects().get( 0 );
+        assertNotNull( project );
+        log.info( "project buildDef list size : " + project.getBuildDefinitions().size()
);
+        log.info( "all pg size " + getContinuum().getAllProjectGroups().size() );
+        ProjectGroup pg = result.getProjectGroups().get( 0 );
+
+        pg = getContinuum().getProjectGroupWithBuildDetails( pg.getId() );
+
+        log.info( " pg groupId " + pg.getGroupId() );
+        //@ group level the db from template must be used
+        log.info( " mg builddefs size " + pg.getBuildDefinitions().size() );
+        log.info( "pg bd goals " + ( (BuildDefinition) pg.getBuildDefinitions().get( 0 )
).getGoals() );
+        assertEquals( "clean deploy", ( (BuildDefinition) pg.getBuildDefinitions().get( 0
) ).getGoals() );
+        
+    }    
+    
+    public void testAddProjectWithGroupCreationDefaultBuildDef()
+        throws Exception
+    {
+
+        //bdt = bds.addBuildDefinitionInTemplate( bdt, bd, true );
+        File rootPom = getTestFile( "src/test/resources/projects/continuum/continuum-core/pom.xml"
);
+
+        assertTrue( rootPom.exists() );
+
+        ContinuumProjectBuildingResult result = getContinuum().addMavenTwoProject(
+                                                                                   rootPom.toURI().toURL()
+                                                                                       .toExternalForm(),
-1, true,
+                                                                                   false,
true, -1 );
+        assertNotNull( result );
+
+        assertEquals( 1, result.getProjects().size() );
+
+        Project project = result.getProjects().get( 0 );
+        assertNotNull( project );
+        log.info( "project buildDef list size : " + project.getBuildDefinitions().size()
);
+        log.info( "all pg size " + getContinuum().getAllProjectGroups().size() );
+        ProjectGroup pg = result.getProjectGroups().get( 0 );
+
+        log.info( getContinuum().getAllProjectGroups().toString() );
+        log.info( " pg id " + Integer.toString( pg.getId() ) );
+
+        pg = getContinuum().getProjectGroupWithBuildDetails( pg.getId() );
+
+        log.info( " pg groupId " + pg.getGroupId() );
+        //@ group level the db from template must be used
+        log.info( " mg builddefs size " + pg.getBuildDefinitions().size() );
+        log.info( "pg bd goals " + ( (BuildDefinition) pg.getBuildDefinitions().get( 0 )
).getGoals() );
+        assertEquals( "clean install", ( (BuildDefinition) pg.getBuildDefinitions().get(
0 ) ).getGoals() );
+
+    }       
+
+
+    public void testAddProjectToExistingGroupDefaultBuildDef()
+        throws Exception
+    {
+
+        ProjectGroup pg = new ProjectGroup();
+        pg.setName( "foo" );
+        pg.setDescription( "foo pg" );
+        getContinuum().addProjectGroup( pg );
+        pg = getContinuum().getAllProjectGroups().get( 1 );
+        assertEquals( 2, getContinuum().getAllProjectGroups().size() );
+
+        File rootPom = getTestFile( "src/test/resources/projects/continuum/continuum-core/pom.xml"
);
+
+        assertTrue( rootPom.exists() );
+        //String url = getTestFile( "src/test-projects/project1/pom.xml" ).toURL().toExternalForm();
+        ContinuumProjectBuildingResult result = getContinuum().addMavenTwoProject(
+                                                                                   rootPom.toURI().toURL()
+                                                                                       .toExternalForm(),
pg.getId(),
+                                                                                   true,
false, false, -1 );
+        assertNotNull( result );
+
+        assertEquals( 1, result.getProjects().size() );
+
+        Project project = result.getProjects().get( 0 );
+        project = getContinuum().getProjectWithBuildDetails( project.getId() );
+        assertNotNull( project );
+        pg = getContinuum().getProjectGroupWithBuildDetails( pg.getId() );
+        log.info( "project buildDef list size : " + project.getBuildDefinitions().size()
);
+        assertEquals( 0, project.getBuildDefinitions().size() );
+        pg = result.getProjectGroups().get( 0 );
+
+        pg = getContinuum().getProjectGroupWithBuildDetails( pg.getId() );
+        
+        assertEquals( "clean install", ( (BuildDefinition) pg.getBuildDefinitions().get(
0 ) ).getGoals() );
+    }
+    
+    
+    private Continuum getContinuum()
+        throws Exception
+    {
+        return (Continuum) lookup( Continuum.ROLE );
+    }
+
+    @Override
+    protected String getPlexusConfigLocation()
+    {
+        return "org/apache/maven/continuum/DefaultContinuumTest.xml";
+    }
+
+    @Override
+    protected String getSpringConfigLocation()
+    {
+        return "applicationContextSlf4jPlexusLogger.xml";
+    }    
+    
+    
+}

Propchange: continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java?rev=726239&r1=726238&r2=726239&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
Sat Dec 13 09:34:07 2008
@@ -89,7 +89,9 @@
         
         //assertTrue( validator.validate( fileUrl ) );
         
-        ContinuumProjectBuildingResult result = continuum.addMavenTwoProject( fileUrl );
+        ContinuumProjectBuildingResult result = continuum.addMavenTwoProject( rootPom.toURI().toURL()
+                                                                              .toExternalForm(),
-1, true,
+                                                                              false, true,
-1 );
 
         assertNotNull( result );
 
@@ -470,8 +472,9 @@
         assertEquals( 0 , continuum.getAllContinuumReleaseResults().size() );
         assertFalse( logFile.exists() );
         assertEquals( defaultProjectGroup, continuum.getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID
) );
+        
     }
-
+    
     private Continuum getContinuum()
         throws Exception
     {

Modified: continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/projects/continuum/continuum-core/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/projects/continuum/continuum-core/pom.xml?rev=726239&r1=726238&r2=726239&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/projects/continuum/continuum-core/pom.xml
(original)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/projects/continuum/continuum-core/pom.xml
Sat Dec 13 09:34:07 2008
@@ -17,7 +17,7 @@
   ~ under the License.
   -->
 
-<project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <artifactId>continuum-parent</artifactId>



Mime
View raw message