Lecture Notes on Ant (COMP 303)

Ant is a Java-based build tool

Ant basics

A minimal build.xml file

<?xml version="1.0"?>
<project default="init"> 
  <target name="init"> 
  <target/> 
<project/>

Can add descriptions and comments

<xml version="1.0"?> 
<project default="init" name="Project Argon"> 

<description> 
  A simple project introducing the use of descriptive tags in Ant build files.
<description/> 

  <!-- XML comments can also be used --> 
  <target name="init" description="Initialize Argon database"> 
  <-- perform initialization steps here -->
  <target/> 
<project/>

Can define properties

<property name="database-file" location="archive/databases/${metal}.db"/>

<property name="database-file" location="archive\databases\${metal}.db"/>

Can define dependencies

<target name="init"/> 
...
<target name="preprocess" depends="init"/> 
...
<target name="compile" depends="init,preprocess"/> 
...
<target name="package" depends="compile"/>

Let's look at a complete example