Browse Source

Enable property expansion when reading MailLogger.properties.file. Also, modified so error stack trace goes to System.err.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272538 13f79535-47bb-0310-9956-ffa450edef68
master
Erik Hatcher 23 years ago
parent
commit
0b3cd9d4fe
1 changed files with 12 additions and 11 deletions
  1. +12
    -11
      src/main/org/apache/tools/ant/listener/MailLogger.java

+ 12
- 11
src/main/org/apache/tools/ant/listener/MailLogger.java View File

@@ -53,6 +53,12 @@
*/ */
package org.apache.tools.ant.listener; package org.apache.tools.ant.listener;


import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.StringUtils;
import org.apache.tools.mail.MailMessage;

import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -62,12 +68,6 @@ import java.util.Hashtable;
import java.util.Properties; import java.util.Properties;
import java.util.StringTokenizer; import java.util.StringTokenizer;


import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.StringUtils;
import org.apache.tools.mail.MailMessage;

/** /**
* Buffers log messages from DefaultLogger, and sends an e-mail with the * Buffers log messages from DefaultLogger, and sends an e-mail with the
* results. The following Project properties are used to send the mail. * results. The following Project properties are used to send the mail.
@@ -94,7 +94,7 @@ import org.apache.tools.mail.MailMessage;
* MailLogger.properties.file property</i> . Any properties defined in that * MailLogger.properties.file property</i> . Any properties defined in that
* file will override Ant properties. * file will override Ant properties.
* *
* @author Erik Hatcher
* @author Erik Hatcher
* <a href="mailto:ehatcher@apache.org">ehatcher@apache.org</a> * <a href="mailto:ehatcher@apache.org">ehatcher@apache.org</a>
*/ */
public class MailLogger extends DefaultLogger { public class MailLogger extends DefaultLogger {
@@ -135,7 +135,8 @@ public class MailLogger extends DefaultLogger {


for (Enumeration e = fileProperties.keys(); e.hasMoreElements();) { for (Enumeration e = fileProperties.keys(); e.hasMoreElements();) {
String key = (String) e.nextElement(); String key = (String) e.nextElement();
properties.put(key, fileProperties.getProperty(key));
String value = fileProperties.getProperty(key);
properties.put(key, project.replaceProperties(value));
} }


boolean success = (event.getException() == null); boolean success = (event.getException() == null);
@@ -159,7 +160,7 @@ public class MailLogger extends DefaultLogger {
sendMail(mailhost, from, toList, subject, buffer.toString()); sendMail(mailhost, from, toList, subject, buffer.toString());
} catch (Exception e) { } catch (Exception e) {
System.out.println("MailLogger failed to send e-mail!"); System.out.println("MailLogger failed to send e-mail!");
e.printStackTrace();
e.printStackTrace(System.err);
} }
} }


@@ -180,13 +181,13 @@ public class MailLogger extends DefaultLogger {
* @param properties Properties to obtain value from * @param properties Properties to obtain value from
* @param name suffix of property name. "MailLogger." will be * @param name suffix of property name. "MailLogger." will be
* prepended internally. * prepended internally.
* @param defaultValue value returned if not present in the properties.
* @param defaultValue value returned if not present in the properties.
* Set to null to make required. * Set to null to make required.
* @return The value of the property, or default value. * @return The value of the property, or default value.
* @exception Exception thrown if no default value is specified and the * @exception Exception thrown if no default value is specified and the
* property is not present in properties. * property is not present in properties.
*/ */
private String getValue(Hashtable properties, String name,
private String getValue(Hashtable properties, String name,
String defaultValue) throws Exception { String defaultValue) throws Exception {
String propertyName = "MailLogger." + name; String propertyName = "MailLogger." + name;
String value = (String) properties.get(propertyName); String value = (String) properties.get(propertyName);


Loading…
Cancel
Save