Ant Basic

Ant Basic


Ant (originally an acronym for Another Neat Tool), is a build tool with special support for the Java programming language but can be used for just about everything. Ant is platform-independent; it is written purely in Java. Ant is particularly good at automating complicated repetitive tasks and thus is well suited for automating



Ant Installation


Configuration for Windows Environment

1. Download latest binary zip from http://jakarta.apache.org/ant/.
2. Unzip Binary in any folder, in my end it unzip on c:\
E.g. C:\apache-ant-1.7.0
3. Setting Environment variable: Right Click on My Computer ->Properties->Advanced tab->Environment variable->Create User variable
Variable
Value
ANT_HOME
C:\apache-ant-1.7.0
Path
%JAVA_HOME%\bin; %ANT_HOME%\bin; %ANT_HOME%\lib;
4. on command-line type c:\ant to verify proper configuration

Working with Ant


For typical Java Project building By Ant script


1. To create test project here is common folder and file
src: For project source files.
build.xml: ant script for clean/compile/create jar etc.. file
2. add a simple java class HelloWorld.java in src/com/myapp
package com.myapp;

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
3. By default Ant uses build.xml as the name for a buildfile, so our .\build.xml would be:



Note: plz remove br tag

4. on command promt type c:testprj>ant compile
It will create a new folder named build, having the entire compile file from the source folder

Creating a jar-file

Creating a jar-file is not very difficult. But creating a startable jar-file needs more steps: create a manifest-file containing the start class, creating the target directory and archiving the files.


Note: plz remove br tag


Creating a War-file

for typical eclipse web project the folder structure is
testProject
-src : For Project source file
-WebContent
-- WEB-INF
---- lib : For compiled/output files produced (by Ant).
---- web.xml
-- META-INF
-- html/jsp/css/javascript files

to create a ant script add build.xml






Note: plz remove br tag

Comments

Popular posts from this blog

Maven in 5 Minutes

Groovy On Grails setup on windows