• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

An ANT script [ build.xml] for ranchers

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

WHAT IT EXPECTS:

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}

WHAT IT DOES:

*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="app.name" value="HF8"/>
<property name="web.app" location="./HF8"/>
<property name="src.dir" location="./src"/>
<property name="bin.dir" location="${web.app}/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="app.dos.name" location="${server.dir}/${app.name}"/>

<!-- Make Necessary Directories -->

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



<!-- Compilation -->

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



<!-- Make Web Application -->

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



<!-- Make War File -->

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





<!-- Deploy To Server -->

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


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


</project>


cheers

-Bahadar
reply
    Bookmark Topic Watch Topic
  • New Topic