continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r383944 - in /maven/continuum/branches/continuum-1.0.x: continuum-api/src/main/java/org/apache/maven/continuum/configuration/ continuum-core/src/main/java/org/apache/maven/continuum/configuration/ continuum-core/src/main/java/org/apache/mav...
Date Tue, 07 Mar 2006 17:58:09 GMT
Author: evenisse
Date: Tue Mar  7 09:58:05 2006
New Revision: 383944

URL: http://svn.apache.org/viewcvs?rev=383944&view=rev
Log:
[CONTINUUM-322] Add the possibiliy to be notify after all build
[CONTINUUM-470] Don't ignore sendOn settings

Modified:
    maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
    maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/java/org/apache/maven/continuum/project/ContinuumProjectState.java
    maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
    maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
    maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java
    maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java
    maven/continuum/branches/continuum-1.0.x/continuum-plexus-application/pom.xml
    maven/continuum/branches/continuum-1.0.x/continuum-plexus-application/src/conf/application.xml

Modified: maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java?rev=383944&r1=383943&r2=383944&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
Tue Mar  7 09:58:05 2006
@@ -83,6 +83,8 @@
     //
     // ----------------------------------------------------------------------
 
+    boolean isLoaded();
+
     void load()
         throws ConfigurationLoadingException;
 

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java?rev=383944&r1=383943&r2=383944&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
Tue Mar  7 09:58:05 2006
@@ -50,14 +50,14 @@
 
     private SystemConfiguration systemConf;
 
+    private boolean loaded = false;
+
     // ----------------------------------------------------------------------
     // Continuum specifics we'll refactor out later
     // ----------------------------------------------------------------------
 
     private Map jdks;
 
-    private static final String LS = System.getProperty( "line.separator" );
-
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -136,7 +136,7 @@
 
     public void setCompanyName( String companyName )
     {
-        systemConf.setCompanyName(  companyName );
+        systemConf.setCompanyName( companyName );
     }
 
     public String getCompanyUrl()
@@ -221,6 +221,11 @@
     // Load and Store
     // ----------------------------------------------------------------------
 
+    public boolean isLoaded()
+    {
+        return loaded;
+    }
+
     public void load()
         throws ConfigurationLoadingException
     {
@@ -234,6 +239,8 @@
 
                 systemConf = store.addSystemConfiguration( systemConf );
             }
+
+            loaded = true;
         }
         catch ( ContinuumStoreException e )
         {

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java?rev=383944&r1=383943&r2=383944&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
Tue Mar  7 09:58:05 2006
@@ -16,8 +16,8 @@
  * limitations under the License.
  */
 
-import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.configuration.ConfigurationException;
+import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectNotifier;
@@ -126,7 +126,8 @@
 
                 if ( build.getEndTime() != 0 )
                 {
-                    context.put( CONTEXT_BUILD_OUTPUT, configurationService.getBuildOutput(
build.getId(), project.getId() ) );
+                    context.put( CONTEXT_BUILD_OUTPUT,
+                                 configurationService.getBuildOutput( build.getId(), project.getId()
) );
                 }
 
                 context.put( CONTEXT_UPDATE_SCM_RESULT, build.getScmResult() );
@@ -162,12 +163,14 @@
 
             try
             {
+                configuration.put( AbstractContinuumNotifier.PROJECT_NOTIFIER_KEY, projectNotifier
);
+
                 Notifier notifier = notifierManager.getNotifier( notifierType );
 
-                Set recipients = recipientSource.getRecipients( String.valueOf( projectNotifier.getId()
),
-                                                                messageId, configuration,
context );
+                Set recipients = recipientSource.getRecipients( String.valueOf( projectNotifier.getId()
), messageId,
+                                                                configuration, context );
 
-                notifier.sendNotification( messageId, recipients, projectNotifier.getConfiguration(),
context );
+                notifier.sendNotification( messageId, recipients, configuration, context
);
             }
             catch ( NotificationException e )
             {

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java?rev=383944&r1=383943&r2=383944&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
Tue Mar  7 09:58:05 2006
@@ -200,7 +200,7 @@
     }
 
     private void buildComplete( Project project, BuildResult build, String buildOutput, String
source, Set recipients,
-                               Map configuration )
+                                Map configuration )
         throws NotificationException
     {
         // ----------------------------------------------------------------------
@@ -209,7 +209,7 @@
 
         BuildResult previousBuild = getPreviousBuild( project, build );
 
-        if ( !shouldNotify( build, previousBuild ) )
+        if ( !shouldNotify( build, previousBuild, configuration ) )
         {
             return;
         }
@@ -267,8 +267,8 @@
 
                 context.put( "osName", osName );
 
-                context.put( "javaVersion", System.getProperty( "java.version" ) + "("
-                    + System.getProperty( "java.vendor" ) + ")" );
+                context.put( "javaVersion",
+                             System.getProperty( "java.version" ) + "(" + System.getProperty(
"java.vendor" ) + ")" );
 
                 // ----------------------------------------------------------------------
                 // Generate
@@ -354,9 +354,8 @@
         if ( fromMailbox == null )
         {
             getLogger()
-                .warn(
-                       project.getName()
-                           + ": Project is missing nag email and global from mailbox is missing,
not sending mail." );
+                .warn( project.getName() +
+                    ": Project is missing nag email and global from mailbox is missing, not
sending mail." );
 
             return;
         }
@@ -449,8 +448,8 @@
 
         if ( currentBuild != null && build.getId() != currentBuild.getId() )
         {
-            throw new NotificationException( "INTERNAL ERROR: The current build wasn't the
first in the build list. "
-                + "Current build: '" + currentBuild.getId() + "', " + "first build: '" +
build.getId() + "'." );
+            throw new NotificationException( "INTERNAL ERROR: The current build wasn't the
first in the build list. " +
+                "Current build: '" + currentBuild.getId() + "', " + "first build: '" + build.getId()
+ "'." );
         }
 
         return (BuildResult) builds.get( builds.size() - 2 );

Modified: maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/java/org/apache/maven/continuum/project/ContinuumProjectState.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/java/org/apache/maven/continuum/project/ContinuumProjectState.java?rev=383944&r1=383943&r2=383944&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/java/org/apache/maven/continuum/project/ContinuumProjectState.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/java/org/apache/maven/continuum/project/ContinuumProjectState.java
Tue Mar  7 09:58:05 2006
@@ -63,6 +63,8 @@
 
     public final static int UPDATING = 8;
 
+    public final static int WARNING = 9;
+
     private String name;
 
     // TODO: maybe move these to another class

Modified: maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java?rev=383944&r1=383943&r2=383944&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
Tue Mar  7 09:58:05 2006
@@ -21,25 +21,37 @@
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.project.ContinuumProjectState;
 import org.codehaus.plexus.notification.notifier.AbstractNotifier;
 
+import java.util.Map;
+
 public abstract class AbstractContinuumNotifier
     extends AbstractNotifier
 {
+    public static final String PROJECT_NOTIFIER_KEY = "projectNotifier";
+
+    /**
+     * @plexus.configuration
+     */
+    private boolean alwaysSend = false;
+
     /**
      * Returns url of the last build
      *
      * @param project The project
-     * @param build The build
+     * @param build   The build
      */
     public String getReportUrl( Project project, BuildResult build, ConfigurationService
configurationService )
         throws ContinuumException
     {
         try
         {
-            //TODO it's bad to load always the conf when we want read a value
-            configurationService.load();
+            if ( !configurationService.isLoaded() )
+            {
+                configurationService.load();
+            }
 
             StringBuffer buf = new StringBuffer( configurationService.getUrl() );
 
@@ -62,15 +74,52 @@
         }
     }
 
+    /**
+     * Determine if message must be sent
+     *
+     * @param build         The current build result
+     * @param previousBuild The previous build result
+     * @return True if a message must be sent
+     * @deprecated
+     */
     public boolean shouldNotify( BuildResult build, BuildResult previousBuild )
     {
+        return shouldNotify( build, previousBuild, null );
+    }
+
+    /**
+     * Determine if message must be sent
+     *
+     * @param build         The current build result
+     * @param previousBuild The previous build result
+     * @param configuration The project notifier configuration
+     * @return True if a message must be sent
+     */
+    public boolean shouldNotify( BuildResult build, BuildResult previousBuild, Map configuration
)
+    {
+        ProjectNotifier projectNotifier = new ProjectNotifier();
+
+        if ( configuration != null && configuration.get( PROJECT_NOTIFIER_KEY ) !=
null )
+        {
+            projectNotifier = (ProjectNotifier) configuration.get( PROJECT_NOTIFIER_KEY );
+        }
+
         if ( build == null )
         {
             return false;
         }
 
-        // Always send if the project failed
-        if ( build.getState() == ContinuumProjectState.FAILED || build.getState() == ContinuumProjectState.ERROR
)
+        if ( alwaysSend )
+        {
+            return true;
+        }
+
+        if ( build.getState() == ContinuumProjectState.FAILED && projectNotifier.isSendOnFailure()
)
+        {
+            return true;
+        }
+
+        if ( build.getState() == ContinuumProjectState.ERROR && projectNotifier.isSendOnError()
)
         {
             return true;
         }
@@ -82,11 +131,31 @@
         }
 
         // Send if the state has changed
-        getLogger().info(
+        getLogger().debug(
             "Current build state: " + build.getState() + ", previous build state: " + previousBuild.getState()
);
 
         if ( build.getState() != previousBuild.getState() )
         {
+            if ( build.getState() == ContinuumProjectState.ERROR )
+            {
+                return projectNotifier.isSendOnError();
+            }
+
+            if ( build.getState() == ContinuumProjectState.FAILED )
+            {
+                return projectNotifier.isSendOnFailure();
+            }
+
+            if ( build.getState() == ContinuumProjectState.OK )
+            {
+                return projectNotifier.isSendOnSuccess();
+            }
+
+            if ( build.getState() == ContinuumProjectState.WARNING )
+            {
+                return projectNotifier.isSendOnWarning();
+            }
+
             return true;
         }
 

Modified: maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java?rev=383944&r1=383943&r2=383944&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
Tue Mar  7 09:58:05 2006
@@ -106,7 +106,7 @@
 
         BuildResult previousBuild = getPreviousBuild( project, build );
 
-        if ( !shouldNotify( build, previousBuild ) )
+        if ( !shouldNotify( build, previousBuild, configuration ) )
         {
             return;
         }

Modified: maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java?rev=383944&r1=383943&r2=383944&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java
Tue Mar  7 09:58:05 2006
@@ -185,7 +185,7 @@
 
         BuildResult previousBuild = getPreviousBuild( project, build );
 
-        if ( !shouldNotify( build, previousBuild ) )
+        if ( !shouldNotify( build, previousBuild, configuration ) )
         {
             return;
         }

Modified: maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java?rev=383944&r1=383943&r2=383944&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java
Tue Mar  7 09:58:05 2006
@@ -150,9 +150,9 @@
         }
         else
         {
-            getLogger().warn( "Unknown build state " + build.getState() + " for project "
+ project.getId() );
+            getLogger().warn( "Unknown build state " + state + " for project " + project.getId()
);
 
-            message = "ERROR: Unknown build state " + build.getState() + " for " + project.getName()
+ " project";
+            message = "ERROR: Unknown build state " + state + " for " + project.getName()
+ " project";
         }
 
         return message + " " + getReportUrl( project, build, configurationService );
@@ -169,7 +169,7 @@
 
         BuildResult previousBuild = getPreviousBuild( project, build );
 
-        if ( !shouldNotify( build, previousBuild ) )
+        if ( !shouldNotify( build, previousBuild, configuration ) )
         {
             return;
         }

Modified: maven/continuum/branches/continuum-1.0.x/continuum-plexus-application/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-plexus-application/pom.xml?rev=383944&r1=383943&r2=383944&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-plexus-application/pom.xml (original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-plexus-application/pom.xml Tue Mar
 7 09:58:05 2006
@@ -98,8 +98,16 @@
       <version>1.0-alpha-3</version>
       <exclusions>
         <exclusion>
-          <artifactId>plexus-container-default</artifactId>
           <groupId>plexus</groupId>
+          <artifactId>plexus-container-default</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.maven</groupId>
+          <artifactId>maven-artifact</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.maven.wagon</groupId>
+          <artifactId>wagon-provider-api</artifactId>
         </exclusion>
       </exclusions>
     </dependency>

Modified: maven/continuum/branches/continuum-1.0.x/continuum-plexus-application/src/conf/application.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-plexus-application/src/conf/application.xml?rev=383944&r1=383943&r2=383944&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-plexus-application/src/conf/application.xml
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-plexus-application/src/conf/application.xml
Tue Mar  7 09:58:05 2006
@@ -95,6 +95,7 @@
         <from-name>@mail.override.from.name@</from-name>
         <timestamp-format>EEE, d MMM yyyy HH:mm:ss Z</timestamp-format>
         <includeBuildResult>true</includeBuildResult>
+        <alwaysSend>false</alwaysSend>
       </configuration>
     </component>
 
@@ -144,6 +145,9 @@
           <role>org.apache.maven.continuum.configuration.ConfigurationService</role>
         </requirement>
       </requirements>
+      <configuration>
+        <alwaysSend>false</alwaysSend>
+      </configuration>
     </component>
 
     <component>
@@ -169,13 +173,14 @@
           <role>org.apache.maven.continuum.store.ContinuumStore</role>
         </requirement>
       </requirements>
-      <!-- configuration>
-        <from-address/>
+      <configuration>
+        <alwaysSend>false</alwaysSend>
+        <!-- from-address/>
         <from-password/>
         <host/>
         <port/>
-        <sslConnection>true</sslConnection>
-      </configuration -->
+        <sslConnection>true</sslConnection -->
+      </configuration>
     </component>
 
     <component>
@@ -201,10 +206,11 @@
           <role>org.apache.maven.continuum.store.ContinuumStore</role>
         </requirement>
       </requirements>
-      <!-- configuration>
-        <from-address/>
-        <from-password/>
-      </configuration -->
+      <configuration>
+        <alwaysSend>false</alwaysSend>
+        <!-- from-address/>
+        <from-password/ -->
+      </configuration>
     </component>
 
     <component>



Mime
View raw message