I have an ant build that makes directories, calls javac and all the regular stuff. The issue I am having is that when I try to do a clean (delete all the stuff that was generated) the delete task reports that is was unable to delete some files. When I try to delete them manually it works just fine. The files are apparently not open by any other process but ant still does not manage to delete them. What can I do?
+1
A:
You don't say if your build is run as the currently logged on user. If not, the fact that explorer.exe or other process has the directory shown can cause it to be locked as well. But deleting it in that same explorer.exe process would succeed. Try Unlocker from http://ccollomb.free.fr/unlocker/ to see what processes have the files/directories locked.
BQ
2008-09-16 21:45:52
+1
A:
Is there something from the Ant process that is holding the files (or directory) open? This would cause the situation where you could delete them after running ant, but not during.
John Meagher
2008-09-16 21:47:11
+4
A:
It depends ...
- The Ant process doesn't have enough permissions to delete the files (typically because they were created by a different user, perhaps a system user). Try running your Ant script as an administrative user, using Run As.
- Windows is really bad at cleaning up file locks when processes die or are killed; consequently, Windows thinks the file is locked by a process that died (or was killed). There's nothing you can do in this situation other than reboot.
- Get better tools to inspect your system state. I recommend downloading the SysInternals tools and using them instead of the default Windows equivalents.
Craig Trader
2008-09-16 21:50:42
I agree with point 3. sysinternals handle.exe is invaluable as a command line tool to analyse this sort of problem.
Richard A
2008-10-24 01:30:19
+3
A:
I encountered this problem once. It was because the file i tried to delete was a part of a classpath for another task.
Shimi Bandiel
2008-09-17 08:47:56