There are three kinds of XML tags that you use in Ant build file:
Tasks: which correspond to your command line tasks like Javac, Clean etc.
Target: Tasks are grouped in Targets, which are reusable tags. Target's concept is like functions in Java.
Property: like variables.
The common tasks in an ant file are:
delete - delete the previous build files created in the last build.
javac - compile the java files.
jar - package the class files in a jar file.
copy - used to deploy the the location that you want.
echo - for logging
All the tasks in a build file are sub-tagged in a "Project" tag. This is a sample build file
<?xml version="1.0" encoding="UTF-8"?>
<project name="project-name" default="codeCompile" basedir=".">
<target name="clean">
<delete dir="${classes.dir}" />
</target>
<target name="setup" depends="clean">
<mkdir dir="${classes.dir}" />
</target>
<target name="codeCompile" depends="setup">
<javac debug="true" deprecation="true" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="compile.classpath">
</javac>
<copy todir="${classes.dir}">
<fileset dir="${src.dir}" excludes="**/*.java" />
</copy>
<jar destfile="${badge-model.jar.name}" >
<fileset dir="${classes.dir}"/>
</jar>
<echo message="Compiled source classes successfully" />
</target>
</project>
I will be following up this article with a series of new article which will guide you throw more complex tasks that you can perform in an ant file to facilitate your building and deployment procedure.
Thanks
M. Gillani
Edited by Alexander, 01 November 2010 - 03:08 PM.
A bit of cleanup


Sign In
Create Account

Back to top









