Our First “Real” Ant Script
Next, we will use our new template to create our first real Ant script.
To get you started, I will explain some of the fundamentals of the Ant language. These are the basic functions you need to learn for now; along the way, we will explore more, so don’t worry when we don’t cover them all at once.
Projects
Every Ant XML file starts off with an XML declaration (for good
practice) and a project begin node and end node. The project
node is kind of like a target, except that there can be only
one. For it to function properly, it needs to have a name
property. The basedir
property defines the directory Ant
should start from—for example, when it needs to traverse directories.
The following is an example of a project node:
<?xml version="1.0" encoding="UTF-8"?> <project name="Default Project" basedir="."> ... </project>
Note
If you need to go one directory level higher, you can use either
../../
or .
; just make sure you also place your Ant
build file in the root of your Eclipse project.
Functions
As mentioned previously, Ant calls functions
targets. A target consists of a target node with a
name
element. This element is
mandatory, meaning it must always be in a target. The name
element is basically the name of your
target, and it enables you to call that target via the command line from
a build file. You can also add a description
property to describe what the
target does, as shown here:
<target name="create-timestamp" description="Creates a Timestamp"> ... </target> ...
Get Automating ActionScript Projects with Eclipse and Ant now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.