ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: expanding properties in custom task
Date Mon, 01 Sep 2003 07:05:22 GMT
On Monday, September 1, 2003, at 02:01  AM, Jon Madison wrote:
> Thanks greatly for the direction! Definitely my bad for the laziness. 
> I had
> expected this to be mentioned in the doc (at least clearly?). I'll 
> implement
> and (if time permits) modify/submit changes to the documentation
> accordingly.
> j.

Well, just to make a shameless plug - it is "documented", in Java 
Development with Ant:

19.4.2 Handling element text
Element text is handed to its containing object, typically the task 
itself, or possibly a
nested element, using the addText method. Of note is that the text is 
provided as is,
and no property references are expanded. Here is a simple example of a 
variant of the
original MessageTask to take the message text as the element data 
rather than from
an attribute:

package org.example.antbook.tasks;
public class MessageTask2 extends Task {
   private String message = "";
   public void addText(String message) {
     this.message = message;

   public void execute() {

Our build file fragment using this task is:

   <property name="another.message" value="light up ahead"/>

It generates this output:

   [message2] ${another.message}

Special method to accept element text
Having the unaltered body text provided to the task is beneficial for 
data that may
contain such strings that appear like property references, but if you 
need those references
resolved, it’s a simple matter of adding a call to a Project method. 
Our execute
method now becomes:

public void execute() {

The results now have the property references resolved:

   [message2] light up ahead

Now that you know how to do it, where in the docs would be a good place 
to add this?  Care to submit a patch so that we can fold it in?

Or perhaps we could put this stuff on the Jakarta wiki pages for Ant?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message