<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4474677395114963186</id><updated>2012-02-16T20:43:48.917-08:00</updated><category term='ANT'/><title type='text'>Samrat Som's Blog</title><subtitle type='html'>Basically Interested in OpenSource, Java Core, Spring Framework, Web Service Development, NetBeans IDE , Eclipse IDE and ANT Scripting</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://samratsom.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4474677395114963186/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://samratsom.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Samrat Som</name><uri>http://www.blogger.com/profile/04786174422410827586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4474677395114963186.post-7819127470781350283</id><published>2008-10-19T07:52:00.000-07:00</published><updated>2008-10-22T03:51:04.262-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ANT'/><title type='text'>ANT Scripting Making Simple</title><content type='html'>&lt;span style="font-family:arial;"&gt;I am starting my blog with the very interesting build making Tool known as ANT (Another Neat Tool). My aim would be to make a very simple implementation of the ANT tool, so that one can grasp in a wink.&lt;br /&gt;&lt;br /&gt;ANT is basically a &lt;span style="FONT-WEIGHT: bold; FONT-STYLE: italic"&gt;java-based tool&lt;/span&gt; designed to be cross-platform,easy to use, extensible and scalable.It can be used in a small personal project or a large multiteam projects.&lt;br /&gt;&lt;br /&gt;ANT is written in a XML file which has its own parser, that understand the syntax and go ahead with the task crypted in the concerned XML. Each and every Java project needs to have a build.xml file, which defines the task to be performed for the project. Its not mandatory to have the name as build.xml, so it can be user specific.&lt;br /&gt;&lt;br /&gt;Basically, I have implemented the ANT in Netbeans IDE 6.1, but it will be better to start off in the terminal prompt rather than using any specific IDE.&lt;br /&gt;&lt;br /&gt;Now to build a project using ANT tool you need to have ANT installed in your system .Now how to install a ANT can be obtained from the link &lt;span style="FONT-STYLE: italic"&gt;http://ant.apache.org/manual/install.html.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here I will Create a Java class and put it to its desired destination and clean off the unnecessary directories involving in its development .So the steps goes like this :&lt;br /&gt;&lt;br /&gt;1) &lt;span style="FONT-WEIGHT: bold"&gt;Write a Java Program&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;package javaapplication2;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;*&lt;br /&gt;* @author samrat&lt;br /&gt;*/&lt;br /&gt;public class Main {&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* @param args the command line arguments&lt;br /&gt;*/&lt;br /&gt;public static void main(String[] args) {&lt;br /&gt;// TODO code application logic here&lt;br /&gt;System.out.println("ANT building in Process");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;2) &lt;span style="FONT-WEIGHT: bold"&gt;Write a Build.xml&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;project name="JavaApp" default="init" basedir="."&amp;gt;&lt;br /&gt;&amp;lt;description&amp;gt;Builds, tests, and runs the project JavaApplication2.&amp;lt;/description&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;target name="init"&amp;gt;&lt;br /&gt;&amp;lt;mkdir dir="build/classes" /&amp;gt;&lt;br /&gt;&amp;lt;mkdir dir="dist" /&amp;gt;&lt;br /&gt;&amp;lt;/target&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;target name="compile" depends="init"&amp;gt;&lt;br /&gt;&amp;lt;javac srcdir="src" destdir="build/classes"/&amp;gt;&lt;br /&gt;&amp;lt;/target&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;target name="archive" depends="compile" &amp;gt;&lt;br /&gt;&amp;lt;jar destfile="dist/project.jar" basedir="build/classes" /&amp;gt;&lt;br /&gt;&amp;lt;/target&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;target name="clean" depends="archive" &amp;gt;&lt;br /&gt;&amp;lt;delete dir="build" /&amp;gt;&lt;br /&gt;&amp;lt;/target&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/project&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;project basedir="." default="init" name="JavaApp"&gt;&lt;br /&gt;&lt;span style="FONT-WEIGHT: bold"&gt;&lt;/span&gt;&lt;description&gt;&lt;span style="FONT-WEIGHT: bold"&gt;&lt;description&gt;&lt;/description&gt;&lt;/span&gt;&lt;/description&gt;&lt;/project&gt;&lt;/span&gt;Below is the explanation of the build.xml file.&lt;span style="font-family:arial;"&gt;&lt;project basedir="." default="init" name="JavaApp"&gt;&lt;description&gt;&lt;/description&gt;&lt;/project&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Creating required directories:&lt;/span&gt; &lt;span style="font-family:arial;"&gt;&lt;project basedir="." default="init" name="JavaApp"&gt;Here is the simple xml which is with project name as "JavaApp". Each Project has number of task and over only &lt;span style="FONT-WEIGHT: bold"&gt;init&lt;/span&gt; task is explained, which creates two directories build/classes and dist. The above xml file can be executed with the promt &lt;span style="FONT-WEIGHT: bold"&gt;ant&lt;/span&gt;, so it will run the default task as mentioned in the project i.e. init. Individual task can be excetued with the following command  ant &amp;lt;taskname&amp;gt;&lt;taskname&gt;&lt;br /&gt;&lt;/taskname&gt;&lt;/project&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Compile the Source File :&lt;/span&gt; Here the task compile depends upon the init task and it will only get executed if only the init is performed successfully. The java is compiled and put into "build/classes" path.&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Archive the Class :&lt;/span&gt;The compiled class is archived into &lt;span style="FONT-WEIGHT: bold"&gt;project.jar&lt;/span&gt; at &lt;span style="FONT-WEIGHT: bold"&gt;dist&lt;/span&gt; directory.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Delete the build Directory : &lt;/span&gt;The Target clean clears the build directory.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;This is a very simple approach of building a Java project using ANT build tool. I will get back to you with some more interesting applications, once I encounter it.&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;project basedir="." default="init" name="JavaApp"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/project&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4474677395114963186-7819127470781350283?l=samratsom.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samratsom.blogspot.com/feeds/7819127470781350283/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4474677395114963186&amp;postID=7819127470781350283' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4474677395114963186/posts/default/7819127470781350283'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4474677395114963186/posts/default/7819127470781350283'/><link rel='alternate' type='text/html' href='http://samratsom.blogspot.com/2008/10/ant-scripting-making-simple.html' title='ANT Scripting Making Simple'/><author><name>Samrat Som</name><uri>http://www.blogger.com/profile/04786174422410827586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
