solution1:

<target name="check-abc">
<available file="abc.txt" property="abc.present"/>
</target>

<target name="do-if-abc" depends="check-abc" if="abc.present">
...
</target>




solution2

One option would be to use an appropriate <fileset> and loop over it 
with <for>, but <for> requires ant-contrib. 



<property name="syncreport.exists" value="false" />
<property name="syncreport.exists" value="true" />




Hi Francis Galiegue  & Gilbert ,

Thanks a lot for replying. I got it done taking inputs from all your
comments.
Below is the code that is working fine.


<target name="check-abc">
<for param="file">
  <path>
    <fileset id="file.exist" dir="." includes="*.txt"/>
  </path>
<sequential>
<echo> file list::: @{file} </echo>
<available file="@{file}" property="abc.present"/>
</sequential>
</for>
</target>

<target name="do-if-abc" depends="check-abc" if="abc.present">
<echo> true</echo>
</target>

Thanks a lot again for helping.

Regards
Sri


Francis Galiegue-4 wrote:
> 
> On Thu, Oct 29, 2009 at 13:00, cvsusr <sp...@rediffmail.com> wrote:
>>
>> I tried this.. this is printing the *.txt file that exist in the current
>> folder
>> <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
>> <for param="file">
>>  <path>
>>    <fileset dir="." includes="*.txt"/>
>>  </path>
>> <sequential>
>> <echo> file list::: @{file} </echo>
>> </sequential>
>> </for>
>>
>>
>> Now i need to check if the file exist then perform the target..  Do i
>> need
>> to use condition for this??
>>
> 
> Well, no, since if there's no file, there will be no iteration at
> all... Hence my suggestion. A fileset can be empty.
> 
> -- 
> 
> Francis Galiegue
> ONE2TEAM
> Ingénieur système
> Mob : +33 (0) 683 877 875
> Tel : +33 (0) 178 945 552
> f...@one2team.com
> 40 avenue Raymond Poincaré
> 75116 Paris
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
> For additional commands, e-mail: user-h...@ant.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Alternative-for-%3Cavailable%3E-taks-to-check-a-pattern-of-file-existence-tp26110901p26114255.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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

Reply via email to