(sending this on to devel as well, since it is becoming a devel-like issue).
Thanks, Diane, you're the best. I guess I'll implement something on these lines, since I do use 1.5. However, unfortunately, I oversimplified the problem. My original problem was hard enough, but this is worse. What I'd really like to do is conditionally specify parameters within the call to a task, not an antcall. Thus: <stcheckout URL="STARTEAM:49201/Aproject/AView" username="auser" password="secret" rootlocalfolder="C:\dev\buildtest\co" forced="true" <if isset lbl> label = "${lbl}" </if> /> Well, that ain't gonna happen. You can't nest conditionals within attribute blocks. As the author of the stcheckout task, I suppose I could rewrite it to accept nested conditional elements, and I may yet do that. But here's a more ambitious idea, bacause I think this concept might be more generally useful: what if Ant had a way to specify that if the value of a task attribute were undefined, ANT WOULDN'T PROCESS THE ATTRIBUTE, instead it would strip the attribute out of the task call. So this then becomes something like this: <stcheckout URL="STARTEAM:49201/Aproject/AView" username="auser" password="secret" rootlocalfolder="C:\dev\buildtest\co" forced="true" label = "$${lbl}" /> meaning "If ${lbl} is not defined no label attribute gets passed to the task." I think this might offer vast potential to write more flexible scripts without having to copy similar looking code into multiple if-then-else blocks. Imagine the combinatorial mess if two or three attributes in a task were needed to be made conditionally. There are many tasks that allow a large number of optional attributes. This would make using them easier. Steve -----Original Message----- From: Diane Holt [mailto:[EMAIL PROTECTED]] Sent: Thu 3/7/2002 7:55 PM To: Ant Users List Cc: Subject: Re: How to conditionally add params to an <antcall> --- "Tenchi-kun (Elliott)" <[EMAIL PROTECTED]> wrote: > <target name="Target1.A" if="kung"> > <antcall target="Target1"> > <param name="foo" value="${foo}" /> > <param name="kung" value="fu" /> > </antcall> > </target> > <target name="Target1.B" unless="kung"> > <antcall target="Target1"> > <param name="foo" value="${foo}" /> > </antcall> > </target> The drawback to doing it this way is that there's no real connection between the two targets (other than that they both test on the same property). In other words, you'd need to call them both independently. If you want to go with two targets, it'd probably be better to have one target that depends on the alternative, which, if it runs, sets a property that the dependent target tests on: <target name="callTarget1" depends="callT1WithKung" unless="antcall.done"> <antcall target="target1"> <param name="foo" value = "bar"/> </antcall> </target> <target name="callT1WithKung" if="keyProp"> <antcall target="target1"> <param name="foo" value = "bar"/> <param name="kung" value = "fu"/> </antcall> <property name="antcall.done" value="true"/> </target> Alternatively, you could go with the ant-contrib <if> task: <taskdef resource="net/sf/antcontrib/antcontrib.properties"/> <target name="callTarget1"> <if> <isset property="keyProp"/> <then> <antcall target="target1"> <param name="foo" value = "bar"/> <param name="kung" value = "fu"/> </antcall> </then> <else> <antcall target="target1"> <param name="foo" value = "bar"/> </antcall> </else> </if> </target> Note: condition <isset> is only available with 1.5alpha; to use this approach with 1.4.1 use <equals> with 'arg2="$$keyProp"' (and reverse the logic). I've just picked up all the ant-contrib tasks today and put them in a jar, so if you'd like them, let me know. Diane ===== ([EMAIL PROTECTED]) __________________________________________________ Do You Yahoo!? Try FREE Yahoo! Mail - the world's greatest free email! http://mail.yahoo.com/ -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>