ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Lenz <cml...@gmx.de>
Subject Log messages from custom task are not associated with the task
Date Fri, 19 Sep 2003 10:31:13 GMT
Hi all,

I'm having a particularly weird problem here (and that after having 
successfully written a couple dozen of Ant tasks already!). I've tried on 
various 1.5.x versions of Ant.

I have a custom task that is taskdef'd and used in the same target (and 
compiled in another target). All works nicely, with one exception: any 
messages logged by my task are not associated with my task, but rather 
appear at the target level. This only becomes apparent when using the XmlLogger:

   ...
   <target ...>
     <message .../>
     <message .../>
     <task name="mytask" .../>
   </target>
   ...

The expected output would be:

   ...
   <target ...>
     <task name="mytask" ...>
       <message .../>
       <message .../>
     </task>
   </target>
   ...

The taskStarted() method of XmlLogger gets called to announce the start of 
my custom task. However, the object passed in as task is not an instance of 
my task class, but rather of UnknownElement. The XmlLogger uses this object 
as a key into its internal Hashtable where it stores the corresponding 
TimedElement for later retrieval.

Now, when my task logs a message, the method messageLogged() of XmlLogger is 
called. This method tries to retrieve the TimedElement from the HashTable by 
using the task associated with the log message as a key. This time, however, 
the task object is really an instance of my task class. Of course, the 
lookup into the Hashtable fails, and the message is logged at the target 
level instead.

I'm really wondering how this could ever work. Why is my task an 
UnknownElement when taskStarted() is invoked?

-chris



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message