antoine 2003/05/28 01:02:41
Modified: src/main/org/apache/tools/ant/listener MailLogger.java src/main/org/apache/tools/ant/taskdefs/email Mailer.java . build.xml Log: Remove dependency to JavaMail for MailLogger by using the Mailer class and Class.forName() instead of the MimeMailer class directly Also remove another bug in the MailLogger which would have forbidden to send plain mail PR: 5969 Revision Changes Path 1.18 +13 -5 ant/src/main/org/apache/tools/ant/listener/MailLogger.java Index: MailLogger.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/listener/MailLogger.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- MailLogger.java 27 May 2003 15:25:48 -0000 1.17 +++ MailLogger.java 28 May 2003 08:02:40 -0000 1.18 @@ -62,9 +62,9 @@ import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.DefaultLogger; import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.email.MimeMailer; import org.apache.tools.ant.taskdefs.email.EmailAddress; import org.apache.tools.ant.taskdefs.email.Message; +import org.apache.tools.ant.taskdefs.email.Mailer; import org.apache.tools.ant.util.DateUtils; import org.apache.tools.ant.util.StringUtils; import org.apache.tools.mail.MailMessage; @@ -155,14 +155,14 @@ String mailhost = getValue(properties, "mailhost", "localhost"); int port = Integer.parseInt(getValue(properties,"port",String.valueOf(MailMessage.DEFAULT_PORT))); - String user = getValue(properties, "user", null); - String password = getValue(properties, "password", null); + String user = getValue(properties, "user", ""); + String password = getValue(properties, "password", ""); String from = getValue(properties, "from", null); String replytoList = getValue(properties,"replyto",""); String toList = getValue(properties, prefix + ".to", null); String subject = getValue(properties, prefix + ".subject", (success) ? "Build Success" : "Build Failure"); - if (user==null && password==null) { + if (user.equals("") && password.equals("")) { sendMail(mailhost, port, from, replytoList, toList, subject, buffer.substring(0)); } else { @@ -266,8 +266,16 @@ private void sendMimeMail(Project project, String host, int port, String user, String password, String from, String replyToString, String toString, String subject, String message) throws IOException { // convert the replyTo string into a vector of emailaddresses + Mailer mailer = null; + try { + mailer = + (Mailer) Class.forName("org.apache.tools.ant.taskdefs.email.MimeMailer") + .newInstance(); + } catch (Throwable e) { + log("Failed to initialise MIME mail: "+e.getMessage()); + return; + } Vector replyToList = vectorizeEmailAddresses(replyToString); - MimeMailer mailer=new MimeMailer(); mailer.setHost(host); mailer.setPort(port); mailer.setUser(user); 1.11 +1 -1 ant/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java Index: Mailer.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/email/Mailer.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Mailer.java 27 May 2003 15:25:48 -0000 1.10 +++ Mailer.java 28 May 2003 08:02:41 -0000 1.11 @@ -64,7 +64,7 @@ * @author [EMAIL PROTECTED] Rob Oxspring * @since Ant 1.5 */ -abstract class Mailer { +public abstract class Mailer { protected String host = null; protected int port = -1; protected String user = null; 1.381 +1 -2 ant/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/ant/build.xml,v retrieving revision 1.380 retrieving revision 1.381 diff -u -r1.380 -r1.381 --- build.xml 28 May 2003 06:03:13 -0000 1.380 +++ build.xml 28 May 2003 08:02:41 -0000 1.381 @@ -214,7 +214,6 @@ <selector id="needs.javamail"> <or> <filename name="${ant.package}/taskdefs/email/MimeMailer*"/> - <filename name="${ant.package}/listener/MailLogger*"/> </or> </selector> <selector id="needs.icontract"> @@ -1568,7 +1567,7 @@ <exclude name="${optional.package}/sos/SOSTest.java" unless="tests.and.ant.share.classloader"/> <exclude name="${optional.package}/vss/MSVSSTest.java" - unless="tests.and.ant.share.classloader"/> + unless="tests.and.ant.share.classloader"/> <exclude name="${optional.package}/TraXLiaisonTest.java" unless="tests.and.ant.share.classloader"/> <exclude name="${optional.package}/metamata/MAuditParserTest.java"