ant 子任务的调用

本文介绍了一个使用Ant进行自动化部署的过程,包括代码下载、检查及失败处理等步骤。通过调用不同的目标(target),实现了从初始化到最终记录日志的完整部署流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<target name="upload_single">
<propertycopy name="svn.code.path" from="${module}.${version}" />
<ant inheritAll="false" antfile="./deploy_func.xml" target="main">
<property name="log.name" value="download_code_${module}_${version}.log"/>
<property name="func.name" value="download_code"/>
<property name="svn.code.path" value="${svn.code.path}"/>
<property name="local.code.path" value="${local.code.path}/${module}_${version}"/>
<property name="backup.path" value="${backup.path}/${module}_${version}"/>
</ant>
</target>
<target name="check_fail">
<available file="./operation.fail" property="result"/>
<fail message="upload_version_${module} failed" if="result" />
</target>
---
<target name="main" depends="inital_main">
<record name="${log.path}/${log.name}" action="start" />
<antcall target="${func.name}"/>
<record name="${log.path}/${log.name}" action="stop" />
</target>
<target name="download_code" depends="inital_download_code,move_code">
<echo message="***start to download '${svn.code.path}'."/>
<exec dir="." executable="cmd.exe" failonerror="false" resultproperty="result.download">
<arg line="/c svn checkout --username ${svn.user} --password ${svn.passwd} --no-auth-cache --force '${svn.code.path}' '${local.code.path}'"/>
</exec>
<antcall target="check_resultproperty">
<param name="result" value="${result.download}"/>
<param name="description" value="download '${svn.code.path}'"/>
</antcall>
<echo message="***end to download '${svn.code.path}' to '${local.code.path}'."/>
</target>
<target name="check_resultproperty">
<if>
<equals arg1="${result}" arg2="0" />
<then>
<echo message="${description} successfully."/>
</then>
<else>
<echo message="${description} failed!" file="./operation.fail"/>
<fail message="${description} failed!"/>
</else>
</if>
</target>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值