Apache ANT

Apache Ant is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications. Ant supplies a number of built-in tasks allowing to compile, assemble, test and run Java applications. Ant can also be used effectively to build non Java applications, for instance C or C++ applications. More generally, Ant can be used to pilot any type of process which can be described in terms of targets and tasks.

Ant is written in Java. Users of Ant can develop their own "antlibs" containing Ant tasks and types, and are offered a large number of ready-made commercial or open-source "antlibs".

Ant is extremely flexible and does not impose coding conventions or directory layouts to the Java projects which adopt it as a build tool.

Java should configured

1) mkdir -p apache-ant

2) [root@rhel6 webmin-1.791]# cd /usr/apache-ant/


Download tar file

http://olex.openlogic.com/packages/ant/1.9.2

[root@rhel6 apache-ant]# ls
apache-ant-1.9.6-bin.tar.gz
[root@rhel6 apache-ant]#


3) tar -xvzf apache-ant-1.9.6-bin.tar.gz


[root@rhel6 apache-ant]# ls
apache-ant-1.9.6  apache-ant-1.9.6-bin.tar.gz
[root@rhel6 apache-ant]#


[root@rhel6 apache-ant]# cd apache-ant-1.9.6
[root@rhel6 apache-ant-1.9.6]# ls
bin           contributors.xml  fetch.xml   INSTALL  lib      manual  patch.xml  WHATSNEW
CONTRIBUTORS  etc               get-m2.xml  KEYS     LICENSE  NOTICE  README
[root@rhel6 apache-ant-1.9.6]# cd bin/
[root@rhel6 bin]# ls
ant      ant.cmd     antRun      antRun.pl            envset.cmd  runant.pl  runrc.cmd
ant.bat  antenv.cmd  antRun.bat  complete-ant-cmd.pl  lcp.bat     runant.py
[root@rhel6 bin]# 


4) vim /etc/bashrc
export JAVA_HOME=/usr/java/jdk1.7.0_21/
export PATH=$PATH:${JAVA_HOME}/bin/java
export ANT_HOME=/usr/apache-ant/apache-ant-1.9.6/
export PATH=$PATH:${ANT_HOME}/bin/ant


5)source /etc/bashrc


[root@rhel6 bin]# ant
Buildfile: build.xml does not exist!
Build failed





Sample Build Example file

create sample build.xml file

[root@master tmp]# cat build.xml

   <project name="My Project" default="hello">
       <target name="hello">
          <echo>Hello World!</echo>
       </target>
   </project>
[root@master tmp]#


[root@master tmp]# ant 
Buildfile: /tmp/build.xml

hello:
     [echo] Hello World!

BUILD SUCCESSFUL
Total time: 0 seconds

[root@master tmp]# 

No comments:

Post a Comment