如何解决Ant中的重用和执行控制
| 我想我绝对不能“得到”蚂蚁。我很难弄清楚如何实现重用和控制一系列目标的执行。请帮忙。 我需要我的构建脚本来创建两个构建:调试构建和生产构建。目前,我正在使用ѭ0来解决我对Ant的误解。 让我使用伪命令性代码来描述我希望如何进行构建://this is my entry point
function build-production-and-debug() =
prepare()
build-production()
build-debug()
cleanup()
function build-production() =
pre-process()
compile()
post-process()
package(\"production\")
function build-debug() =
compile()
package(\"debug\")
我应该如何用Ant解决这个问题?
解决方法
也许您可以使用您的ant代码来给出更好的答案。
但是做到这一点的一种方法是使用depends属性
<target name=\"prepare\">
//do something to prepare
</target>
<target name=\"cleanup\">
//do something to cleanup
</target>
<target name=\"build-production\">
//build production
</target>
<target name=\"build-debug\">
//build debug
</target>
<target name=\"build-production-debug\" depends=\"prepare,build-production,build-debug,cleanup\">
//do something or nothing
</target>
这样,您就可以告诉蚂蚁,在执行\“ build-production-debug \”目标之前,您要首先运行\“ depends \”属性上列出的所有目标,并按该顺序执行。
,这是我想到的内容的概述,我仍在使用antcall
,但仅将其用作参数化构建的入口点。对我来说,关键发现是对目标使用ѭ4条件,以控制目标是否被执行,并注意到其依赖链中的目标仍在执行。 “ѭ5”和“ѭ6”任务在某些地方也有所帮助。
<project>
<target name=\"-init\">
</target>
<target name=\"-prod-preprocess\" depends=\"-init\" if=\"production\">
</target>
<target name=\"-compile\" depends=\"-prod-preprocess\">
</target>
<target name=\"-package\" depends=\"-compile\">
</target>
<target name=\"build-prod\">
<property name=\"production\" value=\"true\" />
<property name=\"package.dir\" location=\"${production.package.location}\"/>
<antcall target=\"-package\" />
</target>
<target name=\"build-debug\">
<property name=\"package.dir\" location=\"${debug.package.location}\"/>
<antcall target=\"-package\" />
</target>
<target name=\"build-both\">
<antcall target=\"build-debug\" />
<antcall target=\"build-prod\" />
</target>
</project>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。