Media Art, User Experience Design, and Interface Development

Speed up development process with Ant

Posted on 2010-10-11

Apache Ant

As developers, there are inevitably repetitive tasks that need to be done and redone with each new project we undertake. The best example I can provide is creating the folder structure for our projects. Obviously this is personal to each dev, and there is also some stuff that some of our IDEs–hmm, I’m looking at you Flash Builder–add by themselves. Oftentimes I have simply copied/pasted the structure from project to project, even created a folder structure without any files, just so I could copy paste. That was a while ago.

In line with the mission of this blog, I present you with another useful tool: Ant.

Ant is basically a set of tasks written in an XML file. Tasks such as moving and copying files and directories, but sometimes much more powerful stuff. If I am not mistaken, this is how a lot of patient developers call manually on the compiler from the Flex SDK to create their SWCs and SWFs.

As I said in my previous posts, I never pretend to be a master at what I explain, but I like to share functional and straightforward knowledge of the tools, languages and utilities I use.

Of IDEs and Ant

As I have mentioned a couple of times, I do not use the Flash Builder 4 standalone IDE, but rather FB4 as a plugin to my Eclipse IDE. I once mentioned that already-integrated XML editor of Eclipse was an advantage over the standalone FB4. Here also Eclipse wins. Go to Window > Show View… > Other… and this is how you obtain a convenient Ant view panel.

Eclipse's Ant View Panel

FDT also offers such a panel, so does IntelliJ IDEA, however I have no idea what is available for FlashDevelop. For the standalone version of Flash Builder, a search on Google quickly provides examples of how to add the panel to the IDE.

Now, let’s look at some Ant stuff!

Structure and conventions

Usually, Ant files are called “build.xml” and are placed in the “build” directory. That directory also contains a properties files called “”

Ant build files structure

Let’s look at them.

a) build.xml

Ant being an XML, it is obviously written in tags. However contrary to XML, tag names are important here:



So as you can see, the root tag is named  “project” and it contains some attributes:


The properties file is a variables container.





Simply write the variable name, an equal sign (“=”) and the value. There is no need for semi-colon at the end of the line.

To import it in the build, use the property tag. As we have seen, all paths are relative to the value of the basedir tag, defined before.


Now all those variables are available for you to use in your tasks. The syntax to use a property is simple: start with a dollar sign ($), and put the property name in curly brackets ({}).


This property has a value of ${someProperty}


Tasks are basically Ant functions or methods. The Apache Ant Manual is full of examples that can be used quickly, but if you have never used Ant, it might be overwhelming. Let’s start by looking at simple things that can be done.

One main thing that annoys me with Flash Builder is the superfluous use of the html-template folder and wrapper. Also, if I happen to put any directories or file in the bin-debug, they got overwritten for all sorts of reasons. I then took the habit of having some folders of my own at the root level of my project, namely:

As I create these directories for most of my projects, it was becoming tedious to create them all the time. This is where Ant is your friend.





The only thing needed when I start a new project is to copy my Ant build to the new project and then launch the Ant task, and all folders are created quickly. Let’s analyze what I presented above.

The target tag contains the tasks. It is mandatory to give it a name, hence the name attribute. Inside that tag is where you place the Ant tasks, such as mkdir (make directory).

It is interesting to note that you can immediately create a directory inside another one, even if the root one does not exist. Calling mkdir with the attribute “www/assets” will create both the “www” and the “assets” directories at once.

Refreshing the workspace

Whenever files are modified outside of an Eclipse-based IDE, it is good to refresh the workspace. When creating, moving, deleting or renaming files in Ant, such a refresh is also necessary. It is however quite annoying to do this manually every time.

Eclipse's External Tools Configuration

The first time you run an Ant task, it will then be added in Eclipse’s External Tools Configuration menu. You can access it by clicking on the button that has sort of a suitcase icon.

Earlier I wrote about the default task of the build task. I usually echo the timestamp as the default task, so I can then simply double click on my build in the Ant view to trigger it and avoid creating or deleting stuff too early. Then I go to the config.

Let’s take a look at them.

Eclipse's External Tools Config - JRE

The first thing you want to do in these configs is to make sure that you check the “Run in the same JRE as the workspace” in the “JRE” tab, so that the refresh succeeds. Obviously, if you have other used for the JRE, rely on your knowledge, but for generic AS3 development, this serves my purpose.

Eclipse's External Tools Config - Refresh

Then, head to the “Refresh” tab and check what you want to refresh once the Ant build has completed.


Look at the ants on the floor
They work real hard, lifting three times their mass
And sometimes more

Nick Diamonds could not have phrased it better when he sung Let’s Get Known. What I presented here and what I know of Ant is but a small part of what it can do. When you realize that you repeat actions often in your Finder or Windows Explorer, think of this tool, it will save you time.

One response to “Speed up development process with Ant”

  1. […] of person, you can also compile your project directly into Ant. I know that after I have written my post about Ant, I should have written about how to compile with said insect, but since I faced the loading a SWC […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.