2007, June 21 - 10:31 — laseelan
Deploying to Tomcat using ANT
Tomcat Web server for servlets and JSP, has become more attractive to Ant developers since it comes with custom Ant tasks for deployment.
To do this action you need to copy server/lib/catalina-ant.jar from your Tomcat 5 installation into the lib directory of your Ant installation to use these tasks.
The Tomcat deployment tasks are deploy, reload, and undeploy; to use them, add these taskdef elements to your build file
To use these tasks, you'll need manager privileges with Tomcat;
edit conf/tomcat-users.xml to add manager privileges for a username
<?xml version='1.0' encoding='utf-8'?>
You can use the deploy task to deploy a web application to Tomcat from Ant like this
username="${manager.username}"
password="${manager.password}" path="${app.path}"
localWar="file://${build}"/>
Here, manager.url is the URL of the Tomcat manager servlet. The default name for this servlet is "manager", so this is something like http://localhost:8080/manager.The app.path property holds the context path at which this application should be deployed (usually / plus the name of the application as you want to use it in the URL to access the application online). The build property holds the location at which you build the Web application as it should be installed in the Tomcat webapps directory.
If you have installed an application and want Tomcat to recognize you have updated Java classes, use the reload task instead
username="${manager.username}"
password="${manager.password}"
path="${app.path}"/>
To remove a Web application, use the undeploy task
username="${manager.username}"
password="${manager.password}"
path="${app.path}"/>
So go head for a simple tomcat-ant operation
This build.xml will help you for further clarification
description="Prepare for clean build">
basedir="${webroot.dir}"
warfile="${build.dir}/${project.distname}.war"
webxml="${webinf.dir}/web.xml">