ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacob, Anil - MWT" <Jacob.A...@menlolog.com>
Subject RE: Setting property for all targets
Date Fri, 30 Apr 2004 21:14:50 GMT
Here is the snippet:

<target name="input">
<input message="Enter your value:" addproperty="value"/>
<echo message="value is set to:${value}"/>
</target>

<target name="Test" depends="input">
<echo message="You have entered ${value}">
</target>

<target name="Testvalue">
<echo message="You have entered ${value}">
</target>

-----
1st Run
----
ant -f buildtest.xml value
Buildfile: buildtest.xml

input:
    [input] Enter your value:
anil
     [echo] value is set to:anil

value:
     [echo] You have entered anil

BUILD SUCCESSFUL
Total time: 2 seconds
--------------------------------------------
2nd Run
------
ant -f buildtest.xml Testvalue
Buildfile: buildtest.xml

Testvalue:
     [echo] You have entered ${value}

BUILD SUCCESSFUL
Total time: 0 seconds

--------------------------------
3rd Run
--
 ant -f buildtest.xml -Dvalue=anil Testvalue
Buildfile: buildtest.xml

Testvalue:
     [echo] You have entered anil

BUILD SUCCESSFUL
Total time: 0 seconds

My question is how can I set ${value} in the 2nd run without having a
depend on the input target and without running it like in the 3rd run.
How can the input target set the value of $value for all targets without
invoking it again and again.

Anil


-----Original Message-----
From: Matt Benson [mailto:gudnabrsam@yahoo.com] 
Sent: Friday, April 30, 2004 12:38 PM
To: Ant Users List
Subject: RE: Setting property for all targets


I'm not seeing enough context to be able to tell what
scenario you want to support.  If you can provide a
snippet representative of all three targets in
question, plus the command line you would -expect- to
be able to use, we might be able to take this further.

-Matt

--- "Jacob, Anil - MWT" <Jacob.Anil@menlolog.com>
wrote:
> I may be doing something wrong.
> Here is what I am doing -
> 
> Instead of using -Dproperty= option I have a target
> which takes input
> from the user
> <target name="input">
> <input message="Enter your value:"
> addproperty="value"/>
> <echo message="value is set to:${value}"/>
> </target>
> 
> Then I have a couple of targets where targetA
> depends on target
> input(above), the second targetB depends on targetA.
> I see that the
> ${value} property is set in targetA but not in
> targetB which fails
> because of this.
> 
> However If I run ant like this:
> 
> > ant  -Dvalue=xxxx targetB
> it works fine.
> 
> Anil
> 
> -----Original Message-----
> From: Matt Benson [mailto:gudnabrsam@yahoo.com]
> Sent: Friday, April 30, 2004 9:43 AM
> To: Ant Users List
> Subject: RE: Setting property for all targets
> 
> 
> --- "Jacob, Anil - MWT" <Jacob.Anil@menlolog.com>
> wrote:
> > Yes,
> > When you set the -Dproperty=value cmd option the
> > property is available
> > to all tasks. How can the same option be used with
> > an input task so that
> > when the input task executes the property set is
> > available to all tasks
> > for the project.
> 
> How can it not?  As long as you're talking about a
> single Ant invocation, that's what you get for free.
> 
> Properties last throughout the life of the project,
> not the target.
> 
> -Matt
> 
> 
> 	
> 		
> __________________________________
> Do you Yahoo!?
> Win a $20,000 Career Makeover at Yahoo! HotJobs
> http://hotjobs.sweepstakes.yahoo.com/careermakeover 
> 
>
---------------------------------------------------------------------
> 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
> 



	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

---------------------------------------------------------------------
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