From e5e17582b09d86d1499a6c1d08fb9629c60b9f68 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Tue, 14 Oct 2008 15:15:47 +0000 Subject: [PATCH] Allow MailLogger to send a fixed email text. PR 38029. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@704562 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 4 ++++ docs/manual/listeners.html | 18 +++++++++++++++--- .../apache/tools/ant/listener/MailLogger.java | 18 ++++++++++++++++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index e93979dfe..0598c22cc 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -429,6 +429,10 @@ Other changes: reach at least one given recipient. Bugzilla Report 36446. + * two new properties allow MailLogger to send a fixed text instead of + the log file. + Bugzilla Report 38029. + Changes from Ant 1.7.0 TO Ant 1.7.1 ============================================= diff --git a/docs/manual/listeners.html b/docs/manual/listeners.html index dc7a7f982..7175cd225 100644 --- a/docs/manual/listeners.html +++ b/docs/manual/listeners.html @@ -224,9 +224,16 @@ control for turning off success or failure messages individually.

No, default "Build Success" - MailLogger.properties.file - Filename of properties file that will override other values. - No + MailLogger.failure.body + Fixed body of the email for a failed + build. Since Ant 1.8.0 + No, default is to send the full log output. + + + MailLogger.success.body + Fixed body of the email for a successful + build. Since Ant 1.8.0 + No, default is to send the full log output. MailLogger.mimeType @@ -238,6 +245,11 @@ control for turning off success or failure messages individually.

Character set of the message. Since Ant 1.8.0 No + + MailLogger.properties.file + Filename of properties file that will override other values. + No +
diff --git a/src/main/org/apache/tools/ant/listener/MailLogger.java b/src/main/org/apache/tools/ant/listener/MailLogger.java index 42ac93663..8623f2885 100644 --- a/src/main/org/apache/tools/ant/listener/MailLogger.java +++ b/src/main/org/apache/tools/ant/listener/MailLogger.java @@ -67,6 +67,10 @@ import org.apache.tools.mail.MailMessage; * failed build *
  • MailLogger.success.subject [default: "Build Success"] - Subject of * successful build
  • + *
  • MailLogger.failure.body [default: none] - fixed text of + * mail body for a failed build, default is to send the logfile
  • + *
  • MailLogger.success.body [default: none] - fixed text of + * mail body for a successful build, default is to send the logfile
  • *
  • MailLogger.mimeType [default: text/plain] - MIME-Type of email
  • *
  • MailLogger.charset [no default] - character set of email
  • *
  • MailLogger.properties.file [no default] - Filename of @@ -143,6 +147,7 @@ public class MailLogger extends DefaultLogger { .toList(getValue(properties, prefix + ".to", null)) .mimeType(getValue(properties, "mimeType", DEFAULT_MIME_TYPE)) .charset(getValue(properties, "charset", "")) + .body(getValue(properties, prefix + ".body", "")) .subject(getValue( properties, prefix + ".subject", (success) ? "Build Success" : "Build Failure")); @@ -249,6 +254,14 @@ public class MailLogger extends DefaultLogger { this.mimeType = mimeType; return this; } + private String body; + public String body() { + return body; + } + public Values body(String body) { + this.body = body; + return this; + } } /** @@ -324,7 +337,7 @@ public class MailLogger extends DefaultLogger { } PrintStream ps = mailMessage.getPrintStream(); - ps.println(message); + ps.println(values.body().length() > 0 ? values.body() : message); mailMessage.sendAndClose(); } @@ -352,7 +365,8 @@ public class MailLogger extends DefaultLogger { mailer.setUser(values.user()); mailer.setPassword(values.password()); mailer.setSSL(values.ssl()); - Message mymessage = new Message(message); + Message mymessage = + new Message(values.body().length() > 0 ? values.body() : message); mymessage.setProject(project); mymessage.setMimeType(values.mimeType()); if (values.charset().length() > 0) {