Using ANT from Eclipse

I have recently taken the plunge into ANT for use in deployment and doing some mundane tasks, and since I use Eclipse I have been playing with the integrated version that comes bundled. There were a few things that are not very well documented (or I could not find) that took me a while to […]
Last updated: March 12, 2012

I have recently taken the plunge into ANT for use in deployment and doing some mundane tasks, and since I use Eclipse I have been playing with the integrated version that comes bundled. There were a few things that are not very well documented (or I could not find) that took me a while to figure out, so I though I would share.

Running an ANT task can be done from within Eclipse very easily. Eclipse recognises an ANT file as long as its called “build.xml”. You can then right click on the file and hit “Run As” > “Ant Build”. Eclipse will then execute it and push any output to the console (Window > Show View > Other > General > Console). An ANT build.xml file takes the following basic structure:

The project tag makes up the entire build. The target tag is like a holder for a bunch of tasks or one task. Inside of a target you can place any number of actions to take place. More on this later. You can set variables in an external file called build.properties, for example:

These variables can then be pulled in to the build task at run time using the property tag (this assumes the build.xml and build.properties are in the same directory)

You can also build up variable on-the-fly, here I have set up a build directory using the projectName

That is it for my quick primer to ANT, I will check out some more features in the coming days.

Duncan Isaksen-Loxton

Educated as a web developer, with over 20 years of internet based work and experience, Duncan is a Google Workspace Certified Collaboration Engineer and a WordPress expert.
Login
Log in below to access your courses.
Log In With Google
Forgot Password
Enter your email address or username and we’ll send you instructions to reset your password.