I use an ant script to build an EAR file. This script runs fine since years on Unix systems. On Windows, an exception happens with the following message : D:\DevWebSDI02\NE00P\UEDIE\bin\Z55C02.xml:325: IOException in D:\DevWebSDI02\wlo\DWRDZ82TEI\EAR\online\Agora\z55cnxtest\WEB-INF\web.xml - java.io.IOException:Failed to delete D:\DevWebSDI02\wlo\DWRDZ82TEI\EAR\online\Agora\z55cnxtest\WEB-INF\web.xml while trying to rename D:\DevWebSDI02\wlo\DWRDZ82TEI\EAR\online\Agora\z55cnxtest\WEB-INF\rep371926229.tmp The line 325 and followings are : <replace file="${ear.dir}${file.separator}$..." propertyfile="${scriptsdir}$..."> <replacefilter token="@@@@ROLE_USER@@@@" property="ROLE_USER_${templ}" /> <replacefilter token="@@@@AUTH_METHOD@@@@" property="AUTH_METHOD_${templ}" /> </replace> The ant version used is Eclipse's one org.apache.ant_1.7.0.v200706080842 The same problem happens with Ant 1.7.1. My workaround is to call System.gc() when entering in the replace method of the file FileUtils.java But it has an effect on speed execution. I had also found some posts about this problem and Stefan Bodewig was talking about relations between JVM and Windows file systems but unfortunately, I cannot retrieve these posts.
I've looked through my archives of the last two years but don't find the post you talked about, it may have been older than that. Anyway. Ant has just closed the file (because it had to read it) and it may very well be that the JVM hasn't released the file handle to the operating system yet (and your call to GC made it release the handle). We have had similar cases in <delete> where we explicitly insert a System.gc() on Windows and retry after sleeping for a 10 millis if a call to delete() fails - we could introduce the same in replace as well.
should work better with svn trunk revision 703151.
I'll test as soon as possible. Thanks
correction seems good but I can't access to Apache SVN repositories from my company.
you can download a snapshot of Ant's trunk from http://svn.apache.org/snapshots/ant/
I've just made a test. The bug is fixed.