Sunday, April 3, 2011

Apache Ant in Eclipse

Reference Link: http://www.vogella.de/articles/ApacheAnt/article.html

Ant is a simple Build tool in the form of an XML file used in executing repeatetive build tasks using a single xml document.

Build task such as , Compiling, creating a jar, Running Junit tests, etc...
_____

Installation
:
Ubuntu : On Debian /Ubuntu use "apt-get install ant" to install it.
Windows :

- Download Apache Ant from http://ant.apache.org/ .

- Extract the zip file and Set the "ANT_HOME" environment variable to this location and include the "ANT_HOME/bin" directory in your path.

- Make sure that JAVA_HOME environment variable is set to the JDK, which is required for running Ant.

_____

Test the Installation:

Check your installation by opening a command line and typing "ant -version" into the commend line.

_____

Creating the Ant, build.xml:

-Create a java project with a simple java class file.. say (test.java), which is in a package 1.2.3.test
-Now create an xml file, build.xml , which is your ant file and paste the xml source(in figure below) from section 3.2 of the reference link page into this xml document within this project.

In the source below, the 'Target' tag specifies the task that needs to be executed.

A single build fil ecan have multiple task within it. If your observe the below source, you can see that each target tag consists of a certain execution such as , "Javac" - Compiling java source, "mkdir" - creating directories, etc.

The "depends" attribute of the target tag specifies the other targets that needs to be existing or executed prior to the current specified targets.

Last but not the least, the Ant file can also be used in executing JUnit test.

********************
************************
















































Main target




********************

No comments:

Post a Comment