ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Murdoch" <>
Subject RE: Newbie help <condition>
Date Thu, 27 Dec 2001 21:43:50 GMT


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

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

<target name="conditional-local-cleanup" depends="skip-local-cleanup"
    <antcall target="local-cleanup"/>

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


> -----Original Message-----
> From: John Volkar []
> 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:   <>
> For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message