Browse Source

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
master
Stefan Bodewig 16 years ago
parent
commit
e5e17582b0
3 changed files with 35 additions and 5 deletions
  1. +4
    -0
      WHATSNEW
  2. +15
    -3
      docs/manual/listeners.html
  3. +16
    -2
      src/main/org/apache/tools/ant/listener/MailLogger.java

+ 4
- 0
WHATSNEW View File

@@ -429,6 +429,10 @@ Other changes:
reach at least one given recipient. reach at least one given recipient.
Bugzilla Report 36446. 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 Changes from Ant 1.7.0 TO Ant 1.7.1
============================================= =============================================




+ 15
- 3
docs/manual/listeners.html View File

@@ -224,9 +224,16 @@ control for turning off success or failure messages individually.</p>
<td width="63%">No, default &quot;Build Success&quot;</td> <td width="63%">No, default &quot;Build Success&quot;</td>
</tr> </tr>
<tr> <tr>
<td width="337">MailLogger.properties.file </td>
<td width="63%">Filename of properties file that will override other values.</td>
<td width="63%">No</td>
<td width="337">MailLogger.failure.body</td>
<td width="63%">Fixed body of the email for a failed
build. <em>Since Ant 1.8.0</em></td>
<td width="63%">No, default is to send the full log output.</td>
</tr>
<tr>
<td width="337">MailLogger.success.body</td>
<td width="63%">Fixed body of the email for a successful
build. <em>Since Ant 1.8.0</em></td>
<td width="63%">No, default is to send the full log output.</td>
</tr> </tr>
<tr> <tr>
<td width="337">MailLogger.mimeType</td> <td width="337">MailLogger.mimeType</td>
@@ -238,6 +245,11 @@ control for turning off success or failure messages individually.</p>
<td width="63%">Character set of the message. <em>Since Ant 1.8.0</em></td> <td width="63%">Character set of the message. <em>Since Ant 1.8.0</em></td>
<td width="63%">No</td> <td width="63%">No</td>
</tr> </tr>
<tr>
<td width="337">MailLogger.properties.file </td>
<td width="63%">Filename of properties file that will override other values.</td>
<td width="63%">No</td>
</tr>
</table> </table>
<blockquote> <blockquote>




+ 16
- 2
src/main/org/apache/tools/ant/listener/MailLogger.java View File

@@ -67,6 +67,10 @@ import org.apache.tools.mail.MailMessage;
* failed build</li> * failed build</li>
* <li> MailLogger.success.subject [default: "Build Success"] - Subject of * <li> MailLogger.success.subject [default: "Build Success"] - Subject of
* successful build</li> * successful build</li>
* <li> MailLogger.failure.body [default: none] - fixed text of
* mail body for a failed build, default is to send the logfile</li>
* <li> MailLogger.success.body [default: none] - fixed text of
* mail body for a successful build, default is to send the logfile</li>
* <li> MailLogger.mimeType [default: text/plain] - MIME-Type of email</li> * <li> MailLogger.mimeType [default: text/plain] - MIME-Type of email</li>
* <li> MailLogger.charset [no default] - character set of email</li> * <li> MailLogger.charset [no default] - character set of email</li>
* <li> MailLogger.properties.file [no default] - Filename of * <li> MailLogger.properties.file [no default] - Filename of
@@ -143,6 +147,7 @@ public class MailLogger extends DefaultLogger {
.toList(getValue(properties, prefix + ".to", null)) .toList(getValue(properties, prefix + ".to", null))
.mimeType(getValue(properties, "mimeType", DEFAULT_MIME_TYPE)) .mimeType(getValue(properties, "mimeType", DEFAULT_MIME_TYPE))
.charset(getValue(properties, "charset", "")) .charset(getValue(properties, "charset", ""))
.body(getValue(properties, prefix + ".body", ""))
.subject(getValue( .subject(getValue(
properties, prefix + ".subject", properties, prefix + ".subject",
(success) ? "Build Success" : "Build Failure")); (success) ? "Build Success" : "Build Failure"));
@@ -249,6 +254,14 @@ public class MailLogger extends DefaultLogger {
this.mimeType = mimeType; this.mimeType = mimeType;
return this; 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(); PrintStream ps = mailMessage.getPrintStream();
ps.println(message);
ps.println(values.body().length() > 0 ? values.body() : message);


mailMessage.sendAndClose(); mailMessage.sendAndClose();
} }
@@ -352,7 +365,8 @@ public class MailLogger extends DefaultLogger {
mailer.setUser(values.user()); mailer.setUser(values.user());
mailer.setPassword(values.password()); mailer.setPassword(values.password());
mailer.setSSL(values.ssl()); mailer.setSSL(values.ssl());
Message mymessage = new Message(message);
Message mymessage =
new Message(values.body().length() > 0 ? values.body() : message);
mymessage.setProject(project); mymessage.setProject(project);
mymessage.setMimeType(values.mimeType()); mymessage.setMimeType(values.mimeType());
if (values.charset().length() > 0) { if (values.charset().length() > 0) {


Loading…
Cancel
Save