ant target的depends属性

ant的target使用depends属性指明对其它target的依赖。可以依赖多个target,被依赖的多个target之间用逗号分隔。

ant会确保被依赖的target首先执行,然后再执行本target。

ant尽量按照depends属性中指明的target出现的顺序来执行(从左到右),但也可能被依赖的某个target先执行(如果更早的target依赖于这个target的话)。

例如,下面的示例中,名字为deploy的target依赖于另外两个target,分别是deploy-tomcat和deploy-appserver,那么deploy-tomcat 和 deploy-appserver这两个target一定会在deploy这个target之前执行:

复制代码
<target name="deploy" depends="deploy-tomcat, deploy-appserver"/>

<target name="deploy-appserver" unless="tomcat">
    <copy file="${build.war.home}/jaxws-${ant.project.name}.war"
          todir="${as.home}/domains/${domain}/autodeploy"/>
</target>

<target name="deploy-tomcat" if="tomcat">
    <copy file="${build.war.home}/jaxws-${ant.project.name}.war"
          todir="${env.CATALINA_HOME}/webapps"/>
</target>

再例如,下面的target有这样的依赖关系

复制代码
<target name="t1"/>
<target name="t2", depends="t5"/>
<target name="t3", depends="t4,t5"/>
<target name="t4"/>
<target name="t5"/>

执行顺序应该为t1->t5->t2->t4->t3

相关推荐
键盘歌唱家10 小时前
Spring AI 入门分享:它和“直接调 API“到底差在哪
java·人工智能·spring
宸丶一10 小时前
Day 10:LangGraph - Agent 的图执行引擎
java·windows·python
hikktn10 小时前
Excel 导出 OOM 预防实战:30 万行从堆溢出到 50MB 的演进
java·excel·easyexcel
风味蘑菇干10 小时前
WTomcat服务器
java·服务器
燕-孑11 小时前
tomcat详解(基础到高级生产)
java·tomcat
码不停蹄的玄黓11 小时前
Spring Bean 生命周期
java·后端·spring
西安邮电大学11 小时前
分治算法详细讲解
java·后端·其他·算法·面试
摇滚侠11 小时前
Mybatis 入门到项目实战 搭建 MyBatis 框架 01-14
java·tomcat·mybatis
码不停蹄的玄黓12 小时前
SpringBoot 全局异常处理器实现
java·spring boot·后端
小高学习java12 小时前
事务的边界问题,如何判断数据回滚时机。
java·数据库·后端