3、antcall,在一個(gè)任務(wù)中調(diào)用另一個(gè)任務(wù)。例子:
<target name="exercises">
<property name="directory1" location="d1"/>
<property name="file" location="directory1/a.txt"/>
<echo message="directory = ${directory1}, file=${file}"/>
</target>
<property name="replace1" value="Hello world!!!"/>
<tstamp>
<format property="currenttime" pattern="yyyy-MM-dd'T'HH:mm:ss"/>
</tstamp>
<filterset id="filter.set">
<filter token="welcome" value="${replace1}" />
<filter token="time" value="${currenttime}" />
</filterset>
<target name="exercise3">
<copy todir="d2">
<fileset dir="d1"/>
<filterset refid="filter.set"/>
</copy>
<antcall target="exercises"/>
</target>
如果未定義引用property1,則在此處定義它。
6、depend
<depend srcdir="
destdir="
cache="$"
closure="">
<include name="**/*.java"/>
</depend>
8、 <exec dir="" executable="“
<arg line="-lib ${task.lib.dir} -buildfile ${task.ant.file}"/>
</exec>
試驗(yàn)成功的一個(gè)例子:build.xml
<?xml version="1.0"?>
<project name="Cobra" default="junit" basedir=".">
<property environment="env" />
<condition property="ia.home" value="${env.IA_HOME}">
<isset property="env.IA_HOME" />
</condition>
<property name="run.classpath" value="class"></property>
<property name="run.srcpath" value="../src"></property>
<property name="test.xml" value="xml"></property>
<property name="test.report" value="report"></property>
<property name="lib.dir" value="lib"/>
<path id="compile.path">
<fileset dir="${lib.dir}">
<include name="junit.jar" />
<include name="ant.jar" />
<include name="ant-xalan1.jar" />
</fileset>
<fileset dir="${ia.home}">
<include name="IAClasses.zip" />
<include name="resource/services/services.jar" />
<include name="resource/services/ppk/*.jar" />
<include name="resource/ant/ant.jar" />
<include name="resource/log4j-1.2.15.jar" />
</fileset>
</path>
<target name="init">
<delete dir="${run.classpath}"/>
<mkdir dir="${run.classpath}"/>
<delete dir="${test.report}"/>
<mkdir dir="${test.report}"/>
<delete dir="${test.xml}"/>
<mkdir dir="${test.xml}"/>
</target>
<target name="compile" depends="init">
<javac destdir="${run.classpath}" srcdir="${run.srcpath}" classpathref="compile.path"/>
</target>
<target name="junit" depends="compile">
<junit printsummary="false">
<classpath path="${run.classpath}">
<path refid="compile.path" />
</classpath>
<formatter type="xml"/>
<batchtest todir="${test.xml}">
<fileset dir="${run.classpath}">
<include name="**/Test*.class"/>
<include name="**/*Test.class"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${test.xml}">
<fileset dir="${test.xml}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${test.report}"/>
</junitreport>
</target>
</project>