将 Ant 构建器集成到 Eclipse:错误“变量引用空选择”
我的 Eclipse JDT 项目中有一些 Ant 任务,我想在每次编译之前执行这些任务,因此我在 Eclipse 构建器配置中添加了一个 Ant 构建器。作为构建文件的位置,我
${workspace_loc:${project_path}/build.xml}
在此处输入了“我不想拥有任何绝对路径”或项目名称。 Eclipse 配置是存储库的一部分,其他用户使用不同的文件系统布局和可能不同的 Eclipse 项目名称来检查它。例如,我的 Eclipse 工作区中通常有同一项目的多个工作副本,当然每个副本都有不同的项目名称。
这在大多数情况下都有效。但是,我有时会在对话框中收到以下错误消息:
构建期间发生错误。
在项目“MyProjectName”上运行构建器“集成外部工具生成器”时出错。
变量引用空选择:${project_path}
变量引用空选择:${project_path}
当 Eclipse 决定构建项目而 Package Explorer 中未选择项目资源时,似乎会发生这种情况。我可以通过在项目中创建一个虚拟文件、在 Eclipse 外部删除该文件、在 Eclipse 中选择它并按 F5 来重现它。 Eclipse 将注意到该文件不再存在,将其从 Package Explorer 中删除(因此不再选择任何内容),然后构建项目,并给出错误消息。
虽然每次编译都运行 Ant 任务并不是那么重要,但我不希望出现这样一个会让用户感到困惑的错误消息框。
那么,如何
- 以不同的方式引用 build.xml 文件以使问题消失、
- 解决问题或
- 抑制此特定错误的错误对话框?
任何帮助将不胜感激。我正在使用 Eclipse 3.7 (Indigo)。
I have some Ant tasks in my Eclipse JDT project that I want to execute before each compilation, so I added an Ant builder to my Eclipse builder config. As the location of the build file, I entered
${workspace_loc:${project_path}/build.xml}
I do not want to have any absolute paths, or the project name, here. The Eclipse configuration is part of the repository, and other users check this out with different file-system layouts and possibly different Eclipse project names. For example, I usually have several working copies of the same project in my Eclipse workspace, each of course with a different project name.
This works most of the time. However, I sometimes get the following error message in a dialog box:
Errors occurred during the build.
Errors running builder 'Integrated External Tool Builder' on project 'MyProjectName'.
Variable references empty selection: ${project_path}
Variable references empty selection: ${project_path}
This seems to happen when Eclipse decides to build the project while no resource of the project is selected in the Package Explorer. I can reproduce it by creating a dummy file in the project, deleting the file outside of Eclipse, selecting it in Eclipse and pressing F5. Eclipse will note that the file no longer exists, remove it from the Package Explorer (so nothing is selected anymore) and then build the project, giving the error message.
While it's not really that important that the Ant tasks are run for every compilation, I do not want to have such an error message box which will confuse users.
So how can I
- reference the build.xml file in a different way such that the problem goes away, or
- fix the problem, or
- suppress the error dialog for this particular error?
Any help would be appreciated. I'm using Eclipse 3.7 (Indigo).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然,在对变量(${workspace_loc})的引用内转换对变量(${project_path})的引用时存在问题。
您可以尝试使用 ${build_project} 变量,
我希望它有帮助。
Obviously, it has problems translating a reference to a variable (${project_path}) inside ... a reference to a variable (${workspace_loc}).
You could try the ${build_project} variable instead
I hope it helps.
您在 Eclipse 的 UI 中遇到了一些不便。逻辑表明,当您打开项目时,应填充有关打开的项目的变量。
但它们不是,因为由于错误或其他原因,代码在焦点转移到其他地方后杀死了它们。
因此,作为解决方法,您可以:
单击项目(文件夹图标)将填充变量
顺便说一句,我认为
${workspace_loc}${project_path}/build.xml
是可以的。You suffered some inconvenience in the Eclipse's UI. The logic dictates you that when you have opened a project, the variables regarding the opened project should be populated.
But they're not, because due to a bug or other reason, the code killed them after the focus moved elsewhere.
So as a workaround you can:
Clicking on the project (folder icon) will populate the variables
By the way, I think
${workspace_loc}${project_path}/build.xml
is ok.