[Ant存档] Demonstration Tips of Ant
2007-01-23 17:43
330 查看
<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>
<!-- 定义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>
相关文章推荐
- TIPS FOR IMPROVING PERFORMANCE OF KAFKA PRODUCER
- Ant Design of React—第六节
- Best of Vim Tips 中文版
- ant学习(存档)
- Android Studio Tips Of the Day - Roundup #1
- Tips of Linux C programming
- Best of VIM Tips
- Tips of Programming in Google App Engine
- Tips of Windows Installer
- Android Studio Tips Of the Day
- tips of learning
- Some of the continuous-integration tools that work with Ant (From Ant in Action 2nd Edition)
- oracle ORA-01002: fetch out of sequence tips 违反提取顺序
- Silverlight Tips of the Day 系列翻译与领悟#3
- Silverlight Tips of the Day 系列翻译与领悟#10
- Ant Notes of usage and failures
- 10 Tips to Survive and Progress in the Field of Software Testing
- tips of Latex 如何确定某个宏定义的位置
- 使用Ant中的OutOfMemoryError解决办法
- Best of Vim Tips