ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs SendEmail.java
Date Tue, 11 Dec 2001 09:23:56 GMT
stevel      01/12/11 01:23:56

  Modified:    src/main/org/apache/tools/ant/taskdefs SendEmail.java
  Log:
  task lacked a failonerror flag. sigh. now you can handle a missing server without the build
keeling over.
  
  Also now we can start writing some unit tests on this item, no?
  
  Revision  Changes    Path
  1.7       +27 -2     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/SendEmail.java
  
  Index: SendEmail.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/SendEmail.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SendEmail.java	2001/12/10 18:01:16	1.6
  +++ SendEmail.java	2001/12/11 09:23:56	1.7
  @@ -65,6 +65,7 @@
   import org.apache.tools.mail.MailMessage;
   
   import org.apache.tools.ant.Task;
  +import org.apache.tools.ant.Project;
   import org.apache.tools.ant.BuildException;
   
   /**
  @@ -126,6 +127,11 @@
       private String subject;
       private Vector files = new Vector();
       private boolean includefilenames;
  +    /**
  +     * failure flag
  +     */
  +    private boolean failOnError = true;
  +    
     
       /** Creates new SendEmail */
       public SendEmail() {
  @@ -201,12 +207,23 @@
        * Sets Includefilenames attribute
        *
        * @param includefilenames Set to true if file names are to be included.
  +     * @since 1.5
        */
       public void setIncludefilenames(boolean includefilenames) {
           this.includefilenames = includefilenames;
       }
   
       /**
  +     * Sets the FailOnError attribute of the MimeMail object
  +     *
  +     * @param failOnError The new FailOnError value
  +     * @since 1.5
  +     */
  +    public void setFailOnError(boolean failOnError) {
  +        this.failOnError = failOnError;
  +    }
  +    
  +    /**
        * Executes this build task.
        *
        * @throws BuildException if there is an error during task execution.
  @@ -267,7 +284,9 @@
                               }
                           } finally {
                               if (in != null) {
  -                                in.close();
  +                                try {
  +                                    in.close();
  +                                } catch (IOException ioe) {}
                               }
                           }
   
  @@ -286,7 +305,13 @@
               log("Sending email");
               mailMessage.sendAndClose();
           } catch (IOException ioe) {
  -            throw new BuildException("IO error sending mail", ioe);
  +            String err="IO error sending mail "+ioe.toString();
  +            if(failOnError) {
  +                throw new BuildException(err,ioe,location);
  +            }
  +            else {
  +                log(err,Project.MSG_ERR);
  +            }
           }
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message