Use getMessage in the messageLogged event, not in taskFinished. You'll
have to implement a simple state machine if you want to trigger it only
on the <echo> task.
Erik
On Thursday, April 10, 2003, at 09:58 AM, ALIA-SC, David wrote:
> Yep, but it throws an nullpointerexception when I try to use the
> event.getMessage() method !
>
> This is the beginning of my code (the principal lines) :
>
> public void taskFinished(BuildEvent event) {
> // filtering...
> if (event.getTask().getTaskName().equalsIgnoreCase(ECHO_TASK)) {
> // the next line does not work --> null pointer exception is
> raised ??
> String tmpMessage = event.getMessage();
> ...
> log.warn(tmpMessage);
> }
> }
>
> David
>
>
> -----Message d'origine-----
> De : Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
> Envoyé : jeudi 10 avril 2003 15:36
> À : user@ant.apache.org
> Objet : AW: Accessing getMessage() method of echo task from listener ?
>
>
> A quick look into the source ... BuildEvent would help you:
>
>
> Returns the project that fired this event.
> public Project getProject()
>
> Returns the target that fired this event.
> public Target getTarget()
>
> Returns the task that fired this event.
> public Task getTask()
>
> Returns the logging message. This field will only be set for
> "messageLogged"
> events.
> public String getMessage()
>
> Returns the priority of the logging message. This field will only be
> set for
> "messageLogged" events. The meaning of this priority is as specified
> by the
> constants in the {@link Project Project} class.
> public int getPriority()
>
> Returns the exception that was thrown, if any. This field will only be
> set
> for "taskFinished", "targetFinished", and "buildFinished" events.
> public Throwable getException()
>
>
>
> Jan Matèrne
>
>> -----Ursprüngliche Nachricht-----
>> Von: ALIA-SC, David [mailto:David.ALIA-SC@AirLiquide.com]
>> Gesendet am: Donnerstag, 10. April 2003 15:30
>> An: Ant Users List
>> Betreff: Accessing getMessage() method of echo task from listener ?
>>
>> Hmm...
>>
>> I want to have my listener more and more effective (thanks to
>> Jan Materne,
>> i've finally managed to have it work fine :)).
>>
>> In the taskFinished(BuildEvent event) method, I want to log
>> the message
>> attribute of an <echo> task (filtering tasks is easy).
>>
>> But how can I get the echoed message into my java code ?
>> Do I have to use the getMessage() of this task ?
>>
>> David
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
|