Ant 如何根据参数从 build.xml 调用另一个 xml 文件

Ant how call another xml file from build.xml depending parameter

我有 3 xml 个文件 build.xml, build_1.xml, build_2.xmlbuild_1.xml, build_2.xml 文件的目标名称为“compress”。

我如何配置 build.xml 文件,当我调用“ant compress 1”时,它 运行 从 build_1.xml 文件压缩目标并相应地 运行 压缩目标如果是“ant compress 2”,来自 build_2.xml

https://ant.apache.org/manual/Tasks/ant.html

据我了解您的问题,您的 build.xml 文件中需要以下 2 个目标:

<target name="ant compress 1">
    <ant antfile="build_1.xml" target="compress"/>
</target>

<target name="ant compress 2">
    <ant antfile="build_2.xml" target="compress"/>
</target>