continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r575311 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/ continuum-api/src/main/java/org/apache/maven/continuum/store/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/java...
Date Thu, 13 Sep 2007 13:41:57 GMT
Author: evenisse
Date: Thu Sep 13 06:41:56 2007
New Revision: 575311

URL: http://svn.apache.org/viewvc?rev=575311&view=rev
Log:
[CONTINUUM-1037] Allow to add more than one default build definition in a group (one by project
type)
Choose the default build definition to use for a project with the executor type

Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java
    maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java
    maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=575311&r1=575310&r2=575311&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
Thu Sep 13 06:41:56 2007
@@ -475,7 +475,7 @@
     BuildDefinition getDefaultBuildDefinition( int projectId )
         throws ContinuumException;
 
-    public BuildDefinition getDefaultBuildDefinitionForProjectGroup( int projectGroupId )
+    public List<BuildDefinition> getDefaultBuildDefinitionsForProjectGroup( int projectGroupId
)
         throws ContinuumException;
 
     BuildDefinition addBuildDefinitionToProject( int projectId, BuildDefinition buildDefinition
)

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java?rev=575311&r1=575310&r2=575311&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
Thu Sep 13 06:41:56 2007
@@ -79,8 +79,8 @@
         throws ContinuumStoreException, ContinuumObjectNotFoundException;
 
     /**
-     * returns the default build definition for the project group and there
-     * should always be one declared
+     * returns the default build definitions for the project group and there
+     * should always be at least one declared
      *
      * @param projectGroupId
      * @return
@@ -88,7 +88,7 @@
      * @throws ContinuumObjectNotFoundException
      *
      */
-    BuildDefinition getDefaultBuildDefinitionForProjectGroup( int projectGroupId )
+    List<BuildDefinition> getDefaultBuildDefinitionsForProjectGroup( int projectGroupId
)
         throws ContinuumStoreException, ContinuumObjectNotFoundException;
 
     BuildDefinition getBuildDefinition( int buildDefinitionId )

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=575311&r1=575310&r2=575311&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Thu Sep 13 06:41:56 2007
@@ -844,29 +844,30 @@
     public void buildProjectGroup( int projectGroupId )
         throws ContinuumException
     {
-        BuildDefinition groupDefaultBD = null;
+        List<BuildDefinition> groupDefaultBDs = null;
 
-        groupDefaultBD = getDefaultBuildDefinitionForProjectGroup( projectGroupId );
+        groupDefaultBDs = getDefaultBuildDefinitionsForProjectGroup( projectGroupId );
 
-        int buildDefinitionId = -1;
-
-        if ( groupDefaultBD != null )
-        {
-            buildDefinitionId = groupDefaultBD.getId();
-        }
-        buildProjectGroupWithBuildDefinition( projectGroupId, buildDefinitionId, true );
+        buildProjectGroupWithBuildDefinition( projectGroupId, groupDefaultBDs, true );
     }
 
     /**
-     * fire off a build for all of the projects in a project group using their default builds
+     * fire off a build for all of the projects in a project group using their default builds.
      *
-     * @param projectGroupId
+     * @param projectGroupId the project group id
+     * @param buildDefinitionId the build definition id to use
      * @throws ContinuumException
      */
     public void buildProjectGroupWithBuildDefinition( int projectGroupId, int buildDefinitionId
)
         throws ContinuumException
     {
-        buildProjectGroupWithBuildDefinition( projectGroupId, buildDefinitionId, false );
+        List<BuildDefinition> bds = new ArrayList<BuildDefinition>();
+        BuildDefinition bd = getBuildDefinition( buildDefinitionId );
+        if ( bd != null )
+        {
+            bds.add( bd );
+        }
+        buildProjectGroupWithBuildDefinition( projectGroupId, bds, false );
     }
 
     /**
@@ -875,7 +876,7 @@
      * @param projectGroupId
      * @throws ContinuumException
      */
-    private void buildProjectGroupWithBuildDefinition( int projectGroupId, int buildDefinitionId,
+    private void buildProjectGroupWithBuildDefinition( int projectGroupId, List<BuildDefinition>
bds,
                                                        boolean checkDefaultBuildDefinitionForProject
)
         throws ContinuumException
     {
@@ -898,7 +899,16 @@
         {
             Project project = (Project) i.next();
 
-            int buildDefId = buildDefinitionId;
+            int buildDefId = -1;
+
+            for ( BuildDefinition bd : bds )
+            {
+                if ( project.getExecutorId().equals( bd.getType() ) )
+                {
+                    buildDefId = bd.getId();
+                    break;
+                }
+            }
 
             if ( checkDefaultBuildDefinitionForProject )
             {
@@ -924,10 +934,10 @@
                 }
             }
 
-            if ( !"maven2".equals( project.getExecutorId() ) )
+            if ( buildDefId == -1 )
             {
-                getLogger().info(
-                    "Project " + project.getId() + " is not a maven2 project, will not be
included in group build." );
+                getLogger().info( "Project " + project.getId() +
+                    " don't have a default build definition defined in the project or project
group, will not be included in group build." );
                 continue;
             }
 
@@ -1982,12 +1992,12 @@
         }
     }
 
-    public BuildDefinition getDefaultBuildDefinitionForProjectGroup( int projectGroupId )
+    public List<BuildDefinition> getDefaultBuildDefinitionsForProjectGroup( int projectGroupId
)
         throws ContinuumException
     {
         try
         {
-            return store.getDefaultBuildDefinitionForProjectGroup( projectGroupId );
+            return store.getDefaultBuildDefinitionsForProjectGroup( projectGroupId );
         }
         catch ( ContinuumObjectNotFoundException cne )
         {

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java?rev=575311&r1=575310&r2=575311&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java
Thu Sep 13 06:41:56 2007
@@ -86,6 +86,7 @@
      *
      * @param buildDefinition
      * @param projectGroup
+     * @throws ContinuumException
      */
     protected void resolveDefaultBuildDefinitionsForProjectGroup( BuildDefinition buildDefinition,
                                                                   ProjectGroup projectGroup
)
@@ -93,27 +94,35 @@
     {
         try
         {
-            BuildDefinition storedDefinition = store.getDefaultBuildDefinitionForProjectGroup(
projectGroup.getId() );
+            List<BuildDefinition> storedDefinitions =
+                store.getDefaultBuildDefinitionsForProjectGroup( projectGroup.getId() );
 
-            // if buildDefinition passed in is not default then we are done
-            if ( buildDefinition.isDefaultForProject() )
+            for ( BuildDefinition storedDefinition : storedDefinitions )
             {
-                if ( storedDefinition != null && storedDefinition.getId() != buildDefinition.getId()
)
+                // if buildDefinition passed in is not default then we are done
+                if ( buildDefinition.isDefaultForProject() )
                 {
-                    storedDefinition.setDefaultForProject( false );
+                    if ( storedDefinition != null && storedDefinition.getId() !=
buildDefinition.getId() )
+                    {
+                        if ( buildDefinition.getType() != null &&
+                            buildDefinition.getType().equals( storedDefinition.getType()
) )
+                        {
+                            storedDefinition.setDefaultForProject( false );
 
-                    store.storeBuildDefinition( storedDefinition );
+                            store.storeBuildDefinition( storedDefinition );
+                        }
+                    }
                 }
-            }
-            else
-            {
-                //make sure we are not wacking out default build definition, that would be
bad
-                if ( buildDefinition.getId() == storedDefinition.getId() )
+                else
                 {
-                    getLogger().info(
-                        "processing this build definition would result in no default build
definition for project group" );
-                    throw new ContinuumException(
-                        "processing this build definition would result in no default build
definition for project group" );
+                    //make sure we are not wacking out default build definition, that would
be bad
+                    if ( buildDefinition.getId() == storedDefinition.getId() )
+                    {
+                        getLogger().info(
+                            "processing this build definition would result in no default
build definition for project group" );
+                        throw new ContinuumException(
+                            "processing this build definition would result in no default
build definition for project group" );
+                    }
                 }
             }
         }
@@ -181,11 +190,11 @@
                 storedDefinition.setProfile( buildDefinition.getProfile() );
 
                 storedDefinition.setDescription( buildDefinition.getDescription() );
-                
+
                 storedDefinition.setType( buildDefinition.getType() );
-                
+
                 storedDefinition.setAlwaysBuild( buildDefinition.isAlwaysBuild() );
-                
+
                 store.storeBuildDefinition( storedDefinition );
 
                 return storedDefinition;

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java?rev=575311&r1=575310&r2=575311&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/installation/DefaultInstallationService.java
Thu Sep 13 06:41:56 2007
@@ -155,7 +155,7 @@
     /**
      * @see org.apache.maven.continuum.installation.InstallationService#getAllInstallations()
      */
-    @SuppressWarnings ("unchecked")
+    @SuppressWarnings("unchecked")
     public List<Installation> getAllInstallations()
         throws InstallationException
     {
@@ -335,7 +335,7 @@
         }
         return cliOutput;
     }
-    
+
     private Map<String, String> getEnvVars( Profile profile )
     {
         Map<String, String> environnments = new HashMap<String, String>();
@@ -363,13 +363,13 @@
     }
 
     /**
-     * @see org.apache.maven.continuum.installation.InstallationService#getExecutorConfiguratorVersion(java.lang.String,org.apache.maven.continuum.execution.ExecutorConfigurator)
+     * @see org.apache.maven.continuum.installation.InstallationService#getExecutorConfiguratorVersion(java.lang.String,org.apache.maven.continuum.execution.ExecutorConfigurator,Profile)
      */
-    @SuppressWarnings ("unchecked")
-    public List<String> getExecutorConfiguratorVersion( String path, ExecutorConfigurator
executorConfigurator, Profile profile )
+    @SuppressWarnings("unchecked")
+    public List<String> getExecutorConfiguratorVersion( String path, ExecutorConfigurator
executorConfigurator,
+                                                        Profile profile )
         throws InstallationException
     {
-         
 
         if ( executorConfigurator == null )
         {
@@ -398,7 +398,7 @@
                 String value = environments.get( key );
                 commandline.addEnvironment( key, value );
             }
-            
+
             executable = executable.append( executorConfigurator.getExecutable() );
             commandline.setExecutable( executable.toString() );
             commandline.addArguments( new String[]{executorConfigurator.getVersionArgument()}
);

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?rev=575311&r1=575310&r2=575311&view=diff
==============================================================================
--- 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
Thu Sep 13 06:41:56 2007
@@ -592,7 +592,7 @@
     {
         return getLatestBuildResultsByProjectGroupId( -1 );
     }
-    
+
     public void removeBuildResult( BuildResult buildResult )
     {
         removeObject( buildResult );
@@ -632,7 +632,17 @@
         {
             ProjectGroup projectGroup = getProjectGroupByProjectId( projectId );
 
-            bd = getDefaultBuildDefinitionForProjectGroup( projectGroup.getId() );
+            Project p = getProject( projectId );
+
+            List<BuildDefinition> bds = getDefaultBuildDefinitionsForProjectGroup(
projectGroup.getId() );
+
+            for ( BuildDefinition bdef : bds )
+            {
+                if ( p.getExecutorId().equals( bdef.getType() ) )
+                {
+                    return bdef;
+                }
+            }
         }
 
         return bd;
@@ -669,11 +679,13 @@
         throw new ContinuumObjectNotFoundException( "no default build definition declared
for project " + projectId );
     }
 
-    public BuildDefinition getDefaultBuildDefinitionForProjectGroup( int projectGroupId )
+    public List<BuildDefinition> getDefaultBuildDefinitionsForProjectGroup( int projectGroupId
)
         throws ContinuumStoreException, ContinuumObjectNotFoundException
     {
         ProjectGroup projectGroup = getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId
);
 
+        List<BuildDefinition> bds = new ArrayList<BuildDefinition>();
+
         for ( Iterator i = projectGroup.getBuildDefinitions().iterator(); i.hasNext(); )
         {
             BuildDefinition bd = (BuildDefinition) i.next();
@@ -681,11 +693,11 @@
             // also applies to project group membership
             if ( bd.isDefaultForProject() )
             {
-                return bd;
+                bds.add( bd );
             }
         }
 
-        return null;
+        return bds;
     }
 
     public Map getDefaultBuildDefinitions()

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java?rev=575311&r1=575310&r2=575311&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
Thu Sep 13 06:41:56 2007
@@ -27,8 +27,6 @@
 import org.apache.maven.continuum.project.ContinuumProjectState;
 import org.apache.maven.continuum.web.bean.ProjectGroupUserBean;
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
-import org.apache.maven.continuum.web.model.BuildDefinitionSummary;
-import org.apache.maven.continuum.xmlrpc.project.ProjectGroupSummary;
 import org.codehaus.plexus.redback.rbac.RBACManager;
 import org.codehaus.plexus.redback.rbac.RbacManagerException;
 import org.codehaus.plexus.redback.rbac.RbacObjectNotFoundException;
@@ -131,23 +129,21 @@
 
         projectGroup = getProjectGroup( projectGroupId );
         //projectGroup.
-        
-                
-        List<BuildDefinition> projectGroupBuildDefs = getContinuum().getBuildDefinitionsForProjectGroup(
projectGroupId );
 
-        int defaultBuildDefinitionId = getContinuum().getDefaultBuildDefinitionForProjectGroup(
projectGroupId ).getId();
+        List<BuildDefinition> projectGroupBuildDefs =
+            getContinuum().getBuildDefinitionsForProjectGroup( projectGroupId );
 
-        if (projectGroupBuildDefs != null)
+        if ( projectGroupBuildDefs != null )
         {
-            this.buildDefinitions = new LinkedHashMap<String, Integer>(projectGroupBuildDefs.size());
-            for(BuildDefinition buildDefinition : projectGroupBuildDefs)
+            this.buildDefinitions = new LinkedHashMap<String, Integer>( projectGroupBuildDefs.size()
);
+            for ( BuildDefinition buildDefinition : projectGroupBuildDefs )
             {
-                
-                if (buildDefinition.getId() != defaultBuildDefinitionId)
+
+                if ( !buildDefinition.isDefaultForProject() )
                 {
                     String key = StringUtils.isEmpty( buildDefinition.getDescription() )
? buildDefinition.getGoals()
-                                                                                        :
buildDefinition
-                                                                                        
   .getDescription();
+                        : buildDefinition
+                            .getDescription();
                     buildDefinitions.put( key, Integer.valueOf( buildDefinition.getId() )
);
                 }
             }
@@ -341,7 +337,8 @@
                 }
             }
 
-            ProjectGroup newProjectGroup = getContinuum().getProjectGroupWithProjects( new
Integer( id[0] ).intValue() );
+            ProjectGroup newProjectGroup =
+                getContinuum().getProjectGroupWithProjects( new Integer( id[0] ).intValue()
);
 
             if ( newProjectGroup.getId() != projectGroup.getId() )
             {

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java?rev=575311&r1=575310&r2=575311&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java
Thu Sep 13 06:41:56 2007
@@ -147,12 +147,12 @@
             }
 
             //TODO : Change this part because it's a duplicate of DefaultContinuum.buildProjectGroup*
-            BuildDefinition groupDefaultBD = null;
+            List<BuildDefinition> groupDefaultBDs = null;
             if (getBuildDefinitionId() == -1 || getBuildDefinitionId() == 0)
             {
                 try
                 {
-                    groupDefaultBD = store.getDefaultBuildDefinitionForProjectGroup( projectGroupId
);
+                    groupDefaultBDs = store.getDefaultBuildDefinitionsForProjectGroup( projectGroupId
);
                 }
                 catch ( ContinuumObjectNotFoundException e )
                 {
@@ -170,7 +170,16 @@
                 Project project = (Project) i.next();
                 if ( this.getBuildDefinitionId() == -1 || getBuildDefinitionId() == 0)
                 {
-                    int buildDefId = groupDefaultBD.getId();
+                    int buildDefId = -1;
+
+                    for ( BuildDefinition bd : groupDefaultBDs )
+                    {
+                        if ( project.getExecutorId().equals( bd.getType() ) )
+                        {
+                            buildDefId = bd.getId();
+                            break;
+                        }
+                    }
 
                     BuildDefinition projectDefaultBD = null;
                     if ( this.getBuildDefinitionId() == -1 )

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?rev=575311&r1=575310&r2=575311&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
Thu Sep 13 06:41:56 2007
@@ -372,6 +372,7 @@
 buildDefinition.goals.maven.label = Goals
 buildDefinition.arguments.label = Arguments
 buildDefinition.buildFresh.label = Build Fresh (Run always a clean checkout instead of an
SCM update)
+buildDefinition.type.label = Type
 buildDefinition.defaultForProject.label = Is it default?
 buildDefinition.schedule.label = Schedule
 buildDefinition.description.label = Description



Mime
View raw message