ABOUT
Why it is called Ant - According to Ant's original author, James Duncan Davidson, the name is an acronym for "Another Neat Tool".

Tips -
  • Default is build.xml - but you can always give any name you want.
  • The ant build xml file is defined in <project> tag
       <project name="myproj">
       </project>

  • The properties file is mentioned as
       <property file="build.properties"/>
  • If there is any user specific properties file, that should be mentioned before, as the precedence is given preference
  • The ant build file typically consists of one or more targets
       <target name="assemble.all" depends="assemble.ui">
               <echo message="assemble all is called "/>
       </target>
  • A target can have a sub ant task
       <subant genericantfile="${ant.file}" inheritall="true"
                           target="_ui.assemble" failonerror="true">
             <filelist dir="." files="ui"/>
       </subant>
               filelist dir -- all the files in the directory
               file="ui" --  the folder where the files are located
               genericantfile -- means the sub ant task is located in the same file , you can call another file in different location
  •        You can define macros
       <macrodef name="property-join">
           <attribute name="name"/>
           <attribute name="first"/>
           <attribute name="second"/>
           <sequential>
             <property name="@{name}" value="${@{first}@{second}}"/>
           </sequential>
         </macrodef>
       This basically appends to variables and assigns the value to a different variable
  • There are readily available tasks provided by Ant such as
               1. <jar> </jar>
               2. <war> </war> and so on... for more information please refer to Ant project

  • Here is an example for creating a war file

       <war destfile="${build.dir}/myfirst.war"
                webxml="${config.dir}/web.xml"
                basedir="${src.web.dir}"
                duplicate="preserve">
             <!-- All the built classes in the ui tier -->
             <classes dir="${build.classes.dir}"/>

       // adding libraries to the war file
             <!-- add log4j  -->             
              <lib dir="${log4j.lib.dir}/">
              <include name="log4j-1.2.6.jar"/>
              </lib>

       <!-- add struts jars  -->             
              <lib dir="${struts.lib.dir}/">
                     <include name="*.jar"/>
              </lib>
       // adding libraries to the war file
            
             <!-- Tiles tag libraries -->
             <webinf dir="${struts.lib.dir}">
               <include name="struts-tiles.tld"/>
             </webinf>

             <!-- The files from the config directory that need to go into the
             WEB-INF directory -->
             <webinf dir="${config.dir}">
               <include name="*.xml"/>
               <exclude name="*.properties"/>
               <include name="*.tld"/>
               <exclude name="*.configuration.properties"/>
               <exclude name="configuration.xml"/>
               <exclude name="environment.xml"/>
             </webinf>
           </war>
         </target>
Ant Version
Release Date
1.6.4
28 April 2005
1.6.5
2 June 2005
1.7.0
19 December 2006
1.7.1
27 June 2008
Ant Versions
Struts
Ant
TAGS
Narendra Kumar Dantala
A J2EE Developer
Having a masters degree in Computational Science, working in Java, developed applications on different domains such as Finanical Services, B2B, Banking, Utility...