Ant Scripts

In this post I want to share few things about Ant Scripts.
Why do we need an Ant script
I feel the ultimate use of this scripting language is compiling/building a large collection of source files as a batch in a controlled manner.
What is an Ant Script An Ant script is an XML configuration file that calls out a target tree where various tasks get executed with the basic aim of building source files. Each buildfile contains one project and at least one (default) target. Targets contain task elements. Each task element of the buildfile can have an attribute and can later be referred to by the value supplied to this. The value has to be unique.
Target A Target holds a collection of tasks and may depend on other tasks. The dependency among the targets are specified using the depends attribute. Multiple targets can be specified using comma as separator. The flow of Ant project depends on the starting/First target that is called.
Commonly used targets are compile, test, clean etc.,
Example: Below one is a fine example that illustrates the flow and dependency among the targets.
target name="A"
target name="B" depends="A"
target name="C" depends="B"
target name="D" depends="C, B, A"
Suppose we call the target D first. The following holds good.
  • A is the first target that is executed
  • Order of execution is A->B->C and finally D.
  • Each target is executed only once.

Task A Task does the work of the Ant script, such as running javac, java etc.
Each Ant build project mainly contains two segments .First one that property setting section that specifies the classpath, Base directory etc and the Second one actual targets.

Installing Ant
Check whether Ant installed on your machine by running the command “Ant” in the command prompt. If it outputs something like this you need install Ant.

1)Ant download is not a installable application.It includes a set of executables,library files etc that can be copied to any desired location.
2)Ant can be downloaded from the Apache website that regulates it. Below is the pointer to it. Ant Download.
3)Now extract all the files to a directory.I usually extract them to "c:\Ant" directory.
4)Make sure Java is installed on your machine.( Say the path is " C:\jdk1.3.1")
5)Now add these as part of the environment variables.To do it ,right click on the 'My Computer'.Navigate to 'Advanced Tab',Click 'Environment Variables' and try to add new.
6)Try to add the below two environment variables "ANT_HOME" and "JAVA_HOME".For assistance see the below pictures.








Now try to run the “Ant -v“at the command prompt. It should output the version.

Additional Plugin Jars
Ant doesn’t support certain tasks or attributes that are often needed in easy developing of build scripts. For example the task repeatedly executes a series of tasks that does compilation or execution. Ant doesn’t come with this support. So we need to add it to the library of jars in the ANT_HOME manually.
Here we need “ant-contrib-0.2.jar”. Here is the pointer to the jar file
http://cvs.sourceforge.net/viewcvs.py/xmoon/struts-demo/WEB-INF/lib/ .

Note: The above jar doesn’t support trim attribute.

Basics of Ant Usage
By now assume Ant s properly installed and the Paths are set properly. Now lets see how it can be used.
Ant is usually executed at the command prompt. The following points demo the usage of Ant.
1) By just running the Ant at the command prompt, it assumes Build.xml as the default argument and tries to run the build.xml file located in the current directory.
i.e. Ant at command prompt is similar to “Ant Build.xml”

2) To run a user defined build file say build_abc.xml the ‘-buildfile’ option need to be used.
Ex: Ant -buildfile build_abc.xml

3) Now lets see how the targets inside the build file are called once we invoke the buildfile.The first target with which the execution to be started is usually said using the default attribute in the project definition tag.
Ex: - <project name="EnterpriseOne" default="dist" basedir=".">
In the above case default attribute says dist is the first target to be called by default. Ant will determine the flow among the targets based on the depends attribute specified in the dist target.

4) To call a specific target, the name of the target should be specified as an argument.
Ex:
1) “Ant execute” asks the Ant to start with target execute first.(This is for default build.xml)
2) “Ant –buildfile build_abc.xml execute”, means the target named execute is called first from the build_abc.xml.

More Info
Ant Resources
Ant Download


New Referrals in Google Adsense

Go and check your Adsense account, you should be able to see 1 or 2 new referral products added.You get cool $ too for that.

WAP Directory

News
BBC :BBC UK - http://bbc.co.uk/mobile
The Wall Street Journal: http://wap.wsj.com/
Ananova : http://wap.ananova.com/
Business Standard : http://www.bs-mobile.com/index.jsp

Sports

ESPN : http://wap.espn.com
Live Cricket Scores : http://wap.ananova.com/sport
CricInfo.com : http://mobile.cricinfo.com/
MSNBC : http://msnbc.com

EMAIL/Messengers
Yahoo : http://wap.yahoo.com
Google : http://wap.google.com
Rediff - http://mobile.rediff.com
Hotmail - http://mobile.msn.com
Yahoo Messenger - http://mm.yahoo.com
GMail :http://m.gmail.com
IndiaTimes : http://wap.indiatimes.com

Internet
Check Domain Name - http://wap.checkdomain.com
Wapedia -Mobile Wikipedia - http://en.wapedia.org/
Flickr Mobile - http://www.flickr.com/mob/
Opera Mini -Browser for your mobile
Opera Mini button

Tech
iPod Lounge http://www.ipodlounge.com/mobile.php
The-Gadgeteer http://www.the-gadgeteer.com/mobile.html
GadgetAddict : http://www.gadgetaddict.com/mobile/

Health
Pocket Doctor - http://wap.pocketdoctor.co.uk
Mediket2000 http://www.mediket2000.com/emerg/ Information on doctors, hospitals, D&N chemists, and bloodbanks in India.
Kevala.com Directory of yoga teachers around the world.Mobile version: http://www.kevala.com/wap/

Travel
Handygo.com Entertainment, travel, transportation, and other information for cities in India. http://www.handygo.com/

Education
1)Virtual Learning Class : Information about free online IT courses, certifications, and e-books offered on the web site. http://wap.vl-class.com/
2)WebElements : Data on the elements of the periodic table. http://www.webelements.com/wapelements/index.wml
3)Webopedia : Dictionary for computers and Internet technology terms. http://wap.webopedia.com/
4)W3Schools : http://www.w3schools.com/wap/

Shopping
Ebay : http://mmm.ebay.com/

Finance/Business
1)FT : http://wap.ft.com
2)BSE India : http://wap.bseindia.com

Misc
1)Blue Dart Express Air express and logistics services provider. Site offers package tracking program.
http://wap.bluedart.com/