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. springboot整合freemarker(转)

    添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>sp ...

  2. 使用四种框架分别实现百万websocket常连接的服务器--转

    原文地址:http://colobu.com/2015/05/22/implement-C1000K-servers-by-spray-netty-undertow-and-node-js/#Nett ...

  3. MongoDb 查询时常用方法

    Query.All("name", "a", "b");//通过多个元素来匹配数组Query.And(Query.EQ("name ...

  4. 【习题 5-6 UVA-1595】Symmetry

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 每一个y坐标的点都找中点. 看看中点是不是都一样就好. [代码] #include <bits/stdc++.h> us ...

  5. Nginx+Memcached+Tomcat集群配置(MSM--win7 64bit)

    本次主要是在win7 64 上演示操作. web应用构建 Memcached安装配置启动 Tomcat配置 所需jar包 memcached-session-manager 序列化 contextxm ...

  6. TensorFlow on Windows: “Couldn't open CUDA library cudnn64_5.dll”

    TensorFlow on Windows: "Couldn't open CUDA library cudnn64_5.dll" 在 windows 下,使用 import te ...

  7. 线程堆栈大小 pthread_attr_setstacksize 的使用

    pthread_create 创建线程时,若不指定分配堆栈大小,系统会分配默认值,查看默认值方法如下: # ulimit -s8192# 上述表示为8M:单位为KB. 也可以通过# ulimit -a ...

  8. glide 安装

    glide是go的一个包管理工具 参考了 https://studygolang.com/articles/10453?fr=email 遇到的问题是,用了 go get githubXXXXX去下载 ...

  9. PatentTips - Highly-available OSPF routing protocol

    BACKGROUND OF THE INVENTION FIG. 1A is a simplified block diagram schematically representing a typic ...

  10. 超级牛X的免费开源小工具之tldr

    github介绍:http://tldr-pages.github.io/ github源码:https://github.com/tldr-pages/tldr 什么是tldr? 新命令行世界?还是 ...