continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcconn...@apache.org
Subject svn commit: r467678 - in /maven/continuum/trunk/continuum-core/src: main/java/org/apache/maven/continuum/execution/maven/m2/ main/java/org/apache/maven/continuum/project/builder/maven/ test/java/org/apache/maven/continuum/ test/java/org/apache/maven/co...
Date Wed, 25 Oct 2006 15:05:53 GMT
Author: jmcconnell
Date: Wed Oct 25 08:05:52 2006
New Revision: 467678

URL: http://svn.apache.org/viewvc?view=rev&rev=467678
Log:
group notifiers should be loading up correctly now on adding of the m2 project

Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java?view=diff&rev=467678&r1=467677&r2=467678
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
Wed Oct 25 08:05:52 2006
@@ -108,23 +108,26 @@
     // ----------------------------------------------------------------------
     // MavenBuilderHelper Implementation
     // ----------------------------------------------------------------------
-
+    /**
+     * @deprecated use {@link #mapMavenProjectToContinuumProject(ContinuumProjectBuildingResult,
MavenProject, Project, boolean)} instead.
+     */
     public void mapMetadataToProject( File metadata, Project continuumProject )
         throws MavenBuilderHelperException
     {
-        mapMavenProjectToContinuumProject( getMavenProject( metadata ), continuumProject
);
+        // todo this is deprecated so it shouldn't be used anyway so just set false for groupPom
boolean and clean up later
+        mapMavenProjectToContinuumProject( getMavenProject( metadata ), continuumProject,
false );
     }
 
     /**
-     * @deprecated use {@link #mapMavenProjectToContinuumProject(ContinuumProjectBuildingResult,
MavenProject, Project)} instead.
+     * @deprecated use {@link #mapMavenProjectToContinuumProject(ContinuumProjectBuildingResult,
MavenProject, Project, boolean)} instead.
      */
-    public void mapMavenProjectToContinuumProject( MavenProject mavenProject, Project continuumProject
)
+    public void mapMavenProjectToContinuumProject( MavenProject mavenProject, Project continuumProject,
boolean groupPom )
         throws MavenBuilderHelperException
     {
-        mapMavenProjectToContinuumProject( new ContinuumProjectBuildingResult(), mavenProject,
continuumProject );
+        mapMavenProjectToContinuumProject( new ContinuumProjectBuildingResult(), mavenProject,
continuumProject, groupPom );
     }
     
-    public void mapMavenProjectToContinuumProject( ContinuumProjectBuildingResult result,
MavenProject mavenProject, Project continuumProject )
+    public void mapMavenProjectToContinuumProject( ContinuumProjectBuildingResult result,
MavenProject mavenProject, Project continuumProject, boolean groupPom )
     {
     
         // ----------------------------------------------------------------------
@@ -253,54 +256,59 @@
 
         // ----------------------------------------------------------------------
         // Notifiers
+        //
+        // if its a groupPom, then notifiers have been taken care of
         // ----------------------------------------------------------------------
 
-        List userNotifiers = new ArrayList();
-
-        if ( continuumProject.getNotifiers() != null )
+        if ( !groupPom )
         {
-            for ( int i = 0; i < continuumProject.getNotifiers().size(); i++ )
-            {
-                ProjectNotifier notifier = (ProjectNotifier) continuumProject.getNotifiers().get(
i );
+            List userNotifiers = new ArrayList();
 
-                if ( notifier.isFromUser() )
+            if ( continuumProject.getNotifiers() != null )
+            {
+                for ( int i = 0; i < continuumProject.getNotifiers().size(); i++ )
                 {
-                    ProjectNotifier userNotifier = new ProjectNotifier();
+                    ProjectNotifier notifier = (ProjectNotifier) continuumProject.getNotifiers().get(
i );
+
+                    if ( notifier.isFromUser() )
+                    {
+                        ProjectNotifier userNotifier = new ProjectNotifier();
 
-                    userNotifier.setType( notifier.getType() );
+                        userNotifier.setType( notifier.getType() );
 
-                    userNotifier.setEnabled( notifier.isEnabled() );
+                        userNotifier.setEnabled( notifier.isEnabled() );
 
-                    userNotifier.setConfiguration( notifier.getConfiguration() );
+                        userNotifier.setConfiguration( notifier.getConfiguration() );
 
-                    userNotifier.setFrom( notifier.getFrom() );
+                        userNotifier.setFrom( notifier.getFrom() );
 
-                    userNotifier.setRecipientType( notifier.getRecipientType() );
+                        userNotifier.setRecipientType( notifier.getRecipientType() );
 
-                    userNotifier.setSendOnError( notifier.isSendOnError() );
+                        userNotifier.setSendOnError( notifier.isSendOnError() );
 
-                    userNotifier.setSendOnFailure( notifier.isSendOnFailure() );
+                        userNotifier.setSendOnFailure( notifier.isSendOnFailure() );
 
-                    userNotifier.setSendOnSuccess( notifier.isSendOnSuccess() );
+                        userNotifier.setSendOnSuccess( notifier.isSendOnSuccess() );
 
-                    userNotifier.setSendOnWarning( notifier.isSendOnWarning() );
+                        userNotifier.setSendOnWarning( notifier.isSendOnWarning() );
 
-                    userNotifiers.add( userNotifier );
+                        userNotifiers.add( userNotifier );
+                    }
                 }
             }
-        }
 
-        List notifiers = getNotifiers( result, mavenProject );
-        if ( notifiers != null )
-        {
-            continuumProject.setNotifiers( notifiers );
-        }
+            List notifiers = getNotifiers( result, mavenProject, continuumProject );
+            if ( notifiers != null )
+            {
+                continuumProject.setNotifiers( notifiers );
+            }
 
-        for ( Iterator i = userNotifiers.iterator(); i.hasNext(); )
-        {
-            ProjectNotifier notifier = (ProjectNotifier) i.next();
+            for ( Iterator i = userNotifiers.iterator(); i.hasNext(); )
+            {
+                ProjectNotifier notifier = (ProjectNotifier) i.next();
 
-            continuumProject.addNotifier( notifier );
+                continuumProject.addNotifier( notifier );
+            }
         }
     }
     
@@ -455,7 +463,7 @@
         return project.getScm().getConnection();
     }
 
-    private List getNotifiers( ContinuumProjectBuildingResult result, MavenProject mavenProject
)
+    private List getNotifiers( ContinuumProjectBuildingResult result, MavenProject mavenProject,
Project continuumProject )
     {
         List notifiers = new ArrayList();
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java?view=diff&rev=467678&r1=467677&r2=467678
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java
Wed Oct 25 08:05:52 2006
@@ -43,13 +43,20 @@
     MavenProject getMavenProject( ContinuumProjectBuildingResult result, File file );
 
     /**
-     * @deprecated use {@link #mapMavenProjectToContinuumProject(ContinuumProjectBuildingResult,
MavenProject, Project)} instead.
+     * @deprecated use {@link #mapMavenProjectToContinuumProject(ContinuumProjectBuildingResult,
MavenProject, Project, boolean)} instead.
      */
-    void mapMavenProjectToContinuumProject( MavenProject mavenProject, Project continuumProject
)
+    void mapMavenProjectToContinuumProject( MavenProject mavenProject, Project continuumProject,
boolean groupPom )
         throws MavenBuilderHelperException;
 
+    /**
+     *
+     * @param result
+     * @param mavenProject
+     * @param continuumProject
+     * @param groupPom map this project as if it is being used to initialize a project group
+     */
     void mapMavenProjectToContinuumProject( ContinuumProjectBuildingResult result, MavenProject
mavenProject,
-                                            Project continuumProject );
+                                            Project continuumProject, boolean groupPom );
 
     ArtifactRepository getLocalRepository();
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java?view=diff&rev=467678&r1=467677&r2=467678
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
Wed Oct 25 08:05:52 2006
@@ -23,6 +23,7 @@
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.model.project.Schedule;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.project.builder.AbstractContinuumProjectBuilder;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuilderException;
@@ -30,6 +31,7 @@
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.model.Notifier;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.FileNotFoundException;
@@ -182,7 +184,7 @@
         {
             Project continuumProject = new Project();
 
-            builderHelper.mapMavenProjectToContinuumProject( result, mavenProject, continuumProject
);
+            builderHelper.mapMavenProjectToContinuumProject( result, mavenProject, continuumProject,
groupPom );
 
             result.addProject( continuumProject, MavenTwoBuildExecutor.ID );
         }
@@ -264,6 +266,53 @@
         // ----------------------------------------------------------------------
 
         projectGroup.setDescription( mavenProject.getDescription() );
+
+
+        //
+        // group lvl notifiers
+        //
+        if ( mavenProject.getCiManagement() != null && mavenProject.getCiManagement().getNotifiers()
!= null )
+        {
+            List notifiers = new ArrayList();
+
+            for ( Iterator i = mavenProject.getCiManagement().getNotifiers().iterator();
i.hasNext(); )
+            {
+                Notifier projectNotifier = (Notifier) i.next();
+
+                ProjectNotifier notifier = new ProjectNotifier();
+
+                if ( StringUtils.isEmpty( projectNotifier.getType() ) )
+                {
+                    result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_NOTIFIER_TYPE
);
+                    return null;
+                }
+
+                notifier.setType( projectNotifier.getType() );
+
+                if ( projectNotifier.getConfiguration() == null )
+                {
+                    result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_NOTIFIER_CONFIGURATION
);
+                    return null;
+                }
+
+                notifier.setConfiguration( projectNotifier.getConfiguration() );
+
+                notifier.setFrom( ProjectNotifier.FROM_PROJECT );
+
+                notifier.setSendOnSuccess( projectNotifier.isSendOnSuccess() );
+
+                notifier.setSendOnFailure( projectNotifier.isSendOnFailure() );
+
+                notifier.setSendOnError( projectNotifier.isSendOnError() );
+
+                notifier.setSendOnWarning( projectNotifier.isSendOnWarning() );
+
+                notifiers.add( notifier );
+            }
+
+            projectGroup.setNotifiers( notifiers );
+        }
+
 
         return projectGroup;
     }

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java?view=diff&rev=467678&r1=467677&r2=467678
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
Wed Oct 25 08:05:52 2006
@@ -282,8 +282,7 @@
         ProjectGroup projectGroup = (ProjectGroup) result.getProjectGroups().get( 0 );
 
         continuum.addGroupNotifier( projectGroup.getId(), new ProjectNotifier() );
-        continuum.addGroupNotifier( projectGroup.getId(), new ProjectNotifier() );
-
+       
         for ( Iterator i = projectGroup.getProjects().iterator(); i.hasNext(); )
         {
             Project p = (Project)i.next();
@@ -299,9 +298,7 @@
         for ( Iterator i = projectGroup.getProjects().iterator(); i.hasNext(); )
         {
             Project p = (Project)i.next();
-            // this is 2 right now, the notifier in the pom is placed in each notifier right
now
-            assertEquals( 2, p.getNotifiers().size() );
-
+            assertEquals( 1, p.getNotifiers().size() );
         }        
     }
 

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java?view=diff&rev=467678&r1=467677&r2=467678
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
Wed Oct 25 08:05:52 2006
@@ -25,13 +25,13 @@
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.PrintStream;
-import java.net.URL;
-import java.util.HashMap;
+import java.io.ByteArrayOutputStream;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.HashMap;
+import java.net.URL;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -58,13 +58,15 @@
 
         assertEquals( 1, result.getProjects().size() );
 
-        Project project = (Project) result.getProjects().get( 0 );
+        ProjectGroup pg = (ProjectGroup)result.getProjectGroups().get(0);
 
-        assertNotNull( project.getNotifiers() );
+        assertNotNull( pg );
 
-        assertEquals( 1, project.getNotifiers().size() );
+        assertNotNull( pg.getNotifiers() );
 
-        ProjectNotifier notifier = (ProjectNotifier) project.getNotifiers().get( 0 );
+        assertEquals( 1, pg.getNotifiers().size() );
+
+        ProjectNotifier notifier = (ProjectNotifier) pg.getNotifiers().get( 0 );
 
         assertEquals( "mail", notifier.getType() );
 
@@ -89,13 +91,15 @@
 
         assertEquals( 1, result.getProjects().size() );
 
-        Project project = (Project) result.getProjects().get( 0 );
+        ProjectGroup pg = (ProjectGroup)result.getProjectGroups().get(0);
+
+        assertNotNull( pg );
 
-        assertNotNull( project.getNotifiers() );
+        assertNotNull( pg.getNotifiers() );
 
-        assertEquals( 1, project.getNotifiers().size() );
+        assertEquals( 1, pg.getNotifiers().size() );
 
-        ProjectNotifier notifier = (ProjectNotifier) project.getNotifiers().get( 0 );
+        ProjectNotifier notifier = (ProjectNotifier) pg.getNotifiers().get( 0 );
 
         assertEquals( "mail", notifier.getType() );
 
@@ -120,13 +124,15 @@
 
         assertEquals( 1, result.getProjects().size() );
 
-        Project project = (Project) result.getProjects().get( 0 );
+        ProjectGroup pg = (ProjectGroup)result.getProjectGroups().get(0);
+
+        assertNotNull( pg );
 
-        assertNotNull( project.getNotifiers() );
+        assertNotNull( pg.getNotifiers() );
 
-        assertEquals( 1, project.getNotifiers().size() );
+        assertEquals( 1, pg.getNotifiers().size() );
 
-        ProjectNotifier notifier = (ProjectNotifier) project.getNotifiers().get( 0 );
+        ProjectNotifier notifier = (ProjectNotifier) pg.getNotifiers().get( 0 );
 
         assertEquals( "mail", notifier.getType() );
 
@@ -134,7 +140,9 @@
 
         String username = System.getProperty( "user.name" );
 
-        String scmUrl = "scm:cvs:ext:${user.name}@company.org:/home/company/cvs:project/foo";
+        String scmUrl = "scm:cvs:ext:${user.name}@company.org:/home/company/cvs:project/foo"
;
+
+        Project project = (Project)result.getProjects().get(0);
 
         scmUrl = StringUtils.replace( scmUrl, "${user.name}", username );
 
@@ -281,7 +289,6 @@
 
         assertEquals( 0, projectGroup.getProjects().size() );
     }
-
 
     private void assertDependency( String dep, String proj, Map projects )
     {



Mime
View raw message