Ant 条件判断 if
最近收到一个ticket,用ant写个build.xml,用到condition,作笔记如下:
basic elements: istrue isfalse not and or xor available isset equals filesmatch
1、istrue isfalse:断言 真 假
- <project name="testCondition">
- <target name="test">
- <condition property="scondition">
- <istrue value="true"/>
- </condition>
- <antcall target="isTrue">
- </antcall>
- <antcall target="isFalse">
- </antcall>
- </target>
- <target name="isTrue" if="scondition">
- <echo>is ture</echo>
- </target>
- <target name="isFalse" unless="scondition">
- <echo>is false</echo>
- </target>
- </project>
2、逻辑运算
2.1、not 逻辑非
- <project name="testCondition">
- <target name="test">
- <condition property="scondition">
- <not>
- <istrue value="true"/>
- </not>
- </condition>
- <antcall target="isTrue">
- </antcall>
- <antcall target="isFalse">
- </antcall>
- </target>
- <target name="isTrue" if="scondition">
- <echo>is ture</echo>
- </target>
- <target name="isFalse" unless="scondition">
- <echo>is false</echo>
- </target>
- </project>
2.2、and 逻辑与
- <project name="testCondition">
- <target name="test">
- <condition property="scondition">
- <and>
- <istrue value="true"/>
- <istrue value="false"/>
- </and>
- </condition>
- <antcall target="isTrue">
- </antcall>
- <antcall target="isFalse">
- </antcall>
- </target>
- <target name="isTrue" if="scondition">
- <echo>is ture</echo>
- </target>
- <target name="isFalse" unless="scondition">
- <echo>is false</echo>
- </target>
- </project>
2.3、or 逻辑或 xor异或 (语法上与and类似)
3、available 是否可用
- <project name="testCondition">
- <path id="all.test.classes">
- <pathelement location="bin"/>
- </path>
- <target name="test">
- <condition property="scondition">
- <!--在指定的classpath路径下是否存在资源 TestTest.class-->
- <available resource="TestTest.class">
- <classpath refid="all.test.classes" />
- </available>
- </condition>
- <antcall target="isTrue">
- </antcall>
- <antcall target="isFalse">
- </antcall>
- </target>
- <target name="isTrue" if="scondition">
- <echo>is ture</echo>
- </target>
- <target name="isFalse" unless="scondition">
- <echo>is false</echo>
- </target>
- </project>
4、isset 指定属性是否存在
- <project name="testCondition">
- <!--属性也可以通过ant参数-D来设置-->
- <property name="name" value="this is name" />
- <target name="test">
- <condition property="scondition">
- <!--如果属性name不存在则返回false-->
- <isset property="name" />
- </condition>
- <antcall target="isTrue">
- </antcall>
- <antcall target="isFalse">
- </antcall>
- </target>
- <target name="isTrue" if="scondition">
- <echo>is ture</echo>
- </target>
- <target name="isFalse" unless="scondition">
- <echo>is false</echo>
- </target>
- </project>
5、equals 是否相等
- <project name="testCondition">
- <!--属性也可以通过ant参数-D来设置-->
- <property name="name" value="this is name" />
- <target name="test">
- <condition property="scondition">
- <!--如果arg1的值与arg2的值相等返回true,否则为false-->
- <equals arg1="${name}" arg2="this is name" />
- </condition>
- <antcall target="isTrue">
- </antcall>
- <antcall target="isFalse">
- </antcall>
- </target>
- <target name="isTrue" if="scondition">
- <echo>is ture</echo>
- </target>
- <target name="isFalse" unless="scondition">
- <echo>is false</echo>
- </target>
- </project>
6、filesmatch 比较文件
- <project name="testCondition">
- <target name="test">
- <condition property="scondition">
- <!--如果file1所代表的文件与file2所代表的文件相等返回true,否则为false-->
- <filesmatch file1="testfile1.txt" file2="testfile2.txt" />
- </condition>
- <antcall target="isTrue">
- </antcall>
- <antcall target="isFalse">
- </antcall>
- </target>
- <target name="isTrue" if="scondition">
- <echo>is ture</echo>
- </target>
- <target name="isFalse" unless="scondition">
- <echo>is false</echo>
- </target>
- </project>
转载于:https://www.cnblogs.com/balaamwe/archive/2012/03/07/2383345.html
Ant 条件判断 if相关推荐
- smali to java_Smali —— 数学运算,条件判断,循环
通过上一篇 Smali 语法解析--Hello World 的学习,了解了 Smali 文件的基本格式.这一篇从最基本的数学运算,条件判断,循环等开始,更加详细的了解 Smali 语法. 数学运算 加 ...
- 已知2个整形数据a,b.不使用if,?:以及其他任何条件判断的语法,找出a跟b中数据的大者。
已知2个整形数据a,b.不使用if,?:以及其他任何条件判断的语法,找出a跟b中数据的大者. 答案: int max(int a,int b) { return (a+b+abs(a-b))/2; } ...
- bash 脚本编程2 条件判断 (笔记)
条件判断类型: 整数测试 字符测试 文件测试 条件表达式: [ exppression ] ` expression ` test expression 注意一定要加空格前后都要加 整数比较: -e ...
- Python中if条件判断语句怎么用?
俗话说"不积跬步无以至千里".学习了Python的基本语法后,接下来我们学习Python常的if条件判断语句. if语句是最简单的条件判断语句,它可以控制程序的执行流程,其使用格式 ...
- c#switch语句判断成绩_Go的条件判断语句
现实时间中,我们如果想去购物,可以选择网上或者线下去购物,甚至说,要购买的物品都有许多选择,选价格便宜的,选质量好的,选不用运费等等 那么在计算机语言中,我们要怎么实现现实中,这些选择呢? Go语言支 ...
- R语言将多分类数据集转化为二分类数据集,使用条件判断将多分类转化为二分类(transform dataset into a dichotomous factor response dataset)
R语言将多分类数据集转化为二分类数据集,使用条件判断将多分类转化为二分类(transform dataset into a dichotomous factor response dataset) 目 ...
- pandas基于条件判断更新dataframe中所有数据列数值内容的值(Conditionally updating all values in pandas Dataframe )
pandas基于条件判断更新dataframe中所有数据列数值内容的值(Conditionally updating all values in pandas Dataframe ) 目录
- pandas基于条件判断更新dataframe中特定数据列数值内容的值(Conditionally updating values in specific pandas Dataframe )
pandas基于条件判断更新dataframe中特定数据列数值内容的值(Conditionally updating values in specific pandas Dataframe ) 目录
- R语言switch语句语法、实战:Switch语句用来处理嵌套的if else处理起来比较困难或者麻烦的条件判断问题
R语言switch语句语法.实战:Switch语句用来处理嵌套的if else处理起来比较困难或者麻烦的条件判断问题 目录
最新文章
- Hinton一作新论文:如何在神经网络中表示“部分-整体层次结构”?
- 阿里云叔同:以容器为代表的云原生技术,已经成为释放云价值的最短路径
- windows Navicat Premium连接oracle
- 五:CentOS7安装出现Warning
- cookie 和 session 区别
- 11月22日云栖精选夜读:双11享Go了吗?2017阿里双11在线峰会续写科技盛宴!
- AAAI'22 Oral | 复旦x字节等提出:基于无监督编辑的反事实故事改写
- 不会真有人觉得聊天机器人难吧——使用BERT加载预训练模型得到中文句子向量
- HTML5 Web SQL 数据库
- 远程通讯测试软件,USR-TCP232-304和虚拟串口软件通讯测试
- 如何给linux添加新硬盘(转)
- pudn下载地址的规律
- Vs2010中文版 使用 .net 3.5 时,智能提示英文变中文
- QQ邮箱搜索器 邮箱地址批量搜索
- IDEA全局配置图文教程
- 1357: 逆序数字
- 我的功放和你们用的功放芯片的SD_MUTE脚电平不一样_该如何处理
- 点餐小程序系统/基于微信小程序的点餐系统/点餐平台网站
- SpringBoot基于若依项目工时统计成本核算管理源码带文字教程
- 打开计算机用户策略,打开组策略,详细教您电脑组策略怎么打开