将 Ant builder 集成到 Eclipse 中:错误“变量引用为空选择" [英] Integrate Ant builder into Eclipse: Error "Variable references empty selection"

查看:24
本文介绍了将 Ant builder 集成到 Eclipse 中:错误“变量引用为空选择"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Eclipse JDT 项目中有一些 Ant 任务,我想在每次编译之前执行这些任务,因此我在我的 Eclipse 构建器配置中添加了一个 Ant 构建器.作为构建文件的位置,我输入了

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}

不想想要在这里有任何绝对路径或项目名称.Eclipse 配置是存储库的一部分,其他用户使用不同的文件系统布局和可能不同的 Eclipse 项目名称来检查它.例如,我的 Eclipse 工作区中通常有同一个项目的多个工作副本,当然每个副本都有不同的项目名称.

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:

构建过程中出现错误.
在项目MyProjectName"上运行构建器集成外部工具构建器"时出错.
变量引用空选择:${project_path}
变量引用空选:${project_path}

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}

这似乎发生在 Eclipse 决定构建项目而在 Package Explorer 中没有选择项目资源时.我可以通过在项目中创建一个虚拟文件,在 Eclipse 之外删除文件,在 Eclipse 中选择它并按 F5 来重现它.Eclipse 会注意到该文件不再存在,将其从包资源管理器中删除(因此不再选择任何内容),然后构建项目,并给出错误消息.

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.

虽然对于每次编译都运行 Ant 任务并不是那么重要,但我不希望有这样一个会让用户感到困惑的错误消息框.

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.

那我怎么办

  • 以不同的方式引用 build.xml 文件,以便问题消失,或者
  • 解决问题,或
  • 抑制此特定错误的错误对话框?

任何帮助将不胜感激.我使用的是 Eclipse 3.7 (Indigo).

Any help would be appreciated. I'm using Eclipse 3.7 (Indigo).

推荐答案

显然,它在转换对变量 (${project_path}) 内部的引用 (${project_path}) 的引用时存在问题...对变量的引用 (${workspace_loc}).

Obviously, it has problems translating a reference to a variable (${project_path}) inside ... a reference to a variable (${workspace_loc}).

你可以试试 ${build_project} 变量

You could try the ${build_project} variable instead

${build_project:/build.xml}

希望能帮到你.

这篇关于将 Ant builder 集成到 Eclipse 中:错误“变量引用为空选择"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆