好久不写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>
</