Return-Path: Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: (qmail 37895 invoked from network); 12 Jun 2010 21:40:39 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 12 Jun 2010 21:40:39 -0000 Received: (qmail 46159 invoked by uid 500); 12 Jun 2010 21:40:39 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 46076 invoked by uid 500); 12 Jun 2010 21:40:38 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 46068 invoked by uid 99); 12 Jun 2010 21:40:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Jun 2010 21:40:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Jun 2010 21:40:36 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 044DB23889EB; Sat, 12 Jun 2010 21:39:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r954142 - in /ant/ivy/core/trunk: CHANGES.txt src/java/org/apache/ivy/ant/AntMessageLogger.java src/java/org/apache/ivy/ant/IvyAntSettings.java src/java/org/apache/ivy/util/MessageLoggerEngine.java Date: Sat, 12 Jun 2010 21:39:52 -0000 To: notifications@ant.apache.org From: maartenc@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100612213953.044DB23889EB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: maartenc Date: Sat Jun 12 21:39:52 2010 New Revision: 954142 URL: http://svn.apache.org/viewvc?rev=954142&view=rev Log: FIX: Ant output wasn't always prefixed by the name of the Ivy task Modified: ant/ivy/core/trunk/CHANGES.txt ant/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageLogger.java ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java ant/ivy/core/trunk/src/java/org/apache/ivy/util/MessageLoggerEngine.java Modified: ant/ivy/core/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=954142&r1=954141&r2=954142&view=diff ============================================================================== --- ant/ivy/core/trunk/CHANGES.txt (original) +++ ant/ivy/core/trunk/CHANGES.txt Sat Jun 12 21:39:52 2010 @@ -126,6 +126,7 @@ for detailed view of each issue, please - IMPROVEMENT: Trace a message when a property file referenced from the settings doesn't exixts (IVY-1074) - IMPROVEMENT: use defaultconf in combination with defaultconfmapping (IVY-1135) (thanks to Jon Schneider) +- FIX: Ant output wasn't always prefixed by the name of the Ivy task - FIX: Resolved Ivy properties written to cache during ivy:resolve incorrectly represents forced revisions (IVY-1159) - FIX: Namespace rules not properly applied to parent projects (IVY-1186) - FIX: LatestVersionMatcher.needModuleDescriptor() does not honor custom statuses (IVY-1170) (thanks to Carl Quinn) Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageLogger.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageLogger.java?rev=954142&r1=954141&r2=954142&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageLogger.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageLogger.java Sat Jun 12 21:39:52 2010 @@ -20,9 +20,9 @@ package org.apache.ivy.ant; import org.apache.ivy.Ivy; import org.apache.ivy.util.AbstractMessageLogger; import org.apache.ivy.util.Checks; +import org.apache.ivy.util.MessageLogger; import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildListener; -import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.Task; /** @@ -45,6 +45,18 @@ public class AntMessageLogger extends Ab * the ivy instance on which the logger should be registered */ public static void register(Task task, final Ivy ivy) { + MessageLogger current = ivy.getLoggerEngine().peekLogger(); + if (current instanceof AntMessageLogger) { + Task currentTask = ((AntMessageLogger) current).task; + + if ((currentTask.getTaskName() != null) + && currentTask.getTaskName().equals(task.getTaskName())) { + // The current AntMessageLogger already logs with the same + // prefix as the given task. So we shouldn't do anything... + return; + } + } + AntMessageLogger logger = new AntMessageLogger(task); ivy.getLoggerEngine().pushLogger(logger); task.getProject().addBuildListener(new BuildListener() { @@ -73,7 +85,7 @@ public class AntMessageLogger extends Ab // NB2 : Testing the identity of the task is not enought, event.getTask() return // an instance of UnknownElement is wrapping the concrete instance stackDepth--; - if (stackDepth == 0) { + if (stackDepth == -1) { ivy.getLoggerEngine().popLogger(); event.getProject().removeBuildListener(this); } @@ -85,7 +97,7 @@ public class AntMessageLogger extends Ab } - private ProjectComponent projectComponent; + private Task task; private long lastProgressFlush = 0; @@ -98,17 +110,17 @@ public class AntMessageLogger extends Ab * the ant project component this message implementation should use for logging. Must * not be null. */ - protected AntMessageLogger(ProjectComponent antProjectComponent) { - Checks.checkNotNull(antProjectComponent, "antProjectComponent"); - projectComponent = antProjectComponent; + protected AntMessageLogger(Task task) { + Checks.checkNotNull(task, "task"); + this.task = task; } public void log(String msg, int level) { - projectComponent.log(msg, level); + task.log(msg, level); } public void rawlog(String msg, int level) { - projectComponent.getProject().log(msg, level); + task.getProject().log(msg, level); } public void doProgress() { @@ -118,19 +130,19 @@ public class AntMessageLogger extends Ab } // log with ant causes a new line -> we do it only once in a while if (System.currentTimeMillis() - lastProgressFlush > PROGRESS_LOG_PERIOD) { - projectComponent.log(buf.toString()); + task.log(buf.toString()); buf.setLength(0); lastProgressFlush = System.currentTimeMillis(); } } public void doEndProgress(String msg) { - projectComponent.log(buf + msg); + task.log(buf + msg); buf.setLength(0); lastProgressFlush = 0; } public String toString() { - return "AntMessageLogger:" + projectComponent; + return "AntMessageLogger:" + task; } } Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java?rev=954142&r1=954141&r2=954142&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java Sat Jun 12 21:39:52 2010 @@ -261,7 +261,7 @@ public class IvyAntSettings extends Data Ivy ivy = Ivy.newInstance(settings); try { ivy.pushContext(); - ivy.getLoggerEngine().pushLogger(new AntMessageLogger(task)); + AntMessageLogger.register(task, ivy); Message.showInfo(); configureURLHandler(); @@ -287,7 +287,6 @@ public class IvyAntSettings extends Data throw new BuildException("impossible to configure ivy:settings with given " + (file != null ? "file: " + file : "url: " + url) + " : " + e, e); } finally { - ivy.getLoggerEngine().popLogger(); ivy.popContext(); } } Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/MessageLoggerEngine.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/MessageLoggerEngine.java?rev=954142&r1=954141&r2=954142&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/util/MessageLoggerEngine.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/MessageLoggerEngine.java Sat Jun 12 21:39:52 2010 @@ -85,7 +85,7 @@ public class MessageLoggerEngine impleme * Returns the current logger, or the default one if there is no logger in the stack * @return the current logger, or the default one if there is no logger in the stack */ - private MessageLogger peekLogger() { + public MessageLogger peekLogger() { if (loggerStack.isEmpty()) { return getDefaultLogger(); }