在Ant中使用逻辑判断 Condition

本文介绍了如何在Ant脚本中使用Condition进行逻辑判断,通过示例展示了如何检查文件是否存在,并讨论了使用antcall和depends的差异,以及在属性传递中的行为。通过理解Condition任务,可以更好地实现Ant脚本中的条件控制。
摘要由CSDN通过智能技术生成

    好久不写ant脚本了,最近两天在用ant做web应用的安装部署脚本,为了实现web服务器的多版本兼容,必然要使用逻辑判断,比如我要判断是安装在weblogic8上还是weblogic9上,而在ant中处理逻辑判断真是麻烦,只能作用于task,要利用property来做判断,使用available来设置property。例如:

<?xml version="1.0" encoding="GB2312"?>
<project name="weblogic ant task" default="build">
 <target name="detect.file"   >  
  <condition property="fileIsExists"   >  
  <and>  
   <available file="c:/123.txt"/>
  </and>  
  </condition>
 </target>
 <target name="echoDemo" if="fileIsExists" depends="detect.file">  
  <echo message="hello ant"/>
 </target>
 <target name="build">  
  <antcall target="echoDemo"/>
 </target>
</

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值