Java Mailing List Archive

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

Apache Ant Archive

» Ant Users List
» Ant Developers List
Help with running different target based on user input?

Help with running different target based on user input?

2007-02-23       - By RADEMAKERS Tanguy
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

after a more careful reading of your mail ;P

<?xml version="1.0" encoding="UTF-8"?>
<project name="" default="script3" basedir=".">

   <target name="ask_script3">

       <input  message="Populate people tables with test data? (run
script3)"
               validargs="y,n"
               defaultvalue="n"
               addproperty="script3.run"/>

       <condition property="script3.run.required">
           <equals arg1="y" arg2="${script3.run}"/>
       </condition>
   </target>

   <target name="script3" depends="ask_script3"
if="script3.run.required">
       <echo message="running script 3..."/>
   </target>

</project>

-----

D:\scrap\ant>ant
Buildfile: build.xml

ask_script3:
   [input] Populate people tables with test data? (run script3)(y,n)
n

script3:

BUILD SUCCESSFUL
Total time: 2 seconds

D:\scrap\ant>ant
Buildfile: build.xml

ask_script3:
   [input] Populate people tables with test data? (run script3)(y,n)
y

script3:
    [echo] running script 3...

BUILD SUCCESSFUL
Total time: 1 second
D:\scrap\ant>


/t

>-----Original Message-----
>From: RADEMAKERS Tanguy
>Sent: Friday, February 23, 2007 2:25 PM
>To: 'Ant Users List'
>Subject: RE: Help with running different target based on user input?
>
>Hello James,
>
>You should put the input tasks within the target blocks that
>"consume" the inputted info:
>
>
><target name="script3">
>
>   <input  message="Populate people tables with test data?
>(run script3)"
>      validargs="y,n"
>      defaultvalue="n"
>      addproperty="foo"/>
>   <do something arg="${foo}/>
>
></target>
>
>check out the ant manual page for the input task for some examples.
>
>/t
>

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