Eclipse 中 Ant 的动态 basedir [英] Dynamic basedir for Ant in Eclipse

查看:25
本文介绍了Eclipse 中 Ant 的动态 basedir的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题可能不是最好的,所以让我解释一下我想要做什么.

The title might not be the best so let me explain what I am trying to do.

我制作了一个 Ant 构建文件,它将帮助我实现 Maven 目标.将范围限定到 Ant 视图并选择我想要做的事情要容易得多.这样做的最大好处是我几乎可以在任何项目中使用它.无论我是部署到 tomcat、jboss 或 sakai(:deploy) 还是我处理同一服务器的多个实例或跳过测试......最坏的情况我只是更改一些路径属性.

I have made an Ant buildfile that will help me with Maven goals. It's so much easier having to scope to Ant view and choose what I want to do. The biggest benefit with this is that I can use it in almost any project. Whether I deploy to tomcat or jboss or sakai(:deploy) or I handle mutiple instaces of the same server or skip tests... worst case I just change some path properties.

现在的缺点是我必须在每个项目中保留此构建文件的副本.

The drawback right now is that I have to keep a copy of this buildfile in every project.

我想要做的是在工作区中只有 1 个构建文件,并且从 eclipse 中选择了我正在处理的当前项目.无论是模块还是父级,我都可以稍后对其进行改进.所以基本上是根据eclipse中选择的项目改变ant任务的basedir.

What I am trying to do is have only 1 buildfile, in the workspace, and dinamicaly optain, from eclipse, the current project that I am working on. Be it module or parent I can refine that later. So basically change the basedir for ant tasks based on the selected project in eclipse.

我尝试过 Ant 运行时属性,但由于某些原因,像

I have tried Ant Runtime Properties but for some reason properties like

${project_path}

${project_path}

未能给我他们的描述.我明白了:

fail to give me what their description say. I get this:

变量引用空选:${project_path}

Variable references empty selection: ${project_path}

我希望我想做什么很清楚.所以我的问题,我知道这是可能的,我只是遗漏了一些东西,我希望你们中的一些人可以帮助我.

I hope it is clear what I am trying to do. So my question, I know it's possible, I'm just missing something and I hope some of you can help me with this.

我相信问题出在 Ant 运行时属性上.我不是 100% 确定我应该如何使用它们.

I believe the trouble is in the Ant Runtime properties. I'm not 100% sure how I should use those.

谢谢!

推荐答案

EDIT 经过评论和进一步调查..
使 projectdir 可用作 ant 的 basedir 属性,如下所示:
<代码>窗口 >首选项蚂蚁>运行时属性
并创建一个名为 basedir 的属性,其值为:

EDIT after comment and further investigation..
Make the projectdir available as basedir property for ant like that :
Window > Preferences > Ant > Runtime > Properties
and create a property named basedir with value either :

${project_loc}

${workspace_loc}/${project_name}

<project basedir="${basedir}">
 <echo>$${basedir} = ${basedir}</echo>
</project>

将按预期工作,意味着回显 eclipse/yourworkspace/projectdir

will work as expected, means echoing eclipse/yourworkspace/projectdir

也许还有其他方法,即通过 Ant Addon Ant4Eclipse,旨在使 Eclipse 设置可用于 ant,没用过.

Maybe there are other ways, i.e. via Ant Addon Ant4Eclipse, which aims to make Eclipse settings available for ant, never used it.

这篇关于Eclipse 中 Ant 的动态 basedir的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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