ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <jakarta-...@ehatchersolutions.com>
Subject Re: RE : RE : Accessing getMessage() method of echo task from listene r ?
Date Thu, 10 Apr 2003 14:46:18 GMT
Again, messageLogged is the method to use getMessage in, not 
taskFinished.

	Erik


On Thursday, April 10, 2003, at 10:25  AM, ALIA-SC, David wrote:

> I can't believe neither.. But...
>
> Here is the complete code below.
> Maybe I should code this part into the taskStarted instead ? (I'll try 
> this
> now)...
>
>
>     public void taskFinished(BuildEvent event) {
> 		if (initialized) {
> 			if
> (event.getTask().getTaskName().equalsIgnoreCase(ECHO_TASK)) {
> 				// Logging only for ECHO task
> 				Hashtable table =
> event.getProject().getProperties();
> 				String log_id = (String)table.get("log.id");
>
> 				String TargName =
> event.getTask().getTaskName();
> 				String strTargetlog = "";
> 				
> 				String tmpMessage = "*";
> 				
> 				if (event.getMessage() != null) {
> 					tmpMessage = event.getMessage();
> 				}
> 							
> 				strTargetlog += log_id + TokenSeparator;
> 				strTargetlog += GetDBDate() +
> TokenSeparator;
> 				strTargetlog +=
> event.getTask().getOwningTarget().toString() + TokenSeparator;
> 				
> 				strTargetlog += Apostrophe(TargName + " > "
> + tmpMessage) + TokenSeparator;
> 				strTargetlog += Apostrophe(STATUS_WG);
> 				log.warn(strTargetlog);
> 			}
> 		}    	
> 	}
>
>
>
>
>
> -----Message d'origine-----
> De : Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
> Envoyé : jeudi 10 avril 2003 16:01
> À : user@ant.apache.org
> Objet : AW: RE : Accessing getMessage() method of echo task from 
> listener ?
>
>
> Can´t believe ...
>
> event.getTask() should work (therefore event!=null=
> event.getMessage() not (therefore event==null)?
>
> Do you have another object named "event" between the if-statement and 
> the
> error?
>
>
> Jan Matèrne
>
>> -----Ursprüngliche Nachricht-----
>> Von: ALIA-SC, David [mailto:David.ALIA-SC@AirLiquide.com]
>> Gesendet am: Donnerstag, 10. April 2003 15:58
>> An: Ant Users List
>> Betreff: RE : Accessing getMessage() method of echo task from
>> listener ?
>>
>> 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
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


Mime
View raw message