ant的condition使用总结

随时随地阅读更多技术实战干货,获取项目源码、学习资料,请关注源代码社区公众号(ydmsq666)

<?xml version="1.0" encoding="UTF-8"?>
<project name ="test" default="all" basedir=".">
<target name ="all">
<!-- 使用断言istrue元素-->
<condition property="mycondition1">
<istrue value="false"/>
</condition>

<!--使用逻辑非not元素-->
<condition property="mycondition2">
<not>
<istrue value="false" />
</not>
</condition>

<!--使用逻辑与and元素:同时为真才为真-->
<condition property="mycondition3">
<and>
<istrue value="false" />
<istrue value="true" />
</and>
</condition>

<!--使用逻辑或or元素-->
<condition property="mycondition4">
<or>
<istrue value="false" />
<istrue value="true" />
</or>
</condition>

<!--使用逻辑异或xor元素-->
<condition property="mycondition5">
<xor>
<istrue value="false" />
<istrue value="true" />
</xor>
</condition>

<!--使用available元素-->
<condition property="mycondition6">
<available file="test.TXT"/>
</condition>

<path id="all.classes">
<pathelement location="bin"/>
</path>
<condition property="mycondition7">
<available resource="test.class">
<classpath refid="all.classes"/>
</available>
</condition>

<!--使用isset元素判断指定属性是否存在-->
<property name="name" value="this is the name property" />
<condition property="mycondition8">
<isset property="name"/>
</condition>

<!--使用equals元素判断是否相等-->
<condition property="mycondition9">
<equals arg1="${name}" arg2="this is the name"/>
</condition>

<!--使用filesmatch元素比较文件-->
<condition property="mycondition10">
<filesmatch file1="tes1.TXT" file2="test2.TXT"/>
</condition>
<antcall target="isTrue"/>
<antcall target="isFalse"/>
</target>

<target name="isTrue" if="mycondition9">
<echo > is true</echo>
</target>

<target name="isFalse" unless="mycondition9">
<echo > is false</echo>
</target>
</project>

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

u010142437

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值