continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r777412 - in /continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ continuum-commons/src/main/java/org/apache/continuum/utils/ continuum-commons/src/test/java/org/apache/continuum/utils/ continuum-core/sr...
Date Fri, 22 May 2009 07:14:46 GMT
Author: ctan
Date: Fri May 22 07:14:45 2009
New Revision: 777412

URL: http://svn.apache.org/viewvc?rev=777412&view=rev
Log:
[CONTINUUM-2232]
- prevent adding duplicate projects in the same group
- allow duplicate projects from different groups to be added in the build queue during scheduled
builds
- log why project is not building during forced/scheduled build
merge -r 777410:777411 from 1.3.x branch

Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
    continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/utils/ProjectSorter.java
    continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/utils/ProjectSorterTest.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
    continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java?rev=777412&r1=777411&r2=777412&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
(original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
Fri May 22 07:14:45 2009
@@ -83,6 +83,8 @@
 
     public static final String ERROR_UNKNOWN = "add.project.unknown.error";
 
+    public static final String ERROR_DUPLICATE_PROJECTS = "add.project.duplicate.error";
+
     private final List<Project> projects = new ArrayList<Project>();
 
     private final List<ProjectGroup> projectGroups = new ArrayList<ProjectGroup>();

Modified: continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/utils/ProjectSorter.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/utils/ProjectSorter.java?rev=777412&r1=777411&r2=777412&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/utils/ProjectSorter.java
(original)
+++ continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/utils/ProjectSorter.java
Fri May 22 07:14:45 2009
@@ -68,7 +68,7 @@
 
             if ( dag.getVertex( id ) != null )
             {
-                logger.warn( "Project '" + id + "' is duplicated in the reactor and will
be discarded" );
+                logger.warn( "Project '" + id + "' is duplicated in the reactor." );
             }
 
             dag.addVertex( id );
@@ -79,13 +79,15 @@
         for ( Project project : projects )
         {
             String id = getProjectId( project );
+            
+            String projectGroupId = "[" + project.getProjectGroup().getId() + "]";
 
             // Dependencies
             for ( Object o : project.getDependencies() )
             {
                 ProjectDependency dependency = (ProjectDependency) o;
 
-                String dependencyId = getDependencyId( dependency );
+                String dependencyId = projectGroupId + ":" + getDependencyId( dependency
);
 
                 if ( dag.getVertex( dependencyId ) != null )
                 {
@@ -105,7 +107,7 @@
 
             if ( parent != null )
             {
-                String parentId = getDependencyId( parent );
+                String parentId = projectGroupId + ":" + getDependencyId( parent );
 
                 if ( dag.getVertex( parentId ) != null )
                 {
@@ -161,8 +163,10 @@
         {
             artifactId = project.getArtifactId();
         }
+        
+        String projectGroupId = "[" + project.getProjectGroup().getId() + "]";
 
-        return groupId + ":" + artifactId + ":" + project.getVersion();
+        return projectGroupId + ":" + groupId + ":" + artifactId + ":" + project.getVersion();
     }
 
     private static String getDependencyId( ProjectDependency project )

Modified: continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/utils/ProjectSorterTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/utils/ProjectSorterTest.java?rev=777412&r1=777411&r2=777412&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/utils/ProjectSorterTest.java
(original)
+++ continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/utils/ProjectSorterTest.java
Fri May 22 07:14:45 2009
@@ -25,6 +25,7 @@
 
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectDependency;
+import org.apache.maven.continuum.model.project.ProjectGroup;
 
 import junit.framework.TestCase;
 
@@ -103,6 +104,54 @@
         Project p4 = sortedList.get( 3 ); //ear1 project must be the latest
         assertEquals( ear1.getArtifactId(), p4.getArtifactId() );
     }
+    
+    /**
+     * test project build order
+     * build order: B -> A -> D -> C -> E
+     *
+     * @throws Exception
+     */
+    public void testProjectBuildOrder()
+        throws Exception
+    {
+        List<Project> list = new ArrayList<Project>();
+
+        Project projectA = getNewProject( "A" );
+        Project projectB = getNewProject( "B" );
+        Project projectC = getNewProject( "C" );
+        Project projectD = getNewProject( "D" );
+        Project projectE = getNewProject( "E" );
+        
+        projectA.setParent( generateProjectDependency( projectB ) );
+        projectE.setParent( generateProjectDependency( projectB ) );
+        projectC.setParent( generateProjectDependency( projectA ) );
+        projectC.setDependencies( Collections.singletonList( generateProjectDependency( projectD
) ) );
+        projectD.setParent( generateProjectDependency( projectA ) );
+                
+        list.add( projectA );
+        list.add( projectB );
+        list.add( projectC );
+        list.add( projectD );
+        list.add( projectE );
+
+        List<Project> sortedList = ProjectSorter.getSortedProjects( list, null );
+        assertNotNull( sortedList );
+        
+        List<Project> expectedList = new ArrayList<Project>();
+        
+        expectedList.add( projectB );
+        expectedList.add( projectA );
+        expectedList.add( projectD );
+        expectedList.add( projectC );
+        expectedList.add( projectE );
+        
+        for ( int i = 0; i < sortedList.size(); i++ )
+        {
+            Project sorted = sortedList.get( i );
+            Project expected = expectedList.get( i );
+            assertEquals( sorted.getArtifactId(), expected.getArtifactId() );
+        }
+    }
 
     /**
      * test one of the child projects not having the artifactId or groupId empty and working
off the
@@ -148,6 +197,7 @@
         Project project = new Project();
         project.setName( "foo" + projectId );
         project.setVersion( "v" + projectId );
+        project.setProjectGroup( new ProjectGroup() );
 
         return project;
     }
@@ -159,6 +209,7 @@
         project.setGroupId( "g" + projectId );
         project.setVersion( "v" + projectId );
         project.setName( "n" + projectId );
+        project.setProjectGroup( new ProjectGroup() );
 
         return project;
     }
@@ -173,4 +224,4 @@
         return dep;
     }
 
-}
\ No newline at end of file
+}

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java?rev=777412&r1=777411&r2=777412&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
Fri May 22 07:14:45 2009
@@ -244,6 +244,10 @@
                 throw new ContinuumException( "Error occurred while enqueuing prepare build
task", e );
             }
         }
+        else
+        {
+            log.warn( "No build agent configured. Not building projects." );
+        }
     }
 
     public void removeDistributedBuildQueueOfAgent( String buildAgentUrl )

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java?rev=777412&r1=777411&r2=777412&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
Fri May 22 07:14:45 2009
@@ -123,24 +123,32 @@
             overallBuildQueue = getOverallBuildQueue( BUILD_QUEUE, buildDefinition.getSchedule().getBuildQueues()
);
         }
 
-        String buildDefinitionLabel = buildDefinition.getDescription();
-        if ( StringUtils.isEmpty( buildDefinitionLabel ) )
+        if ( overallBuildQueue != null )
         {
-            buildDefinitionLabel = buildDefinition.getGoals();
-        }
+            String buildDefinitionLabel = buildDefinition.getDescription();
 
-        BuildProjectTask buildTask =
-            new BuildProjectTask( projectId, buildDefinition.getId(), trigger, projectName,
buildDefinitionLabel,
-                                  scmResult, projectGroupId );
-        try
-        {
-            log.info(
-                "Project '" + projectName + "' added to overall build queue '" + overallBuildQueue.getName()
+ "'." );
-            overallBuildQueue.addToBuildQueue( buildTask );
+            if ( StringUtils.isEmpty( buildDefinitionLabel ) )
+            {
+                buildDefinitionLabel = buildDefinition.getGoals();
+            }
+    
+            BuildProjectTask buildTask =
+                new BuildProjectTask( projectId, buildDefinition.getId(), trigger, projectName,
buildDefinitionLabel,
+                                      scmResult, projectGroupId );
+            try
+            {
+                log.info(
+                    "Project '" + projectName + "' added to overall build queue '" + overallBuildQueue.getName()
+ "'." );
+                overallBuildQueue.addToBuildQueue( buildTask );
+            }
+            catch ( TaskQueueException e )
+            {
+                throw new BuildManagerException( "Error occurred while adding project to
build queue: " + e.getMessage() );
+            }
         }
-        catch ( TaskQueueException e )
+        else
         {
-            throw new BuildManagerException( "Error occurred while adding project to build
queue: " + e.getMessage() );
+            log.warn( "No build queue configured. Not building." );
         }
     }
 
@@ -226,6 +234,10 @@
                     }
                 }
             }
+            else
+            {
+                log.warn( "No build queue configured. Not building" );
+            }
         }
         else
         {

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=777412&r1=777411&r2=777412&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
Fri May 22 07:14:45 2009
@@ -1657,6 +1657,15 @@
 
         for ( Project project : projects )
         {
+            checkForDuplicateProjectInGroup( projectGroup, project, result );
+          
+            if ( result.hasErrors() )
+            {
+                log.info( result.getErrors().size() + " errors during project add: " );
+                log.info( result.getErrorsAsString() );
+                return result;
+            }
+
             project.setScmUseCache( useCredentialsCache );
 
             // values backup for first checkout
@@ -3628,6 +3637,31 @@
         return filteredProjectsList;
     }
 
+    private void checkForDuplicateProjectInGroup( ProjectGroup projectGroup, Project projectToCheck,

+                                                   ContinuumProjectBuildingResult result
)
+    {
+        String duplicateProjects = "";
+
+        List<Project> projectsInGroup = projectGroup.getProjects();
+        
+        if ( projectsInGroup == null )
+        {
+            return;
+        }
+
+        for ( Project project : (List<Project>) projectGroup.getProjects() )
+        {
+            
+            if ( project.getGroupId().equals( projectToCheck.getGroupId() ) && 
+                 project.getArtifactId().equals( projectToCheck.getArtifactId() ) &&
+                 project.getVersion().equals( projectToCheck.getVersion() ) )
+            {
+                result.addError( result.ERROR_DUPLICATE_PROJECTS );
+                return;
+            }
+        }
+    }
+
     void setTaskQueueManager( TaskQueueManager taskQueueManager )
     {
         this.taskQueueManager = taskQueueManager;

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java?rev=777412&r1=777411&r2=777412&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
Fri May 22 07:14:45 2009
@@ -28,7 +28,6 @@
 import org.apache.continuum.web.util.AuditLog;
 import org.apache.continuum.web.util.AuditLogConstants;
 import org.apache.maven.continuum.ContinuumException;
-import org.apache.maven.continuum.builddefinition.BuildDefinitionServiceException;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;

Modified: continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=777412&r1=777411&r2=777412&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
Fri May 22 07:14:45 2009
@@ -298,6 +298,7 @@
 add.project.project.building.error = Unknown error trying to build POM.
 add.project.unknown.error = The specified resource cannot be accessed. Please try again later
or contact your administrator.
 add.project.nogroup.error = No project group specified.
+add.project.duplicate.error = Trying to add duplicate projects in the same project group.
 
 # ----------------------------------------------------------------------
 # Page: AddMavenOneProject



Mime
View raw message