15 April 2009

0 ANT Introduction

Ant is a Java based build tool, similar to make, but with better support for the cross platform issues involved with developing Java applications. Ant is the build tool of choice for all Java projects at Apache and many other Open Source Java projects. Ant can be configured to compile your java source code files, build your deployment JAR and WAR files, unit-test code and create projects javadoc documentation.

Ant 1.6.0 adds a lot of new features, most prominently support for XML namespaces as well as a new concept of Ant libraries that makes use of namespaces to avoid name clashes of custom tasks.

Advantages of Ant

  • Build IN Java, USING Java, and FOR Java
  • Supports Java Tools (javac, javadoc, etc.)
  • XML Build File is Easier to Build, Read, and Maintain than MAKE file
  • Easier to Extend
  • Supports Cross Platform Java Development
  • Ant is much faster than using MAKE ? Each command is a new process
  • Ant runs within the JVM
  • Each command is executed from within JVM
  • Tools like javac are new threads – not new process
  • Compiling large number of java source files is MUCH,MUCH faster with Ant
  • Ant's Debug Options are very helpful
  • XML much easier to read than MAKEFILE
  • User does not need to know all command line interface options to tools that can be called programmatically
  • Even OS-Specific commands can be setup in 'TaskDefs' and/or included from other sources


Installing Ant

Regardless of platform, downloading Ant is the first step to installing the software. The files can be downloaded to a temporary directory and then uncompressed to any desired directory. After the download step, the process differs depending on whether you've downloaded the binary distribution or the source distribution.
Ant does not provide an installation program; it runs from wherever you choose to copy the files and directories. It lists the directories that ultimately get created under your main Ant directory.

Directories provided with Ant
bin - Batch files, Perl scripts, and shell scripts for running Ant.
docs - Ant documentation.
lib - Libraries required by Ant to run.
src - Source code for Ant. Provided only in the source distribution.

BinaryInstallation
The term "binary" just means that everything is compiled and packaged into JAR files for easy execution — you don't need to compile Ant from source.
Steps to install Installation of the binary distribution:
1. Unzip (or untar) the distribution to the desired directory.
2. Set the ANT_HOME environment variable to point to to the ant installation directory.
3. Set the JAVA_HOME environment variable to point to the JDK location.
4. Add ANT_HOME/bin to your system's PATH environment variable.

The ant script uses the ANT_HOME and JAVA_HOME environment variables to configure the CLASSPATH used by the JVM running Ant. If these variables are not set, the startup script attempts to infer the correct values, subject to operating system limitations.

Source Installation

Installing the Ant source distribution requires a little more work than installing the binary distribution. As expected, downloading and uncompressing the distribution is the first step.
You generally want to place the source files in a directory separate from any existing Ant installations. Next, ensure that JAVA_HOME points to the JDK distribution. As with the binary installation, you should also set ANT_HOME and update your PATH.


Type the following command from the source distribution directory:
build -Ddist.dir=destination_directory dist (Windows)
build.sh -Ddist.dir=destination_directory dist (Unix)

The build script creates a complete binary distribution of Ant in the specified destination directory. When omitted, dist.dir defaults to build.



0 comments:

Feeds Comments

Please give your valuable comments.