Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

An ANT script [ build.xml] for ranchers  RSS feed

Bahadar Khan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I am copying here an ant script that I use while studying HF book. It will make your work of building and deploying a WAR file in Tomcat container easy and save you a lots of time.


0: Create a main project directory say HFExample
1: Put your *.java source file in under HFExample/src
2: Put your html, jsp files uder HFExample/jsp
3: Put your web.xml file under HFExample/conf
4: Copy this ( build.xml ) under root HFExample
5: Type under your project root directory :/HFExample/ANT [Press ENTER}


*It will create necessary directory structure
* Copy the files under proper web application structure
* Make a project_name.war ( in this case HFExample.war )
* deploy your application in the Tomcat

*** You can use this script in your subsequent projects, just change the project name and its location each time you want to use it in new projects by changing name in line 2 & 3.*****

<project default="init">

<property name="" value="HF8"/>
<property name="" location="./HF8"/>
<property name="src.dir" location="./src"/>
<property name="bin.dir" location="${}/WEB-INF/classes"/>
<property name="server.dir" location="E:\Tomcat\jakarta-tomcat-5.0.28\webapps"/>
<property name="conf.dir" location="./conf"/>
<property name="html.dir" location="./jsp"/>

<property name="" location="${server.dir}/${}"/>

<!-- Make Necessary Directories -->

<target name="make_dir">
<mkdir dir="${}"/>
<mkdir dir="${bin.dir}"/>

<!-- Compilation -->

<target name="compile" depends="make_dir">
<javac srcdir="${src.dir}" destdir="${bin.dir}"/>

<!-- Make Web Application -->

<target name="assemble" depends="compile">
<copy file="${conf.dir}/web.xml" todir="${}/WEB-INF"/>
<copy todir="${}">
<fileset dir="${html.dir}"/>

<!-- Make War File -->

<target name="jarup" depends="assemble">
<delete file="${}.war"/>
<jar destfile="${}.war" basedir="${}" includes="**/*.*"/>

<!-- Deploy To Server -->

<target name="deploy" depends="jarup">
<delete file="${server.dir}/${}.war"/>
<delete dir="${}"/>
<copy file="${}.war" todir="${server.dir}"/>

<target name="init" depends="deploy"/>



  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!