gpt4 book ai didi

android - 将多个目标传递给 subant

转载 作者:行者123 更新时间:2023-11-30 03:12:28 24 4
gpt4 key购买 nike

我有一个使用 Ant 使用一些标准目标(调试、发布、安装、清理等)构建的 Android 项目。我发现我可以使用如下命令运行多个目标:

ant clean debug

在这种情况下,它将运行“clean”,然后在项目上构建“debug”。这很好用。

我还有另一个用 Ant 构建的项目,我的第一个主项目依赖于它。我正在尝试在预构建步骤中自动构建子项目。到目前为止我有这个:

<target name="-pre-build">        
<subant target="${ant.project.invoked-targets}" failonerror="true">
<fileset dir="../other_project" includes="build.xml" />
</subant>

<!-- (additional steps here) -->
</target>

这适用于一个目标(例如 ant debug),但是当我运行多个目标(例如 ant clean debug)时,我得到以下错误:

Target "clean,debug" does not exist in the project "com.foo.other_project"

显然 invoked-targets 是一个逗号分隔的列表,当我真的想为每个目标重新运行 subant 时。有谁知道如何实现这一目标?有没有办法将目标列表传递给 subant,或者遍历列表并为每个目标运行一次 subant?

谢谢!

最佳答案

documentation描述了如何指定多个目标:

You can specify multiple targets using nested "target" elements instead of using the "target" attribute. These will be executed as if Ant had been invoked with a single target whose dependencies are the targets so specified, in the order specified.

还提供了一个例子:

<subant failonerror="false">
<fileset dir="." includes="**/build.xml" excludes="build.xml"/>
<target name="clean"/>
<target name="build"/>
</subant>

关于android - 将多个目标传递给 subant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20713684/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com