Java Mailing List Archive

http://www.ant-tasks.com/

Home » Ant Users List »

RE: how to change the property value at run time

Irfan Sayed

2008-05-15

Replies: Find Java Web Hosting

Author LoginPost Reply
Thanks to all. I got the concept now.

Regards,
Irfan

-----Original Message-----
From: David Weintraub [mailto:qazwart@(protected)]
Sent: Thursday, May 15, 2008 7:10 AM
To: Ant Users List
Subject: Re: how to change the property value at run time

Once an Ant property is set, you can't change it. However, there are a
few ways to get around this:

1). In an antcall, you set <param> and these parameters are inherited
as properties in the called target:

<target name="first">
  <antcall target="subtask">
    <param name="param1" value="${JAVA_HOME}"/>
  </antcall>
</target>

<target name="second">
  <antcall target="subtask">
    <param name="param1" value="d:/install"/>
  </antcall>
</target>

<target name="default"
  depends="first,second"/>

<target name="subtask">
  <echo message="Param1 is now set to ${param1}"/>
</target>

2). You can do something similar with macrodef

3). Use AntContrib's <var> task:
http://ant-contrib.sourceforge.net/tasks/tasks/variable_task.html.

Running "ant default" will print out two different values for ${param1}.
On Wed, May 14, 2008 at 9:20 AM, <Irfan.Sayed@(protected):
> Hi All,
>
>
>
> I need to change the value of a specific property at run time. Can
> somebody please let me know how I can do that.
>
>
>
> Let's say the property name is "JAVA_HOME" and suppose I want to
change
> the value of that property to "d:\install"
>
>
>
> Please help.
>
>
>
> Regards,
>
> Irfan
>
>
>
>



--
--
David Weintraub
qazwart@(protected)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.