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. java并发之生产者消费者模型

    生产者和消费者模型是操作系统中经典的同步问题.该问题最早由Dijkstra提出,用以演示它提出的信号量机制. 经典的生产者和消费者模型的描写叙述是:有一群生产者进程在生产产品.并将这些产品提供给消费者 ...

  2. 数据库中暂时表,表变量和CTE使用优势极其差别

    1 在写SQL时常常会用到暂时表,表变量和CTE,这三者在使用时各有优势: 1. 暂时表:分为局部暂时表和全局暂时表. 1.1局部暂时表,创建时以#开头,在系统数据库tempdb中存储. 在当前的链接 ...

  3. Java中使用org.json和json-lib解析JSON

    文章目录  [隐藏] 一.JavaProject中org.json解析JSON 1.JSON的org.son-api下载 1)JSON网址 2)JSON的java解析org.json-api网址 3) ...

  4. [PReact] Reduce the Size of a React App in Two Lines with preact-compat

    Not every app is greenfield, and it would be a shame if existing React apps could not benefit from t ...

  5. iOS开发:父子控制器简介:

    #import "ViewController.h" #import "ScoietyViewController.h" #import "HotVi ...

  6. html5 背景音乐 js控制播放 暂停

    <html> <head> <title> 测试页面 </title> <script src="jquery.min.js" ...

  7. css3背景透明文字不透明

    在 FF/Chrome 等较新的浏览器中可以使用css属性background-color的rgba轻松实现背景透明,而文字保持不透明.而IE6/7/8浏览器不支持rgba,只有使用IE的专属滤镜fi ...

  8. Linux下 kprobe工具的使用

    此处转载: 一.Kprobe简单介绍 kprobe是一个动态地收集调试和性能信息的工具,它从Dprobe项目派生而来,是一种非破坏性工具,用户用它差点儿能够跟踪不论什么函数或被运行的指令以及一些异步事 ...

  9. MySQL 监控-innotop

    innotop 编写者Balon Schwartz,<高性能MySQL>的作者之一. innotop的作用为实时地展示服务器正在发生的事情,监控innodb,监控多个MySQL实例,是一款 ...

  10. Navigation Pane不能设置显示标题

    https://msdn.microsoft.com/VBA/Word-VBA/articles/view-showheading-method-word https://social.msdn.mi ...