You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Kai Hendry <he...@soltecsoftware.com.au> on 2005/09/26 06:32:17 UTC

if then

I want to do something quite simple, but with Ant it seems really difficult.

I want to check a property BAR exists. If it is not set, then set it to 
another property called FOO.

In shell:
FOO="blah"
if [ ! $BAR ]; then BAR=$FOO ; fi
echo $BAR $FOO

Right now I think I have to setup a separate target. Which is insane. 
Because I would need to call it somehow if the condition isn't met.

I got this far:

<target name="init">

        <condition property="isBARset">
            <isset property="BAR" />
        </condition>
<!-- how do I tastefully call THEN  ?? -->

</target>


<target name="THEN" if="isBARset">
 <property name="BAR"  value="${FOO}" />
</target>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: if then

Posted by Juergen Hermann <jh...@web.de>.
On Mon, 26 Sep 2005 07:41:14 +0200, Nicolas Vervelle wrote:

<property name="bar" value="${foo}"/>

done.if the requirement were a little more complicated, you'd use <condition>, 
only if all that fails, you need antcontrib (or a 3-target construction).

>Check ant-contrib, it's a library with several additional ant tasks, for 
>example <if> <then> <else>
>http://ant-contrib.sourceforge.net

>Kai Hendry wrote:

>> I want to do something quite simple, but with Ant it seems really 
>> difficult.
>>
>> I want to check a property BAR exists. If it is not set, then set it 
>> to another property called FOO.
>>
>> In shell:
>> FOO="blah"
>> if [ ! $BAR ]; then BAR=$FOO ; fi
>> echo $BAR $FOO


Ciao, Jürgen



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: if then

Posted by Nicolas Vervelle <ni...@steria.com>.
Check ant-contrib, it's a library with several additional ant tasks, for 
example <if> <then> <else>
http://ant-contrib.sourceforge.net

Kai Hendry wrote:

> I want to do something quite simple, but with Ant it seems really 
> difficult.
>
> I want to check a property BAR exists. If it is not set, then set it 
> to another property called FOO.
>
> In shell:
> FOO="blah"
> if [ ! $BAR ]; then BAR=$FOO ; fi
> echo $BAR $FOO
>
> Right now I think I have to setup a separate target. Which is insane. 
> Because I would need to call it somehow if the condition isn't met.
>
> I got this far:
>
> <target name="init">
>
>        <condition property="isBARset">
>            <isset property="BAR" />
>        </condition>
> <!-- how do I tastefully call THEN  ?? -->
>
> </target>
>
>
> <target name="THEN" if="isBARset">
> <property name="BAR"  value="${FOO}" />
> </target>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org