Browse Source

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?


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270112 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 23 years ago
parent
commit
d7c1a1daa5
1 changed files with 27 additions and 2 deletions
  1. +27
    -2
      src/main/org/apache/tools/ant/taskdefs/SendEmail.java

+ 27
- 2
src/main/org/apache/tools/ant/taskdefs/SendEmail.java View File

@@ -65,6 +65,7 @@ import java.util.Enumeration;
import org.apache.tools.mail.MailMessage; import org.apache.tools.mail.MailMessage;


import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;


/** /**
@@ -126,6 +127,11 @@ public class SendEmail extends Task {
private String subject; private String subject;
private Vector files = new Vector(); private Vector files = new Vector();
private boolean includefilenames; private boolean includefilenames;
/**
* failure flag
*/
private boolean failOnError = true;
/** Creates new SendEmail */ /** Creates new SendEmail */
public SendEmail() { public SendEmail() {
@@ -201,11 +207,22 @@ public class SendEmail extends Task {
* Sets Includefilenames attribute * Sets Includefilenames attribute
* *
* @param includefilenames Set to true if file names are to be included. * @param includefilenames Set to true if file names are to be included.
* @since 1.5
*/ */
public void setIncludefilenames(boolean includefilenames) { public void setIncludefilenames(boolean includefilenames) {
this.includefilenames = 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. * Executes this build task.
* *
@@ -267,7 +284,9 @@ public class SendEmail extends Task {
} }
} finally { } finally {
if (in != null) { if (in != null) {
in.close();
try {
in.close();
} catch (IOException ioe) {}
} }
} }


@@ -286,7 +305,13 @@ public class SendEmail extends Task {
log("Sending email"); log("Sending email");
mailMessage.sendAndClose(); mailMessage.sendAndClose();
} catch (IOException ioe) { } 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);
}
} }
} }




Loading…
Cancel
Save