ant 调用子任务

2 篇文章 0 订阅
<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" failοnerrοr="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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值