Ant is not able to delete some files on windows

I encountered this problem once. It was because the file i tried to delete was a part of a classpath for another task.


Using Ant Retry task has helped me. I've just wrapped it around the Delete Task.


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.