eclipse ant build failed 无法删除文件lib\build
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16945441/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
eclipse ant build failed Unable to delete file lib\build
提问by ken
When running certain build.xml targets, the clean has a hit or miss on deleting the ivy jar directory. The "locked" files are by eclipse, using explorer on the directory or rerunning ant from eclipse refuses to delete it until restart of eclipse. This is very time consuming.
Some reason eclipse is holding on to this files after running ant build/clean.
It's not all the projects and only at certain times for unknown reasons.
当运行某些 build.xml 目标时,clean 会在删除 ivy jar 目录时遇到问题。“锁定”文件由 eclipse 提供,在目录上使用资源管理器或从 eclipse 重新运行 ant 拒绝删除它,直到 eclipse 重新启动。这是非常耗时的。在运行 ant build/clean 后,eclipse 保留此文件的某些原因。
这不是所有的项目,只是在某些时候出于未知原因。
There is this existing discussion. Eclipse won't delete files
有这个现有的讨论。 Eclipse 不会删除文件
but it doesn't answer the question for me about how to get eclipse to run ant without having to restart every time.
但它并没有回答我关于如何让 eclipse 运行 ant 而不必每次都重新启动的问题。
Is there a way to use eclipse -console to see the file handles what is holding it? or does somebody know a root cause to why eclipse/ant/ivy wont let go of these targets after a build or two (1st time after a fresh start of Eclipse works fine) but then some subsequent ant build after that it becomes unhappy.
有没有办法使用 eclipse -console 来查看文件处理的是什么?或者有人知道为什么 eclipse/ant/ivy 在一两次构建后不会放弃这些目标的根本原因(Eclipse 重新启动后的第一次工作正常)但随后的一些 ant 构建之后它变得不开心。
In my case it is eclipse which is locking the file for sure. Restarting Eclipse is not a solution. Otherwise, I'll just go back to a command line window. I've tried setting the run in same jvm, and all sorts of settings.
就我而言,它是 eclipse,它肯定会锁定文件。重新启动 Eclipse 不是解决方案。否则,我将返回到命令行窗口。我试过在同一个 jvm 中设置运行,以及各种设置。
Do I need to debug the eclipse plugins? Is there an easier way to find out what's not release the lock within Eclipse and it's plugins? This is my first time ever to see this and I suspect it's IVY causing it.
我需要调试 eclipse 插件吗?有没有更简单的方法来找出 Eclipse 中没有释放锁定的内容及其插件?这是我第一次看到这个,我怀疑是 IVY 引起的。
Running juno, ivy, spring, ant and have the problem when run-as Ant Build from Eclipse that clean is unable to delete the lib/build directory of the artifacts.
运行 juno、ivy、spring、ant 并在从 Eclipse 以 Ant Build 运行时出现问题,clean 无法删除工件的 lib/build 目录。
eclipse.buildId=M20130204-1200
java.version=1.6.0_43
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.jee.product
!ENTRY org.apache.ivyde.eclipse 1 0 2013-06-04 11:36:50.344
!MESSAGE starting IvyDE plugin
ant target:
蚂蚁目标:
<target name="clean-retrieved" >
<delete includeemptydirs="true" >
<fileset dir="${basedir}">
<include name="lib/**" />
</fileset>
</delete>
</target>
ERROR:
错误:
clean-retrieved:
BUILD FAILED
C:\scripts\common-build-targets.xml:238: Unable to delete file C:\scripts\lib\build\annotations-1.3.8.jar <<just first jar file in directory..
回答by chamakits
This occurs when a process is using said file. I've had this issue happen usually when the program that uses said jar is still running. Verify that you aren't still running your program in eclipse. The easiest way to see that visually is to see this:
当进程正在使用所述文件时会发生这种情况。当使用所述 jar 的程序仍在运行时,我通常会遇到这个问题。验证您没有仍在 eclipse 中运行您的程序。直观地看到它的最简单方法是看到这个:
That red square (stop button) being enabled means that your program is still running. If you press that, you'd be stopping your process. However, if your program wasn't running it'd look something like this:
启用红色方块(停止按钮)意味着您的程序仍在运行。如果你按下那个,你就会停止你的过程。但是,如果您的程序没有运行,它看起来像这样:
Since the "stop" button isn't enabled, it means the program isn't running. However, it's possible that there are other processes also running, other than the one shown at the time. To see that, you can see a "computer screen" icon on this next screenshot:
由于“停止”按钮未启用,这意味着程序没有运行。但是,可能还有其他进程也在运行,而不是当时显示的进程。要看到这一点,您可以在下一个屏幕截图中看到“计算机屏幕”图标:
That computer screen being enabled signifies that you have ran multiple programs/processes. Clicking on the down arrow lets you change to other programs. Check to see if those are running, and stop those also. An easier way is to press the double X's symbol. That will close every section related to a finished process, and might show you one that is still running, that you can stop. Continue pressing the double x and the stop button until all are gone, and you should be able to delete your jar, and build without issue.
启用该计算机屏幕表示您已运行多个程序/进程。单击向下箭头可让您更改为其他程序。检查它们是否正在运行,并停止它们。更简单的方法是按双 X 符号。这将关闭与已完成流程相关的每个部分,并可能向您显示仍在运行的部分,您可以停止。继续按双 x 和停止按钮,直到一切都消失了,你应该能够删除你的 jar,并且没有问题地构建。
回答by user3140352
Execute below from command line
从命令行在下面执行
c:\path_to_eclipse\eclipse.exe -clean
c:\path_to_eclipse\eclipse.exe -clean
回答by Cliff
This seems to be a problem with the ant plugin. In my case, when the plugin parses the build.xml file, it opens file handles to all jars mentioned in the classpath of my taskdef elements. As soon as an action causes the ant plugin to parse the build.xml file it acquires file handles to these jars and won't release them until eclipse is closed. I consider this a bug in the ant plugin -- it should only hold open file handles while the target is being run.
这似乎是ant插件的问题。就我而言,当插件解析 build.xml 文件时,它会打开我的 taskdef 元素的类路径中提到的所有 jar 的文件句柄。一旦某个操作导致 ant 插件解析 build.xml 文件,它就会获取这些 jar 的文件句柄,并且在 eclipse 关闭之前不会释放它们。我认为这是 ant 插件中的一个错误——它应该只在目标运行时保存打开的文件句柄。
I have found no work-around for this problem other than reverting to command line usage of ant instead of the eclipse plugin. The entire build could be restructured to put duplicate copies of these jars elsewhere and update the taskdef targets, but that's a serious hack. People on the team with mac or linux don't see this because those allow you to delete a file that has an open file handle. Can debate the merits of that elsewhere.
除了恢复到 ant 而不是 eclipse 插件的命令行使用之外,我没有找到解决此问题的方法。可以重构整个构建以将这些 jar 的重复副本放在其他地方并更新 taskdef 目标,但这是一个严重的问题。使用 mac 或 linux 的团队中的人看不到这一点,因为它们允许您删除具有打开文件句柄的文件。可以在别处讨论它的优点。
回答by thonnor
I'm going to chip in here (I know this is an old post)
我要在这里凑钱(我知道这是一个旧帖子)
My Eclipse/Ant combo was working fine but then I created a new workspace which looked ok but refused to remove the dist/*jars
during a clean.
我的 Eclipse/Ant 组合工作正常,但后来我创建了一个新的工作区,它看起来不错,但dist/*jars
在清理过程中拒绝删除。
I tried removing them via Windows Explorer which claimed that they were already open in Eclipse.
我尝试通过 Windows 资源管理器删除它们,声称它们已经在 Eclipse 中打开。
An Eclipse restart worked but was time consuming.
Eclipse 重启有效,但很耗时。
My solution - I created a new workspace and re-imported my projects to it.
我的解决方案 - 我创建了一个新工作区并将我的项目重新导入其中。
My guess - some corruption within my original workspace.
我的猜测 - 我原来的工作区中有一些损坏。
回答by user2718671
I had that problem too. It was caused because of a denied permission for a folder. I couldn't switch owner of the folder. What solved the problem was to install Lockhunterunlock the folder, deleting and recreating it.
我也有这个问题。这是由于文件夹的权限被拒绝引起的。我无法切换文件夹的所有者。解决问题的是安装Lockhunter解锁文件夹,删除并重新创建它。