Cyriaque Dupoirieux wrote:
>
> Hello,
>
> I want to copy a file, but this file may not exist.
> <copy file="my.properties" todir="codes"/>
> And if the file doesn't exist, I have the following message :
> [copy] Could not find file my.properties to copy.
>
> I have the same problem with a directory :
> <copy todir="codes/images" >
> <fileset dir="sources/images"/>
> </copy>
> The error message is :
> D:\build.xml:133: sources\images not found.
>
> How can I test the existance of files or directories ? (available
> target ?)
>
> Thanks & Regards,
>
<target name="isAvailable">
<available file="yourFile.txt"
property="yourFile.txt.available"/>
</target>
<target name="copy" depends="isAvailable"
if="yourFile.txt.available">
<copy file="yourFile.txt" tofile="yourFile.txt.backup"/>
</target>
Insert these two targets to your build.xml.
call
> ant copy
it will only do a backup if the property yourFile.txt.available
is set. the Property yourFile.txt.available will be set via
target isAvailable (if the file yourFile.txt is present)
Hope that helps. Works fine foe me
--
_______________________________________________________________
Martin Gerlach Distributed Systems
phone: +49 (0)221 250-1046 mailto:[EMAIL PROTECTED]
fax: +49 (0)221 250-1588 http://www.planb-media.de
plan_b media ag Coloneum
Butzweilerstr. 255 D-50829 Cologne, Germany
_______________________________________________________________