Sameer’s Blog

using ant to build application…..

Posted by: seesameer on: March 29, 2008

We need a tool which will help in making application simpler and faster. The answer is ant…

To use ant you should have eclipse or you should get ant

Before installing ant you should have JDK installed. JAVA_HOME should point to appropriate JDK.

Set ANT_HOME to binary distribution of ant.. depending upon your system(Windows,Unix)…

Example : ANT_HOME = D:\sameer\apps\ant

after setting… check in command prompt

ant -version press enter..

You will get this…

 

Sample build file for web application.. which can be used in eclipse…

<?xml version=”1.0″ encoding=”UTF-8″?>
<!– ======================================================================
Date: 29 MAR 2008
project: APPL NAME

Author:Sameer
======================================================================= –>
<project name=”APPL NAME” default=”delete”>
<description>
<!– Description About Project –>
</description>

<target name=”delete” description=”Delete bin,build and deploy directories”>
<delete dir=”bin”/>
<delete dir=”build”/>
<delete dir=”deploy”/>
<echo>Delete was successfull</echo>
</target>

<target name=”init”>
<tstamp />
</target>

<!–Create a build directories–>
<target name=”prepare” description=”Create build directories”>
<mkdir dir=”build” />
<mkdir dir=”build/APPL NAME/WEB-INF/classes” />
<mkdir dir=”build/APPL NAME/WEB-INF/lib” />
<mkdir dir=”build/APPL NAME/gui/jsp”/>
</target>
<!– create bin directories–>
<target name=”bin” description=”Create bin directory” >
<mkdir dir=”bin”/>

</target>

<!–Create Deploy Directories–>
<target name=”deploy” description=”Create deploy directory”>
<mkdir dir=”deploy”/>
</target>

<!–Create Documentaion Directory–>
<target name=”doc” description=”Create Document Directory”>
<mkdir dir=”docs”/>
<mkdir dir=”docs/Architecture”/>
</target>

<!–Create GUI directory–>
<target name=”gui” description=”Create GUI Directory”>
<mkdir dir=”gui”/>
<mkdir dir=”gui/config”/>
<mkdir dir=”gui/jsp”/>
</target>

<!–Create Lib Directory–>
<target name=”lib” description=”Create Lib Directory”>
<mkdir dir=”lib”/>
</target>
<!–Create tld files Directory–>
<target name=”tags” description=”Create tags files Directory”>
<mkdir dir=”tags”/>
</target>
<!–Create Properties–>
<target name=”property” description=”Create Property Directory”>
<mkdir dir=”properties”/>
</target>

<!–Create Source folder Structure–>
<target name=”src” description=”Create Source Directory”>
<mkdir dir=”src”/>
<mkdir dir=”src/org/apps”/>
</target>

<!– Compile all SRC java files –>
<target name=”compile” description=”Compile all java files from src directory and copy class files into bin directory”>
<javac srcdir=”src” destdir=”bin”
debug=”on” deprecation=”off”>
</javac>
</target>

<!–Generate a build path–>
<target name=”copy” description=”Copy all source class files to form a build path”>
<!–copy all gui folder to build structure–>
<copy todir=”build/APPL NAME/gui”>
<fileset dir=”gui/jsp”></fileset>
</copy>

<!–copy all bin class files to build structure–>
<copy todir=”build/APPL NAME/WEB-INF/classes”>
<fileset dir=”bin” excludes=”**/*.java”></fileset>
<fileset dir=”properties”></fileset>
</copy>

<!–copy all liberary files to build structure–>
<copy todir=”build/APPL NAME/WEB-INF/lib”>
<fileset dir=”lib”></fileset>
</copy>

<!–copy all tags files and xml files to build structure–>
<copy todir=”build/APPL NAME/WEB-INF/tags”>
<fileset dir=”tags”></fileset>
<fileset dir=”gui/config”></fileset>
</copy>
</target>

</project>
<!–End of APPL NAME Project–>

Leave a Reply

Blog Stats

  • 607 hits

 

March 2008
M T W T F S S
    Apr »
 12
3456789
10111213141516
17181920212223
24252627282930
31