ant delete can not successful solution
今天在写ant脚本的时候发现一个del删除一个lib不成功,怀疑是什么占用了,但是手动是能删除的。
g了一下,果然很多人碰到过(不得不承认,技术搜索方面谷哥比度娘给力太多了):
Chances are that your build is using that JAR file in a classpath to <javac> or some other task, and Windows JVM locks JAR files from being deleted.
是自己hack了classpath的路径,所以JVM锁住了,无法正常删除。
Solution:
1) Ant is written in Java! That means it uses classpsath. That means if my .jar file is in the classpath than Ant's JVM is probably preloading it, and if its in use, then OF COURSE you can't delete it.
Sure enough, my classpath was ".;c:\jdk;yadda yadda" I removed the ".;" and it works every time!
2) 最简单的方法: 加上“deleteonexit”
deleteonexit | Indicates whether to use File#deleteOnExit() if there is a failure to delete a file, this causes the jvm to attempt to delete the file when the jvm process is terminating. Since Ant 1.6.2 |
posted on 2012-02-28 15:47 lightideal 阅读(275) 评论(0) 编辑 收藏 举报