Ant:文件集“目录"具有运行时扩展完整路径的属性 [英] Ant: fileset "dir" attribute with a runtime expanded full path

查看:22
本文介绍了Ant:文件集“目录"具有运行时扩展完整路径的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个看起来像这样的文件系统:

Let's say I have a file-system that looks a little something like this:

  • C:\stuff\build.xml
  • C:\stuff\myfolder\library1.jar
  • C:\stuff\myfolder\library2.jar

在 build.xml 中,我想定义一个看起来像这样的路径:

Inside build.xml, I want to define a path that looks like this:

<path id="some.id">
    <fileset dir="myfolder">
        <include name="**/*.jar"/>
    </fileset>
</path>

通常可以正常工作.但是,我正在调用我自己的自定义 Ant 任务,该任务将继承任何引用(包括路径some.id"),并且该自定义 Ant 任务将调用位于不同 basedir 中的 build.xml.因此,文件集中的dir"属性不再有效.

Normally that works fine. However, I am calling my own custom Ant Task that will inherit any references (including the path "some.id") and that custom Ant Task will call a build.xml that lives in a different basedir. Therefore, the "dir" attribute in the fileset is no longer valid.

有没有办法定义一个目录",使其无论第二个 build.xml 位于何处都保持有效?

Is there a way to define a "dir" such that it remains valid no matter where the second build.xml lives?

我本质上想做这样的事情:

I essentially want to do something like this:

<fileset dir="${expand.current.directory}/myfolder">

所以当我调用第二个 build.xml 时,它会理解dir"属性是:

So when I call the second build.xml it will understand that the "dir" attribute is the location of:

<fileset dir="c:\stuff\myfolder">

此外,我想要一个解决方案,允许我将东西"项目从一台机器复制到另一台机器,而无需更改构建.例如,如果stuff"项目在 C: 驱动器上,我将项目复制到另一台机器上的 D: 驱动器,我希望构建继续工作,而不必进入构建并更改字母C 到字母 D.

Furthermore, I want a solution that allows me to copy the "stuff" project from one machine to another without requiring a change to the build. For example, if the "stuff" project is on the C: drive and I copy the project over to a D: drive on another machine, I want the build to continue to work without me having to go into the build and change the letter C to the letter D.

推荐答案

我认为您在寻找 ${user.dir} 属性 - 这是当前工作目录.

I think you're after the ${user.dir} property - which is the current working directory.

所有 java System.properties 都可用作 ant 属性.

All java System.properties are available as ant properties.

这篇关于Ant:文件集“目录"具有运行时扩展完整路径的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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