You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by ha...@verizon.com on 2003/02/13 03:28:34 UTC

How to pass a value from a custom task to ant ?

I am writing a custom task in which I get the value of a variable by some
processing say dir= foo/bar.
I want to use this value in my ant script in subsequent processing.  I
tried setting the dir value to a system
property as System.setProperty("dir",dir), but when I tried to access I
could not access this value from ant.
I am accessing  like this

<property name="somename" value="${dir}"/>
when I echo

I get as ${dir} notthe value foo/bar

The same this if I set from command line as ant -Ddir=foo/bar I get it
correctly.
What is the problem.  Can we not access like this.
Is the ant going to read system properties at startup and doesn't care
about the properties set at runtime ?

If anybody has any idea please throw.

thanks
HP



Re: How to pass a value from a custom task to ant ?

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
On Wednesday, February 12, 2003, at 09:28  PM, 
hari.kalakonda@verizon.com wrote:
> What is the problem.  Can we not access like this.
> Is the ant going to read system properties at startup and doesn't care
> about the properties set at runtime ?

Exactly.

To set a property (in the Ant sense of the word, not the Java System 
sense), use project.setNewProperty().  I'd recommend one of the 
parameters to your task be the property name to set so that its 
dynamically configurable and not hard-coded.

	Erik