将 ant 目标传递给子目录中的多个 build.xml 文件

2024-05-07

我有一个包含多个模块的项目,每个模块都在自己的目录中。每个模块都有自己的ant构建文件(build.xml)

在根目录中,我设置了一个通用构建文件,该文件以正确的顺序调用每个模块的构建文件。

<?xml version="1.0"?>
<project name="bridgedb" default="all" basedir=".">
  <target name="all">
    <ant dir="corelib"/>
    <ant dir="tools"/>
    <ant dir="makeGdb"/>
    <ant dir="cytoscape-plugin"/>
  </target>
</project>

现在每个模块也有一个“干净”的目标,所以我添加这些行:

 <target name="clean">
    <ant dir="corelib" target="clean"/>
    <ant dir="tools" target="clean"/>
    <ant dir="makeGdb" target="clean"/>
    <ant dir="cytoscape-plugin" target="clean"/>
  </target>

类似的目标还有更多。有没有办法重写构建文件以避免这种重复?我寻找了包含活动目标的内置属性,但找不到它。


为什么不使用antcall http://ant.apache.org/manual/Tasks/antcall.html调用引用所有子目录的目标,并参数化要调用的目标。例如

 <antcall target="doStuffToSubdirs">
    <!-- let's clean -->
    <param name="param1" value="clean"/>
  </antcall>

进而:

<target name="doStuffToSubdirs">
   <ant dir="corelib" target="${param1}"/>
   <ant dir="tools" target="${param1}"/>
    ...etc
</target>

所以这允许您参数化对子目录的调用。如果添加新的子目录,则只需将该子目录添加到“doStuffToSubdirs”目标(我也会重命名它!)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

将 ant 目标传递给子目录中的多个 build.xml 文件 的相关文章

随机推荐