Skip to content

Setting Up Ant

ant_logo_large

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):

Setup to Run Stand-Alone

  1. Install the JRE, if you don’t already have it.
  2. Download latest version of ANT: http://ant.apache.org/bindownload.cgi and unzip to c:\Ant
  3. 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

  4. Put all the JAR files under C:\Ant\lib
  5. Add the following variables to your SYSTEM Variables
    ANT_HOME=C:\Ant  

     
    Add this to your existing PATH variable:

    C:\Ant\bin;  

     
    Also, make sure there’s a CLASSPATH and JAVA_HOME system variables setup for the JRE.
    e.g. 

    CLASSPATH=.;C:\Program Files\Java\jre1.6.0_07\lib\ext\QTJava.zip  
    JAVA_HOME=C:\Program Files\Java\jdk1.6.0_07  

  1. 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

  1. Run Eclipse
  2. Go to Run > External Tools > External Tools Configurations
  3. Double click on the Ant Build Icon
    This will open up the "New_Configuration Wizard"

  4. Name the build DeployStaging (there should already be a name in the field, but it’s called "New_configuration"
  5. 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.)
  6. 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).
  7. Select all the JARs.
  8. Click Apply.
  9. Click Close.
  10. Save if prompted.
  11. Select the build file and then Go to Run > Run
  12. To Modify the script you’ve just setup, go to Run > External Tools > External Tools Configurations
  13. 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").
  14. Click Apply and close.
  15. To see the build progress in detail, open up the console view by Window > Show View >Other > General > Console.

Dan View All

Blog owner.

%d bloggers like this: