运维开发网

Ant在多个目录中

运维开发网 https://www.qedev.com 2020-05-09 11:25 出处:网络 作者:运维开发网整理
我想简化这个: <target name="build"> <parallel> <antcall target="build-A" /> <antcall target="build-B" /> <antcall target="build-C" /> </parallel> </target> <target name="build-A">
我想简化这个:

<target name="build">
   <parallel>
      <antcall target="build-A" />
      <antcall target="build-B" />
      <antcall target="build-C" />
   </parallel>
</target>

<target name="build-A">
   <exec executable="tool.exe" dir="projects/A">
      <arg value="input.xml" />
   </exec>
</target>

其中build-B和build-C完全相同(仅在dirs B和C中),类似于:

<dirset id="projects" dir="." >
   <include name="projects/*" />
</dirset>

<apply executable="tool.exe" parallel="true">
   <arg value="input.xml" />
   <dirset refid="projects" />
</apply>

这不起作用,因为apply将执行以下操作之一:

如果parallel设置为true,

tool.exe input.xml projects/A projects/B projects/C

或者如果parallel设置为false,

tool.exe projects/A/input.xml
...waits for tool.exe to complete...
tool.exe projects/B/input.xml
...etc

即使这是不正确的,因为tool.exe希望在projects / A目录中运行.

有没有办法并行化这个,以便我得到的输出相当于:

cd project/A
tool.exe input.xml

cd ../B
tool.exe input.xml

cd ../C
tool.exe input.xml

但并行?

我会使用 ant-contrib的 for task来做到这一点.

<for param="dir" parallel="true">
    <dirset id="projects" dir="." >
        <include name="projects/*" />
    </dirset>
    <sequential>
        <exec executable="tool.exe" dir="@{dir}">
            <arg value="input.xml" />
        </exec>
    </sequential>
</for>
0

精彩评论

暂无评论...
验证码 换一张
取 消