Eclipse 中 Ant 的动态 basedir
标题可能不是最好的,所以让我解释一下我想要做什么。
我制作了一个 Ant 构建文件,它将帮助我实现 Maven 目标。切换到 Ant 视图并选择我想要执行的操作要容易得多。这样做的最大好处是我几乎可以在任何项目中使用它。无论我部署到 tomcat、jboss 还是 sakai(:deploy),还是处理同一服务器的多个实例或跳过测试...最坏的情况我只是更改一些路径属性。
现在的缺点是我必须在每个项目中保留此构建文件的副本。
我想做的是在工作区中只有 1 个构建文件,并从 Eclipse 中动态选择我正在处理的当前项目。无论是模块还是父级,我都可以稍后对其进行完善。 所以基本上根据 Eclipse 中选定的项目更改 ant 任务的 basedir 。
我尝试过 Ant 运行时属性,但由于某些原因,属性如
${项目路径}
未能给我他们的描述。我明白了:
变量引用空选择:${project_path}
我希望清楚我要做什么。所以我的问题是,我知道这是可能的,我只是错过了一些东西,我希望你们中的一些人可以帮助我。
我相信问题出在 Ant 运行时属性上。我不是 100% 确定应该如何使用它们。
谢谢你!
The title might not be the best so let me explain what I am trying to do.
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.
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.
I have tried Ant Runtime Properties but for some reason properties like
${project_path}
fail to give me what their description say. I get this:
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.
I believe the trouble is in the Ant Runtime properties. I'm not 100% sure how I should use those.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在评论和进一步调查后编辑..
使projectdir可用作ant的basedir属性,如下所示:
窗口>首选项>蚂蚁>运行时间>属性
并创建一个名为 basedir 的属性,其值为:
${project_loc}
或
${workspace_loc}/${project_name}
并将
按预期工作,意味着回显 eclipse/yourworkspace/projectdir
也许还有其他方法,即通过 Ant Addon Ant4Eclipse,旨在使 Eclipse 设置可用于 ant,从未使用过它。
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}
or
${workspace_loc}/${project_name}
and
will work as expected, means echoing eclipse/yourworkspace/projectdir
Maybe there are other ways, i.e. via Ant Addon Ant4Eclipse, which aims to make Eclipse settings available for ant, never used it.