Thanks! I totally missed the if="" and unless="" attributes of the the <target> element while reading the manual.
Thanks a bunch. John Volkar -----Original Message----- From: Adam Murdoch [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 27, 2001 4:44 PM To: Ant Users List Subject: RE: Newbie help <condition> Hi, You have a few options. Simplest is to put the condition on the "local-cleanup" target itself: <target name="local-cleanup" if="call_local_cleanup"> ... </target> The contents of the local-cleanup target will only be executed if "call_local_cleanup" is set (to any value, including values like "false"). With this approach, you miss out on the log message - which might be worth it for the sake of a simpler build file. Alternatively, you can create two extra targets - one for each of the branches of the "if": <target name="skip-local-cleanup" unless="call_local_cleanup"> <log>...</log> </target> <target name="conditional-local-cleanup" depends="skip-local-cleanup" if="call_local_cleanup"> <antcall target="local-cleanup"/> </target> Then use "conditional-local-cleanup" instead of "local-cleanup" in depend lists and <antcall>s. You could possibly combine the 2 approaches, and roll "conditional-local-cleanup" up into "local-cleanup". Adam > -----Original Message----- > From: John Volkar [mailto:[EMAIL PROTECTED]] > Sent: Friday, 28 December 2001 3:55 AM > To: Ant Users List > Subject: Newbie help <condition> > > > Okay, I give, how do I conditionally execute a <task>? (actually > in my case > <antcall> a <target>???) > > Say I have (somewhere previously) defined: > <property name="call_local_cleanup" value="true"> > This might be specified via the command line or in a calling target. > > The target "local-cleanup" does (potentially) horrid things to the users > basedir, notibly things like a mass delete and re-get from > version control. > (which is slow and painful, therefore user may desire to skip this.) > > What I want to do is something like... > > if ${call_local_cleanup}==true > <antcall target="local-cleanup"> > else > <echo message="skipping local-cleanup"> > > > How would I do something like this? > > Thanks in advance... > John Volkar > > > ps: I'm leaving for the day, time to visit the liquor store for New Years > Eve supplies, so I'll hope to see a response tomorrow... thanks. > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
