[Ant存档] Demonstration Tips of Ant

<project name="AntTest" default="main" basedir=".">

<!--     定义path数据类型(datatype),并引用        -->

 <path id="compile.classpath">
 <pathelement location="${lucene.jar}"/>
 <pathelement location="${tidy.jar}"/>
 </path>
 
 <path id="test.classpath">
 <path refid="compile.classpath"/>
 <pathelement location="${junit.jar}"/>
 <pathelement location="${build.dir}/classes"/>
 <pathelement location="${build.dir}/test"/>
 </path>
 
 <path id="the.path">
  <pathelement location="lib/ant.jar"/>
 </path>
 <property name="path.string" refid="the.path"/>
 <echo message="${path.string}"/>

 <!--       引用环境变量        -->
 <property name="classpath" value="${basedir}/bin"/>
 <property environment="env." />
 <echo message="Number of processors = ${env.NUMBER_OF_PROCESSORS}" />
 <echo message="ANT_HOME = ${env.ANT_HOME}"/>
 <echo message="ITS_HOME = ${env.ITS_HOME}" />
 
 <echo message="Built-in Properties:"/>
 <echo message="${ant.file}"/>
 <echo message="${ant.java.version}"/>
 <echo message="${ant.version}"/>
 
 <property name="build.dir" location="build"/>
 <echo message="${build.dir}" />
 <echo message="${basedir}" />
 

<!-- demonstrate the immutability of ant's property -->
 <property file="build.properties"/>  <!--  ought to have an property named build.debug set to off in build.properties file-->
 <property name="build.debug" value="on"/>
 <echo message="build.debug = ${build.debug}"/>
 
 <target name="init">
 <property name="strip.comment" value="true"/>

<!-- demonstration of current time -->

    <tstamp>
        <format property="TODAY" pattern="yyyy-MM-dd hh:mm aa" />
    </tstamp>

<!-- define self-made tasks -->
 <taskdef name="simpletask" classname="org.xxx.anttest.SimpleTask" classpath="${classpath}" />
 <taskdef name="proctask" classname="org.xxx.anttest.FileProcTask" classpath="${classpath}"/>
 </target>

<!-- execute main program with external args -->

 <target name="execute">
  <echo level="warning" message="Executing Main Programme..."/>
  <java classname="org.xxx.anttest.Test" classpath="bin">
   <arg value="first arg"/>
   <arg value="second arg"/>
   <arg value="third arg"/>
  </java>
 </target>
 
 <target name="simpletask" depends="init" >
  <simpletask path="${env.ANT_HOME}:build/output" />
 </target>
 
 <target name="proctask" depends="init">
  <echo message="Current Time is: ${TODAY}"></echo>
  <proctask  dir="${basedir}">
   <include name="**/*.java"/>
  </proctask>
 </target>
 
<!--

1. strip comments in the file of config.properties when copying

2.  demonstrate the useage of  if  attribute

-->

 <target name="stripcomment" if="strip.comment" depends="init">
  <copy file="config.properties" todir="config">
   <filterchain>
    <striplinecomments>
     <comment value="#"/>
    </striplinecomments>
   </filterchain>
  </copy>
 </target>

 <target name="main" depends="stripcomment" />

</project>
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值