Author: Rajesh Kumar
<project name="test" default="compile" basedir=" . ">
<target name="compile-web">
<javac srcdir="${src}" destdir="${build}">
<include name="**/web/**"/>
</javac>
<copy todir="${build}">
<fileset dir="web">
<include name="**/*.properties" />
</fileset>
</copy>
</target>
<target name="init">
....
</target>
<target name="copyFiles">
....
</target>
<target name="compile" depends="init">
....
</target>
<target name="package" depends="compile, copyFiles">
....
</target>
<target name="init">
...
</target>
<target name="copyFiles">
...
</target>
<target name="compile" depends="init">
...
</target>
<target name="package" depends="compile, copyFiles">
...
</target>
<target name="package" depends="compile, copyFiles">
<jar> ... </jar>
</target>
<target name="A"/>
<target name="B" depends="A"/>
<target name="C" depends="B"/>
<target name="D" depends="C,B,A"/>
<target name="A"/>
<target name="B" depends="A"/>
<target name="C" depends="B"/>
<target name="D" depends="C,B,A"/>
<target name="compileEJB" if="EJBModule"/>
-The target "compileEJB" will be executed only if the property "EJBModule" has some value in the build XML. The value could be even an empty string.
<target name="compileAllModules" unless="ModuleList"/>
<taskname attribute1="value1" attribute2="value2".....attributeN="valueN"/>
<javac srcdir="${src}" destdir="${build}" source="${source.version}" target="${target.version}">
<include name="**/appclient/**"/>
<exclude name="**/*.properties" />
<classpath refid="classpath" />
</javac>
<property name="libDirectory" value="./lib"/>
<property file="../common/build.properties"/>
<echo>${compileDir}</echo>
<property name="propertyName" value="propertyValue"/>
<property file="./config/file1.properties"/>
<property url="http://www.site.com/prop/site.properties"/>
Continued
<property resource="org/apache/tools/ant/taskdefs/file1.properties"/>
Referred property :<property name="try" value="tryValue" id="tryId"/>
Referring property :<property name="tryAgain" refid="tryId"/>
build.compiler=jikes
deploy.server=localhost
deploy.port=8080
deploy.url=http://${deploy.server}:${deploy.port}/
<javac srcdir="${src}" destdir="${build}" source="1.4" target="1.5">
<include name="**/exception/*"/>
<classpath refid="classpath" />
</javac>
<javac srcdir="${src}" destdir="${build}" source="1.4" target="1.5">
<include name="**/exception/*"/>
<classpath refid="classpath" />
</javac>
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmdClasspath" />
<pmd shortFilenames="true">
<ruleset>rulesets/imports.xml</ruleset>
<formatter type="html" toFile="PMDReport/pmd_report.html" linkPrefix="http://pmd.sourceforge.net/xref/" />
<fileset dir="${src}">
<include name="**/*.java" />
</fileset>
</pmd>
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmdClasspath" />
makes a task called pmd available to Ant. The class net.sourceforge.pmd.ant.PMDTask implements the task.
<target name="exec">
<exec executable="ant.bat">
<arg line="-buildfile FirstBuild.xml" />
</exec>
</target>
<target name="default">
<antcall target="echoMessage">
<param name="param1" value="value"/>
</antcall>
</target>
<target name=" echoMessage ">
<echo message="param1=${param1}"/>
</target>
<ant antfile="subproject/subbuild.xml" target="compile"/>
<target name="exec">
<exec executable="ant.bat">
<arg line="-buildfile FirstBuild.xml" />
</exec>
</target>
<target name="ant">
<ant antfile="FirstBuild.xml" />
</target>
<java classname="test.Main">
<arg value="-h"/>
<classpath>
<pathelement location="dist/test.jar"/>
</classpath>
</java>
<jar destfile="${dist}/lib/app.jar">
<fileset dir="${build}/classes" excludes="**/T.class" />
</jar>
<ear destfile="build/myapp.ear" appxml="src/metadata/application.xml">
<fileset dir="build" includes="*.jar,*.war"/>
</ear>
<war destfile="myapp.war" webxml="src/metadata/myapp.xml">
<fileset dir="src/html/myapp"/>
<lib dir="thirdparty/libs">
<exclude name="jdbc1.jar"/>
</lib>
<classes dir="build/main"/>
<zipfileset dir="src/gifs" prefix="images"/>
<import file="../common-targets.xml"/>
Imports targets from the common-targets.xml file that is in a parent directory.
<loadproperties srcFile="file.properties"/>
Author: Rajesh Kumar