1、istrue isfalse:断言 真 假


  1. <project name="testCondition">
  2. <target name="test">
  3. <condition property="scondition">
  4. <istrue value="true"/>
  5. </condition>
  6. <antcall target="isTrue"></antcall>
  7. <antcall target="isFalse"></antcall>
  8. </target>
  9. <target name="isTrue" if="scondition">
  10. <echo>is ture</echo>
  11. </target>
  12. <target name="isFalse" unless="scondition">
  13. <echo>is false</echo>
  14. </target>
  15. </project>

2、逻辑运算


2.1、not 逻辑非

  1. <project name="testCondition"  default="test">
  2. <target name="test">
  3. <condition property="scondition">
  4. <not>
  5. <istrue value="true"/>
  6. </not>
  7. </condition>
  8. <antcall target="isTrue"></antcall>
  9. <antcall target="isFalse"></antcall>
  10. </target>
  11. <target name="isTrue" if="scondition">
  12. <echo>is ture</echo>
  13. </target>
  14. <target name="isFalse" unless="scondition">
  15. <echo>is false</echo>
  16. </target>
  17. </project>

2.2、and 逻辑与

  1. <project name="testCondition" default="test">
  2. <target name="test">
  3. <condition property="scondition">
  4. <and>
  5. <istrue value="true"/>
  6. <istrue value="false"/>
  7. </and>
  8. </condition>
  9. <antcall target="isTrue"></antcall>
  10. <antcall target="isFalse"></antcall>
  11. </target>
  12. <target name="isTrue" if="scondition">
  13. <echo>is ture</echo>
  14. </target>
  15. <target name="isFalse" unless="scondition">
  16. <echo>is false</echo>
  17. </target>
  18. </project>

2.3、or 逻辑或 xor异或 (语法上与and类似)


3、available 是否可用

  1. <project name="testCondition" default="test">
  2. <path id="all.test.classes">
  3. <pathelement location="bin"/>
  4. </path>
  5. <target name="test">
  6. <condition property="scondition">
  7. <!--在指定的classpath路径下是否存在资源 TestTest.class-->
  8. <available resource="TestTest.class">
  9. <classpath refid="all.test.classes" />
  10. </available>
  11. </condition>
  12. <antcall target="isTrue"></antcall>
  13. <antcall target="isFalse"></antcall>
  14. </target>
  15. <target name="isTrue" if="scondition">
  16. <echo>is ture</echo>
  17. </target>
  18. <target name="isFalse" unless="scondition">
  19. <echo>is false</echo>
  20. </target>
  21. </project>

4、isset 指定属性是否存在

  1. <project name="testCondition" default="test">
  2. <!--属性也能够通过ant參数-D来设置-->
  3. <property name="name" value="this is name"/>
  4. <target name="test">
  5. <condition property="scondition">
  6. <!--假设属性name不存在则返回false-->
  7. <isset property="name"/>
  8. </condition>
  9. <antcall target="isTrue"></antcall>
  10. <antcall target="isFalse"></antcall>
  11. </target>
  12. <target name="isTrue" if="scondition">
  13. <echo>is ture</echo>
  14. </target>
  15. <target name="isFalse" unless="scondition">
  16. <echo>is false</echo>
  17. </target>
  18. </project>

5、equals 是否相等

  1. <project name="testCondition">
  2. <!--属性也能够通过ant參数-D来设置-->
  3. <property name="name" value="this is name"/>
  4. <target name="test">
  5. <condition property="scondition">
  6. <!--假设arg1的值与arg2的值相等返回true,否则为false-->
  7. <equals arg1="${name}" arg2="this is name"/>
  8. </condition>
  9. <antcall target="isTrue"></antcall>
  10. <antcall target="isFalse"></antcall>
  11. </target>
  12. <target name="isTrue" if="scondition">
  13. <echo>is ture</echo>
  14. </target>
  15. <target name="isFalse" unless="scondition">
  16. <echo>is false</echo>
  17. </target>
  18. </project>

6、filesmatch 比較文件

  1. <project name="testCondition">
  2. <target name="test">
  3. <condition property="scondition">
  4. <!--假设file1所代表的文件与file2所代表的文件相等返回true,否则为false-->
  5. <filesmatch file1="testfile1.txt" file2="testfile2.txt"/>
  6. </condition>
  7. <antcall target="isTrue"></antcall>
  8. <antcall target="isFalse"></antcall>
  9. </target>
  10. <target name="isTrue" if="scondition">
  11. <echo>is ture</echo>
  12. </target>
  13. <target name="isFalse" unless="scondition">
  14. <echo>is false</echo>
  15. </target>
  16. </project>

ant的condition任务的更多相关文章

  1. 从源码角度深入分析ant

    Ant的基本概念 首先是ant的基本概念:Project,Target,Tasks,Properties,Paths 1.Project <project> build.xml文件最顶层的 ...

  2. 从源码角度深入分析 ant

    [转自] http://www.tuicool.com/articles/eQvIRbA Ant的基本概念 首先是ant的基本概念: Project,Target,Tasks,Properties,P ...

  3. React Native初试:Windows下Andriod环境搭建

    最近想写个App,又觉得Native App 太无趣了Web App又没那么成熟然后发现了Facebook在9月发布的React Native比较新奇,所以决定捣鼓看看: React Native为F ...

  4. ANDROID STUDIO, GRADLE AND NDK INTEGRATION

    Originally posted on:http://ph0b.com/android-studio-gradle-and-ndk-integration/ With the recent chan ...

  5. NDK 开发实例二(添加 Eigen库)

    上一篇,我已经阐述了如何创建一个简单的NDK实例: NDK 开发实例一(Android.mk环境配置下) 在上一篇的基础上,我们来添加Eigen库,然后做一个简单实例. Eigen是一个高层次的C + ...

  6. NetBeans部署项目(Extjs)报错(一)

    NetBeans部署项目(Extjs)报错(一) 1.用NetBeans将项目部署到Tomcat中,报错. 具体如下: ant -f D:\\NetBeans\\workspace\\Foundati ...

  7. Cocos2d-x游戏导出android工程,提取cocos的so文件

      Cocos2d-x游戏导出android工程,提取cocos的so文件   原本cocos游戏的android工程编译时,需要将cocos的库文件进行编译,这些文件大部分是cpp文件, 使用ndk ...

  8. React Native Android入门实战及深入源代码分析系列(2)——React Native源代码编译

    本文为老曾原创.转载需注明出处:viewmode=contents">http://blog.csdn.net/minimicall?viewmode=contents 在上一节中,我 ...

  9. Android 使用OpenCV的三种方式(Android Studio)

    http://blog.csdn.net/sbsujjbcy/article/details/49520791 其实最早接触OpenCV是很久很久之前的事了,大概在2013年的5,6月份,当时还是个菜 ...

随机推荐

  1. POJ 1325 Machine Schedule(zoj 1364) 最小覆盖数

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=364 http://poj.org/problem?id=1325 题目大意: ...

  2. 【CS Round #48 (Div. 2 only)】Water Volume

    [链接]h在这里写链接 [题意] 在这里写题意 [题解] 枚举0在哪个位置就好. [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/stdc++.h> us ...

  3. Maven学习总结(17)——深入理解maven灵活的构建

    一个优秀的构建系统必须足够灵活,应该能够让项目在不同的环境下都能成功构建.maven为了支持构建的灵活性,内置了三大特性,即:属性.profile和资源过滤. 1.maven属性 maven属性分6类 ...

  4. BestCoder Round #11 (Div. 2) 前三题题解

    题目链接: huangjing hdu5054 Alice and Bob 思路: 就是(x,y)在两个參考系中的表示演全然一样.那么仅仅可能在这个矩形的中点.. 题目: Alice and Bob ...

  5. PatentTips - SNMP firewall

    BACKGROUND OF THE INVENTION [0001] The present invention relates to communications and, more particu ...

  6. dll = MinGW gcc 生成动态链接库 dll 的一些问题汇总

    MinGW gcc 生成动态链接库 dll 的一些问题汇总 https://blog.csdn.net/liyuanbhu/article/details/42612365 网络上关于用 MinGW  ...

  7. JAVA中try-catch异常逃逸

    有时候一些小的细节,确实比较纠结,对于try-catch-finally代码块中代码依次执行,当try中有exception抛出时,将会有catch拦截并执行,如果没有catch区块,那么except ...

  8. [Angular2] Map keyboards events to Function

    The idea is when we tape the arrow keys on the keyboard, we want the ball move accodingly. const lef ...

  9. 【u011】乘法难题

    Time Limit: 1 second Memory Limit: 128 MB [问题描述] 乘法难题是一种用一行的卡片来玩的单人游戏,每张卡片上有一个正整数.在游戏者从中拿出一卡片,并且得到一个 ...

  10. React Native 四:图片

    一.展示图片资源  1.在ReactNative中.图片使用Image组件进行展示,以下我们就以静态.混合和网络资源等多种方式演示图片展示. 2.将图片放在代码目录img处: