bizarrre ant copying

Thu, Jan 26, 2006

I had a problem with the Guanxi release system in that the build file wouldn’t copy empty directories:

<copy todir=“${sp.release.dir}/guanxi-sp-guard-bin-${release.version}”>   <fileset dir=“${tmp.dir}/${tmp.guanxi-sp-guard.bin.dir}”>     <include name=”*/.*“/>   </fileset> </copy>

According to the documentation on the copy task the includeEmptyDirs attribute is set to “true” by default, so the copy task will copy empty directories found by the fileset.

Nope! WEB-INF/logs, which is empty was never copied. It seems this line is not enough:

    <include name=”*/.*“/>

you’re better off using this instead:

    <include name=”**“/>

*/.* looks for files in directories. If there are files, the directory will be recreated. If there aren’t, i.e. an emtpy directory then there’s nothing to be copied as far as */.* is concerned, so the directory isn’t recreated.

** selects everything so empty directories are detected and copied.

comments powered by Disqus