TomcatAntTasks

HomePage | RecentChanges | Preferences

Using the Catalina Ant Tasks to Install/Stop/Start/Remove/Reload Webapps on Tomcat

Install Ant and the Catalina Ant tasks: Ant

Note: On recent versions of Tomcat I think you have to download the Manager app separately.

Modify tomcat-users.xml

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="tomcat"
  <role rolename="manager"/>
  <user username="user" password="pass" roles="manager,tomcat"/>
</tomcat-users>
(I think only the 'manager' role is required...)

In build.xml:


   <property name="manager.url" value="http://localhost/manager" />
   <property name="manager.username" value="user" />
   <property name="manager.password" value="pass" />
   <property name="context" value="contextName" />

   <!-- On Windows, install.file must be a full path with drive letter, not \\server\folder\ -->
   <property name="install.file" value="file://E:\path\to\project\webapp" />
   
 <!-- these require the file catalina-ant.jar 
	(found in /path/to/tomcat/server/lib)
   to be placed in the /path/to/ant/lib directory --> 
  <taskdef name="install" classname="org.apache.catalina.ant.InstallTask" /> 
  <taskdef name="list" classname="org.apache.catalina.ant.ListTask" /> 
  <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask" /> 
  <taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask" />
  <taskdef name="stop" classname="org.apache.catalina.ant.StopTask" /> 
  <taskdef name="start" classname="org.apache.catalina.ant.StartTask" /> 

  <target name="reload" description="Reload Web application" depends="init">
     <reload url="${manager.url}" username="${manager.username}" 
      password="${manager.password}" path="/${context}"/>
  </target>
  
  <target name="stop" description="Stop Web application" depends="init">
     <stop url="${manager.url}" username="${manager.username}" 
      password="${manager.password}" path="/${context}"/>
  </target>
  
    <target name="start" description="Start Web application" depends="init">
     <start url="${manager.url}" username="${manager.username}" 
      password="${manager.password}" path="/${context}"/>
  </target>

  <target name="install" depends="init" description="Install application to servlet container">
  <install url="${manager.url}" username="${manager.username}" 
           password="${manager.password}" path="/${context}" war="${install.file}" /> 
  </target>
  
  <target name="remove" depends="init" description="Remove application on servlet container">
  <remove url="${manager.url}" username="${manager.username}" 
          password="${manager.password}" path="/${context}" /> 
  </target>


HomePage | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited August 10, 2005 10:32 am by WendySmoak (diff)
Search: