如何在 Eclipse .classpath 文件中使用环境变量? [英] How do I use environment variables in an Eclipse .classpath file?

查看:47
本文介绍了如何在 Eclipse .classpath 文件中使用环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 中,我有一个指向 C:\Program Files\MyExternalLibRoot 的环境变量 EXTERNAL_LIB_ROOT.在另一台机器上,它可能指向 C:\ExternalLibs.

In Windows I have an environment variable EXTERNAL_LIB_ROOT that points to C:\Program Files\MyExternalLibRoot. On another machine, it may point to C:\ExternalLibs.

在 ant build.xml 文件中,我会使用:

In an ant build.xml file I would use:

<pathelement location="${env.EXTERNAL_LIB_ROOT}/path/to/jar.jar"/>

如何设置 Eclipse 项目 .classpath 文件以使用 EXTERNAL_LIB_ROOT 环境变量?是否可以让 Eclipse 使用上述环境变量自动生成 build.xml 文件?

How do I set up an Eclipse project .classpath file to use the EXTERNAL_LIB_ROOT environment variable? Is it possible to have Eclipse auto generate the build.xml file using the environment variable as above?

推荐答案

不是环境变量,但是可以设置Eclipse 中的路径变量.路径变量是每个工作区的.因此,它们是在工作空间内的多个项目之间共享公共位置的便捷方式.我已经使用它们在项目之间共享一个 lib 文件夹.

Not an environment variable, but you can set up a Path Variable in Eclipse. Path variables are per-workspace. They are therefore a convenient way of sharing a common location among multiple projects within a workspace. I have used them to share a lib folder among projects.

要创建路径变量(第一次,或重新使用项目中的现有变量):

To create a Path Variable (either for the first time, or to re-use an existing one in a project):

  • 文件/新建/文件夹
    • 打开新建文件夹"对话框
    • 打开选择路径变量"对话框

    在您的情况下,创建一个名为 EXTERNAL_LIB_ROOT 的变量.

    In your case, create a variable called EXTERNAL_LIB_ROOT.

    (顺便说一句,我建议不要从您的 .classpath 生成 build.xml,而是从您的 build.xml 创建 .classpath 和 .project.)

    (BTW, rather than generating a build.xml from your .classpath, I would suggest instead creating .classpath and .project from your build.xml.)

    这篇关于如何在 Eclipse .classpath 文件中使用环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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