zoukankan      html  css  js  c++  java
  • ant—学习记录一

    <?xml version="1.0"?>
    <project name="helloWorld">
    <target name="sayHelloWorld">
    <echo message="Hello,xutianhao"/>
    </target>
    </project>
    <!-- ant_helloworld -->

      

    <?xml version="1.0"?>
    <project name="projectStudy" default="sayBaseDir" basedir="E:apache-ant-1.8.2-binapache-ant-1.8.2">
    <!-- default 代表默认要执行的动作  target-->
    <!-- basedir为用户设置的属性 如果去掉的话再执行,结果是e:即ant构建文件的父目录 -->
    <target name="sayBaseDir">
    <!-- 命令行中执行的语句  ant SayBasedir 即执行sayBaseDir步骤 -->
    <!-- 如果未指明执行的target 直接ant 会完成default指定的target-->
    <echo message="the base dir is:${basedir}"/>
    </target>
    <!-- 如果说在一个project里有两个name相同的target 
    运行结果为
    BUILD FAILED
    E:uild.xml:20: Duplicate target 'sayBaseDir'-->
    </project>
    

      

    <?xml version="1.0"?>
    
    <project name="targetStudy">
    <target name="targetA" if="ant.java.version">
    <!-- 如果 if属性存在 所在 target将被执行 -->
    <echo message="java.version:${ant.java.version}"/>
    </target>
    <target name="targetB" unless="amigo" depends="targetA">
    <!-- 如果 unless属性存在 所在target将不被执行 -->
    <!-- targetB依赖于targetA -->
    <!-- 运行ant targetB 先执行targetA(被依赖的)再执行targetB -->
    <description>a depend example!</description>
    <echo message="The base dir is:${basedir}"/>
    </target>
    </project>
    
    <!--运行结果
    E:>ant targetB
    Buildfile: E:uild.xml
    
    targetA:
         [echo] java.version:1.7
    
    targetB:
         [echo] The base dir is:E:
    
    BUILD SUCCESSFUL
    Total time: 0 seconds -->
    

      

    <?xml version="1.0"?>
    
    <project name="targetStudy">
    <target name="targetA">
    <echo message="The base dir is:${basedir}"/>
    <!-- project 基目录的绝对路径   代表当前目录-->
    <echo message="The ant.file is:${ant.file}"/>
    <!-- buildfile 的绝对路径 -->
    <echo message="The ant.java.version is:${ant.java.version}"/>
    <!-- ant 检测到的java版本  -->
    <echo message="The ant.version is:${ant.version}"/>
    <!-- ant 的版本 -->
    <echo message="The ant.project.name is:${ant.project.name}"/>
    <!-- 当前制定的project的name -->
    
    </target>
    </project>
    <!-- E:>ant targetA
    Buildfile: E:uild.xml
    
    targetA:
         [echo] The base dir is:E:
         [echo] The base dir is:E:uild.xml
         [echo] The base dir is:1.7
         [echo] The base dir is:Apache Ant(TM) version 1.8.2 compiled on December 20
     2010
         [echo] The base dir is:targetStudy
    
    BUILD SUCCESSFUL
    Total time: 0 seconds -->
    

      

    <?xml version="1.0"?>
    
    <project name="targetStudy">
    <property name="name" value="xutianhao"/>
    <property name="age"  value="23"/>
    <target name="targetA">
    <echo message="The base dir is:${name}"/>
    <!-- 设置的姓名属性 xutianhao-->
    <echo message="The base dir is:${age}"/>
    <!-- 设置的年龄属性23-->
    
    </target>
    </project>
    

      

  • 相关阅读:
    redhat 6安装详解
    使用pidstat查看进程资源使用情况
    (转)调优 DB2 UDB v8.1 及其数据库的最佳实践
    (转)LVS安装使用详解
    (转)[小工具] Linux下列格式化工具
    (转)zabbix3.4使用percona-monitoring-plugins监控mysql
    (转)zabbix之生产案例
    (转)CentOS7 LVM添加硬盘及扩容
    (转)计算机网络基础知识总结
    (转)网络基础之网络协议篇
  • 原文地址:https://www.cnblogs.com/tianhao/p/4220648.html
Copyright © 2011-2022 走看看