I have a target in ant that deleted my temporary build directory. However, I was getting an error saying it couldn't delete the jar files contained there. If I let the build file run to its completion and then run 'ant clean' from the command line, then it works no problem. Its like there is still some sort of thread running against the jars the first time the clean target is called. DOes anyone know how to get around this?
I've seen a similar problem a few times, and have just assumed it's a Windows problem. There are times when I can't delete a file or directory through File Explorer either. Sometimes the problem goes away after awhile, and sometimes I have to log out and in again. It hasn't happened to me since I got a new machine, although I'm still using Windows 2000 Pro. Maybe I have a newer service pack? Here's some things to try: 1) Make sure no process is using the jar. Your app server should be shut down. 2) Make sure no process is using the directory. In particular, don't have any DOS command lines sitting in that directory. 3) Set failonerror to false. At least then the rest of your clean script can run.
I've had the same problem deleting files on Windows 2000. It seems like it takes Windows a little longer to realize that no process is using the file than it should. I generally don't run my clean target as part of the build, so I haven't run into problems with Ant as a result.