ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yves Dessertine <>
Subject Re: Make copy task fail if any destination file already exists?
Date Tue, 27 Jan 2009 17:37:38 GMT
I'll explain a bit more.

I have the following example build.xml file :

<project name="fooproject" default="usage" basedir=".">
	<target name="foo">
		<copy toDir="targetTree">
			<fileset dir="sourceTree" />

	<target name="usage">
		<echo>foo bar</echo>

Project layout looks like this :

 +--- build.xml
 +--- sourceTree
       +--- bar.txt
       +--- subdir
             +--- boo.bmp
             +--- boo1.bmp
 +--- targetDir
       +--- <any number of files here>
       +--- subdir
             +--- otherfile_only_in_target.txt
             +--- <any number of files here>
             +--- foo1.bmp         <== this already exists: error!

Its task is to copy any number of files from sourceDir to targetDir,
but throwing an error if any file to be copied already exists in

Here, I need the copy task to fail because subdir/foo1.bmp already
exists. It is possible to do such a thing w/ ant ?


Yves Dessertine

2009/1/26 Yves Dessertine <>:
> Thank you for your answer. the <available> task is interessting, but
> it isn't what I need. What I need is to copy a directory with
> subdirectories within another dir, with subdirs which might have the
> same name (to merge the contents of both), but while triggering an
> error if any file already exists in the target dir.
> This looks quite complicated to do with ant.
> 2009/1/26  <>:
>>>It is possible with Ant to make a copy task fail if any destination
>>>file already exists?
>>>I found no clue in the docs (noticed only the "failonerror" param in
>>>copy task ( and in
>>>the condition for the "fail" task, but nothing relevant IMHO).
>>>I know it would be possible to check the existance of an entire
>>>folder, but this isn't suitable for my project.
>> This is not <copy>s job.
>> Try <available>.
>> Jan
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:

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

View raw message