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?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
I am seeing problems like this way too often since I switched to Microsoft Windows 10. Renaming the file immediately before removing it solved it for me:
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.
Ant versions before 1.8.0 have a bug which leads to random errors during delete operation. Try using Ant 1.8.0 or newer.
You can see the bug details here https://issues.apache.org/bugzilla/show_bug.cgi?id=45960
I've been having this problem a lot lately and it's random. One time it works, the next time it doesn't work. I'm using NetBeans (in case that matters) and I've added a lot of extra tasks to build.xml. I was having this problem in the -post-jar task. It would happen when I call unjar on the file, then delete. I suspect that NB is trying to scan the jar and this causes the lock on it.
What worked for me is to immediately rename the jar at the start of -post-jar and add a .tmp extension to it. Then I call unjar on the temp file. When I'm done I rename back to the desired jar name.
I faced the same problem.
I didn't have any classpath set to or antivirus running on my machine.
However, the ANT version I was using was 32 bit and the JDK I installed was 64 bit.
I installed a 32 bit JDK and the issue was resolved.
You need to delete it manually in Windows. It worked for me. (Usually the files to be deleted are older versions of jar.. For example: if there exists httpcore.4.2.5.ja5r and httpcore.4.3.jar, it will try to delete 4.2.5.jar)