ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Olivier Gies <>
Subject Re: Use of the "If else" condition in ANT
Date Tue, 05 Feb 2008 07:37:42 GMT
Hi Uday,

Here are 2 solutions for an if-else in Ant:

1) Using you just use plain Ant 1.7, you can use the <condition> task, 
combining 'if' and 'unless' target attributes with target dependencies, 
as follows:

<target name="main" depends="A, B"/>

<target name="A" if="condition.ok" depends="eval.condition">

<target name="B" unless="condition.ok" depends="eval.condition">

<target name="eval.condition">
    <condition property="condition.ok">
        <resourcecount count="1" when="ge">
            <fileset file="text_file.txt">
                <contains text="String to search" casesensitive="false"/>

2) The way I do it: just use ant-contrib's implementation of 
<if><then><else> :) (see:


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

View raw message