Showing posts with label build.xml. Show all posts
Showing posts with label build.xml. Show all posts

Thursday, 28 August 2014

A sample ant build script and its explaination

A sample build script is given below . Please refer comments for explaination

<?xml version="1.0" ?>
<!-- Default compilation action for ant build -->
<project name="<Your application>" default="compile">
<path id="compile.classpath">
<fileset dir="WEB-INF/lib">
<include name="*.jar"/>
</fileset>
</path>
<!-- init target for ant build -->
<!-- creates classes , conf , dist folders. -->
<target name="init">
<delete dir="WEB-INF/classes"/>
<mkdir dir="WEB-INF/classes/conf"/>
<mkdir dir="dist" />
</target>
<!-- As specified in project tag default action in build will be called -->
<target name="compile" depends="init" >
<!-- Compile all classes and copy them to WEB-INF/classes -->
<javac destdir="WEB-INF/classes" debug="true" srcdir="src">
<classpath refid="compile.classpath"/>
</javac>

<copy todir="WEB-INF/classes">
<fileset dir="conf"/>
</copy>
</target>
<!-- Compile and package the classes to a war -->
<target name="war">
<war destfile="dist/s31.war" webxml="WEB-INF/web.xml">
<fileset dir="../dist"/>
<lib dir="WEB-INF/lib"/>
<classes dir="WEB-INF/classes"/>
</war>
</target>
</project>