Ant Build Tool : Quick Notes

Ant Script for JAVA Developers

1) Simple Ant Script for Clean , Compile and jar generation adding Manifest information to jar

   	 init called ..


   	 Delete All Class Files ..

   	 Delete All Jar Files ..

   	 Compile All Java Files ..

   	 Generate Jar File ..

Note :- All folder path are relative to basedir . Here is basedir=”.”
Note :- the values at class-path are separated by space

2) Using Property in Ant Script

   	 Property Value.. ${show}

3) Reading From Property File


4) Current Time Stamp in Ant Script

   	 Current Time is : ${current.time} 

5) Directory Opertaions
Make dir


      Delete Dir
File/Direcotorr Rename

Copy files

6) Ant Script and Svn

SVN Checkout


Note :- for https:/ type svn
7)File uploads and Ant Script



8) Variable of Varible in Ant Scipt


   				 userid is :- ${userid}
   				 password :-${password}
   			 Lifecylce Specific Information Feteched...
   			 Lifecylce Specific Information Feteched...

9)creating war and zip file in ant script


10) Creating Custom Ant Tasks

   	 custom task..
   	 Password Decrypted Successfully... ${sftp.password}

package com.example;


public class AntScriptUtils extends Task {
    private String pass;
    String decryptedPassword = null;

    // The method executing the task
    public void execute() throws BuildException {

   	 try {
   		 decryptedPassword = decrypter.decryptValue(pass);
   		 getProject().setProperty("dPassword", decryptedPassword);

   	 } catch (PropertyEncrypterException e) {
   		 ErrorLogger.fatal("Error : ", e);

    // The setter for the "message" attribute
    public void setMessage(String msg) {
   	 this.pass = msg;

    public static void main(String[] args) {
   	 new AntScriptUtils();


Required Jar files for ant’s different task
antlr-runtime-3.1.3.jar commons-net.jar ganymed.jar jna.jar
jsch-0.1.44.jar sqljet.1.0.4.jar svnant.jar svnClientAdapter.jar
svnjavahl.jar svnkit.jar svnkit-cli.jar
svnkit-javahl.jar trilead.jar

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: