Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant is not able to delete some files on windows

Tags:

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?

like image 974
Honza Avatar asked Sep 16 '08 21:09

Honza


People also ask

Why can I not delete some files?

It's most likely because another program is currently trying to use the file. This can occur even if you don't see any programs running. When a file is open by another app or process, Windows 11/10 puts the file into a locked state, and you can't delete, modify, or move it to another location.

How do you force delete files that are in use?

In the command window, type the DEL /F file name command and press Enter to force delete the file that is in use.


2 Answers

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

like image 168
Shimi Bandiel Avatar answered Sep 27 '22 17:09

Shimi Bandiel


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.
like image 41
Craig Trader Avatar answered Sep 27 '22 16:09

Craig Trader