ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maart...@apache.org
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 GMT
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 <code>null</code>.
      */
-    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();
         }



Mime
View raw message