khaleel. Powered by Blogger.

what-is-ant-and-how-can-one-configure?

Thursday 2 June 2011

ANT is a Java based build tool and helps in automating whole of build process of a Java project.
ANT uses an XML build file and by default it looks for a build file named build.xml from the directory it has been executed.

A build.xml contains several targets e.g. creating or deleting directory structure, post compilation creation of jar or ear files, extracting/unzipping jar/ear files etc.One target can depend upon one or more targets and it can contain one or more tasks.

One can download Apace Ant 1.7.1 from here.Once that is done, extract it any of your local drive. Set the system variables as follows:

ANT_HOME =D:\apache-ant-1.7.1 (Here I have extracted the ANT ZIP at D drive)
PATH = %ANT_HOME%\bin

To ensure proper installation of ANT, go to command prompt and execute the command "ant - version", you will see the installed ant version.

The execution of ANT file is done from the directory where build.xml resides and simply typing ant command on console and hit enter will start the execution of build file.

The build.xml looks like as given below:


Compilation Complete! Building .jar file Complete!

In the build.xml, element is the root element, name attribute of this represents the name of the project.

element can exist multiple times within project element and each one of them represents a single stage. In the above build.xml, we have compile target element which contains two tasks, one - and the other which builds java files.

The other target element 'compress' is dependent upon compile target element. It creates a jar file which includes all the .class files in current directory.

The echo tasks just display messages on console.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
Promote Your Blog

About This Blog

This blog is for java lovers

Total Pageviews

About Me

khaleel-bapatla
BAPATLA, ap, India
simple and honest
View my complete profile

  © Blogger template On The Road by Ourblogtemplates.com 2009

Back to TOP