Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ant对象和引用:引用的范围是什么;谁的身份证?_Ant - Fatal编程技术网

Ant对象和引用:引用的范围是什么;谁的身份证?

Ant对象和引用:引用的范围是什么;谁的身份证?,ant,Ant,似乎奇怪的是,没有关于它的文档(至少我知道没有文档;我很乐意接受更正) 当我这样做时: <fileset id="my.fs" dir="..."/> IDmy.fs的范围是什么 整个蚂蚁执行周期 当前目标(以及依赖于当前目标的任何目标) 最后,如果多个线程(使用并行任务生成)试图定义具有相同ID的文件集,会发生什么情况?引用在定义它们的项目中可见。例如,如果将放置在任何目标之外,则它对于构建文件中的所有目标都是可见的。如果它是在目标A中定义的,那么如果B依赖于A,它将在目

似乎奇怪的是,没有关于它的文档(至少我知道没有文档;我很乐意接受更正)

当我这样做时:

<fileset id="my.fs" dir="..."/>

ID
my.fs
的范围是什么

  • 整个蚂蚁执行周期
  • 当前目标(以及
    依赖于当前目标的任何目标)

最后,如果多个线程(使用
并行
任务生成)试图定义具有相同ID的文件集,会发生什么情况?

引用在定义它们的项目中可见。例如,如果将
放置在任何目标之外,则它对于构建文件中的所有目标都是可见的。如果它是在目标
A
中定义的,那么如果
B
依赖于
A
,它将在目标
B
中可见:

例1:

<project name="Project1" default="doIt">

   <fileset id="my.fs" dir="some_dir"/>
   ...

   <target name="doIt">
       <copy todir="some_dir_copy">
           <fileset refid="my.fs" />  <!-- this will work -->
       </copy>
   </target>
</project>
例4:

<project name="Project1" default="doIt">

   <target name="doIt">
       <fileset id="my.fs" dir="some_dir"/>
       <ant antfile="./build.xml" target="run" inheritrefs="true" />
   </target>

   <target name="run">
       <copy todir="some_dir_copy">
           <fileset refid="my.fs" />  <!-- this will work -->
       </copy>
   </target>
</project>
<project name="Project1" default="doIt">

   <target name="doIt">
       <fileset id="my.fs" dir="some_dir"/>
       <ant antfile="./build.xml" target="run" />
   </target>

   <target name="run">
       <copy todir="some_dir_copy">
           <fileset refid="my.fs" />  <!-- this will fail -->
       </copy>
   </target>
</project>
<project name="Project1" default="doIt">

   <target name="doIt">
       <fileset id="my.fs" dir="some_dir"/>
       <ant antfile="./build.xml" target="run" inheritrefs="true" />
   </target>

   <target name="run">
       <copy todir="some_dir_copy">
           <fileset refid="my.fs" />  <!-- this will work -->
       </copy>
   </target>
</project>
<parallel>
    <fileset id="my.fs" dir="some_dir"/>
    <fileset id="my.fs" dir="another_dir"/>
</parallel>

...

<target name="doIt">
    <copy todir="some_dir_copy">
        <fileset refid="my.fs" />  <!-- this may copy either some_dir or another_dir, depending on which parallel task finished last -->
    </copy>
</target>