使用eclipse时,如何从项目属性中的库中引用ANT HOME?

时间:2023-02-05 11:45:38

In our code base we have a dependency on the ant version used in eclipse.

在我们的代码库中,我们依赖于eclipse中使用的ant版本。

In the the ant.jar has been set up as a library which the project uses

在ant.jar中已经设置为项目使用的库

This is a pain when moving versions of eclipse as the Ant plugin folder name changes (although I see it is now just called Ant1.7)

当Ant插件文件夹名称发生变化时,移动eclipse版本时会很痛苦(尽管我看到它现在只称为Ant1.7)

Is there a way to access eclipses reference to ANT Home which appears in the workspace preferences so that I don't have to explicitly set a variable that has the hard coded path to the ant plugins folder

有没有办法访问出现在工作区首选项中的eclip引用ANT Home,这样我就不必显式设置一个具有ant plugins文件夹硬编码路径的变量

5 个解决方案

#1


1  

Your project should not have a dependency on eclipse's version of Ant in the first place, you should keep your own version so as to decouple your project from eclipse. What if a developer or yourself decides to use intelliJ?

你的项目首先不应该依赖于eclipse的Ant版本,你应该保留自己的版本,以便将你的项目与eclipse分离。如果开发人员或您自己决定使用intelliJ怎么办?

Although i don't know what the nature of your project is, i would have thought all dependencies should be added to your projects lib directory or something similar.

虽然我不知道你的项目的性质是什么,但我认为应该将所有依赖项添加到你的项目lib目录或类似的东西。

#2


0  

One possible suggestion would be to :

一个可能的建议是:

  • transform your project into a plugin project (properties on your project / PDE tools / convert Project to Plug-in Projects...) and
  • 将您的项目转换为插件项目(项目中的属性/ PDE工具/将项目转换为插件项目......)和

  • add to its dependencies the 'ant' required plugin.
  • 将'ant'所需的插件添加到其依赖项中。

That would be easier to manage when you change the version of eclipse.

当你改变eclipse的版本时,这将更容易管理。

#3


0  

Have you considered installing Ant separately, creating an environment variable, and then referencing the location via the ANT_HOME environment variable within your Ant build.xml?

您是否考虑过单独安装Ant,创建环境变量,然后通过Ant build.xml中的ANT_HOME环境变量引用该位置?

#4


0  

From within your eclipse, on the package explorer view, right click on the specific project and build path.

在Eclipse中,在包浏览器视图中,右键单击特定项目和构建路径。

Move into the Libraries tab and select the "Add Variable..." button. From here you'll see that is where the JDK system libraries path, maven(if you're using it, tomcat, eetc...) If ANT_HOME doesn't appear, you can add it by clicking the Configure Variables... button. From this moment, the ANT_HOME path will be considered in the build path of the project.

进入Libraries选项卡并选择“Add Variable ...”按钮。从这里你可以看到JDK系统库路径,maven(如果你正在使用它,tomcat,eetc ......)如果没有出现ANT_HOME,你可以点击配置变量来添加它...按钮。从这时起,ANT_HOME路径将在项目的构建路径中考虑。

Hope it helps.

希望能帮助到你。

Carlos

#5


0  

Your ant home is available in the property ${ant.home}

您的蚂蚁之家位于酒店$ {ant.home}

E.g:

<echo> ${ant.home} </echo>

Gives the following on my machine:

在我的机器上提供以下内容:

 [echo]  D:\java\eclipse_3.4_jee\plugins\org.apache.ant_1.7.0.v200803061910 

#1


1  

Your project should not have a dependency on eclipse's version of Ant in the first place, you should keep your own version so as to decouple your project from eclipse. What if a developer or yourself decides to use intelliJ?

你的项目首先不应该依赖于eclipse的Ant版本,你应该保留自己的版本,以便将你的项目与eclipse分离。如果开发人员或您自己决定使用intelliJ怎么办?

Although i don't know what the nature of your project is, i would have thought all dependencies should be added to your projects lib directory or something similar.

虽然我不知道你的项目的性质是什么,但我认为应该将所有依赖项添加到你的项目lib目录或类似的东西。

#2


0  

One possible suggestion would be to :

一个可能的建议是:

  • transform your project into a plugin project (properties on your project / PDE tools / convert Project to Plug-in Projects...) and
  • 将您的项目转换为插件项目(项目中的属性/ PDE工具/将项目转换为插件项目......)和

  • add to its dependencies the 'ant' required plugin.
  • 将'ant'所需的插件添加到其依赖项中。

That would be easier to manage when you change the version of eclipse.

当你改变eclipse的版本时,这将更容易管理。

#3


0  

Have you considered installing Ant separately, creating an environment variable, and then referencing the location via the ANT_HOME environment variable within your Ant build.xml?

您是否考虑过单独安装Ant,创建环境变量,然后通过Ant build.xml中的ANT_HOME环境变量引用该位置?

#4


0  

From within your eclipse, on the package explorer view, right click on the specific project and build path.

在Eclipse中,在包浏览器视图中,右键单击特定项目和构建路径。

Move into the Libraries tab and select the "Add Variable..." button. From here you'll see that is where the JDK system libraries path, maven(if you're using it, tomcat, eetc...) If ANT_HOME doesn't appear, you can add it by clicking the Configure Variables... button. From this moment, the ANT_HOME path will be considered in the build path of the project.

进入Libraries选项卡并选择“Add Variable ...”按钮。从这里你可以看到JDK系统库路径,maven(如果你正在使用它,tomcat,eetc ......)如果没有出现ANT_HOME,你可以点击配置变量来添加它...按钮。从这时起,ANT_HOME路径将在项目的构建路径中考虑。

Hope it helps.

希望能帮助到你。

Carlos

#5


0  

Your ant home is available in the property ${ant.home}

您的蚂蚁之家位于酒店$ {ant.home}

E.g:

<echo> ${ant.home} </echo>

Gives the following on my machine:

在我的机器上提供以下内容:

 [echo]  D:\java\eclipse_3.4_jee\plugins\org.apache.ant_1.7.0.v200803061910