Ant (Another Neat Tool) is a tool to automate tasks needed to run successful builds, deployments, and tests. You can run Ant as a stand-alone tool, or run it from Eclipse.
Needed JAR Files
In Ant, a "task" is a single line of instruction that gets run in the build file, as opposed to a "target" which is a group of tasks. There are a core set of tasks in Ant: copy, delete, echo, and many more (http://ant.apache.org/manual/). Other important tasks (like FTP/SVN/Mail functionality), however, are not included. For that reason, we need to include these "add-ons" into Ant in the form of JAR files into Ant’s classpath.
The following is a list of additional tasks we need, that are not part of Ant’s core task list (download these before reading on):
- For SVN Tasks we need:
- For Mail Tasks we need:
- For FTP Tasks we need:
- Apache ORO
Setup to Run Stand-Alone
- Install the JRE, if you don’t already have it.
- Download latest version of ANT: http://ant.apache.org/bindownload.cgi and unzip to c:\Ant
- Download the above latest JAR Files in Zip files. Zip files you download may have more than just JAR files, but you need to isolate these JAR files and put the JAR files into Ant’s classpath, C:\Ant\lib
- Put all the JAR files under C:\Ant\lib
- Add the following variables to your SYSTEM Variables
Add this to your existing PATH variable:
Also, make sure there’s a CLASSPATH and JAVA_HOME system variables setup for the JRE.
CLASSPATH=.;C:\Program Files\Java\jre1.6.0_07\lib\ext\QTJava.zip JAVA_HOME=C:\Program Files\Java\jdk1.6.0_07
- That should be it. Try to run, go to the command console and type "ant". To load a build file, type:
ant \-buildfile build.ant
Setup to Run From Eclipse
The typical Eclipse setup already comes with the core Ant tasks, so you just have to get the optional ones. Download the attachment and preferably put them here: C:\Ant\lib
- Run Eclipse
- Go to Run > External Tools > External Tools Configurations
- Double click on the Ant Build Icon
This will open up the "New_Configuration Wizard"
- Name the build DeployStaging (there should already be a name in the field, but it’s called "New_configuration"
- Under the Main tab, put in the Buildfile (in this case, "Browse File System…") – browse to where your buildfile is. (No need to include the .properties file, as the build file will call it.)
- Under the Classpath tab, click on User Entries then click on "Add External JARs…" and point it to the directory which has all the JARs you downloaded (C:\Ant\lib).
- Select all the JARs.
- Click Apply.
- Click Close.
- Save if prompted.
- Select the build file and then Go to Run > Run
- To Modify the script you’ve just setup, go to Run > External Tools > External Tools Configurations
- To select another default target (for example, for to get the latest changes), go to the Targets tab, uncheck the default, and select the target you want (in this case, "update_latest").
- Click Apply and close.
- To see the build progress in detail, open up the console view by Window > Show View >Other > General > Console.