Apache ANT Tutorial
Apache Ant is a Java based build tool from Apache Software Foundation. Apache Ant's build files are written in XML and take advantage of the open standard, portable and easy to understand nature of XML. For more detail kindly check
Why do you need a build tool?
Before diving deep into the definition of Apache Ant, one must understand the need for a build tool. Why do I need Ant, or more specifically, why do I need a build tool? Do you spend your day doing the following manually?
Package the binaries
Deploy the binaries to the test server
Test your changes
Copy code from one location to another
If you have answered yes to any of the above, then it is time to automate the process and take away that burden from you.
On average, a developer spends 3 hours (out of a 8 hour working day) doing mundane tasks like build and deployment. Wouldn't you be delighted to get back the 3 hours? Enter Apache Ant. Apache Ant is an operating system build and deployment tool that can be executed from a command line.
Features of Apache Ant
Ant is the most complete Java build and deployment tool available. Ant is platform neutral and can handle platform specific properties such as file separators.
Ant can be used to perform platform specific tasks such as modifying the modified time of a file using 'touch' command.
Ant scripts are written using plain XML. If you are already familiar with XML, you can learn Ant pretty quickly.
Ant is good at automating complicated repetitive tasks.
Ant comes with a big list of predefined tasks.
Ant provides an interface to develop custom tasks.
Ant can be easily invoked from the command line and it can integrate with free and commercial IDEs.
Installing Apache Ant
It is assumed that you have already downloaded and installed Java Development Kit (JDK) on your computer. If not, please follow the instructions here.
Apache Ant is distributed under the Apache Software License, a fully-fledged open source license certified by the open source initiative.
The latest Apache Ant version, including full-source code, class files and documentation can be found at http://ant.apache.org.
Tutorials Point, Simply Easy Learning
Ensure that the JAVA_HOME environment variable is set to the folder where your JDK is installed.
Download the binaries from http://ant.apache.org
Unzip the zip file to a convenient location using Winzip, winRAR, 7-zip or similar tools, say c:\ folder.
Create a new environment variable called ANT_HOME that points to the Ant installation folder, in this case c:\apache-ant-1.8.2-bin folder. Append the path to the Apache Ant batch file to the PATH environment variable. In our case this would be the c:\apache-ant-1.8.2-bin\bin folder.
Ant - Build Files
Typically, Ant's build file, build.xml should live in the project's base directory. Although you are free to use other file names or place the build file in some other location. For this exercise, create a file called build.xml anywhere in your computer.
Hello World - Welcome to Apache Ant!
Please note that there should be no blank lines or whitespaces before the xml declaration. If you do, this may cause an error message when running the ant build - The processing instruction target matching "[xX][mM][lL]" is not allowed.
All buildfiles require the project element and at least one target element. The XML element project has three attributes :
The Name of the project. (Optional)
The default target for the build script. A project may contain any number of targets. This attribute specifies which target should be considered as the default....