Tomcat 5 Application Server Module

Public Targets

TargetDescription
deploydeploys war to tomcat
undeployremoves webapp from tomcat
redeployreload already deployed webapp on tomcat
fdeploycopy deployment folder to tomcat
fundeployremoves deployment folder from tomcat
jspccompile JSPs
appcgenerate/compile JSP/EJB support files - not implemented
startstart tomcat server
stopstop tomcat server
listlist deployed apps

Source: appserver-tomcat5.xml

				<?xml version="1.0" encoding="UTF-8"?>
<project name="appserver">
	<description>
  + ==\_/============J=A=V=A=G=E=N===A=N=T===M=O=D=U=L=E=S================= +
  +  \(_)/                                                                  +
  +  -(_)-            Tomcat 5 Application Server Module                    +
  +  /(_)\                                                                  +
  + ======================================================================= +
  +    Copyright (c) 2002-2005 Outsource Cafe, Inc.  All rights reserved.   +
  + ======================================================================= +
  +
  + Public targets: 
  +    deploy      - deploys distribution file to server
  +    undeploy    - removes distribution file from server
  +    fdeploy     - folder deploys expanded app to server
  +    fundeploy   - folder undeploy removes expanded app from server
  +    redeploy    - redeploys distribution to server
  +    start       - starts application server
  +    stop        - stops application server
  +    jspc        - server-specific JSP compiler
  +
  + Support targets: 
  +    started     - sets 'server.started' if server is running
  +    stopped     - sets 'can.end' if server running and not 'server.started' 
  +                  avoiding stops on servers up before testcycle initiation
  +
  + Required properties:
  +   dist.name    - the distribution file name, should be predefined.
  +   dist.dir     - the loaction of jar/war files, should be predefined.
  +
  + Notes: You must add 'manager' permission to the user defined by 'tomcat.username'
  + or you will receive a 'Server returned HTTP response code: 403' exception.
  + Users and permissions are defined in ${tomcat.home}/conf/tomcat-users.xml.
  +
  + Tested on: jakarta-tomcat-5.0.24 and jakarta-tomcat-5.5.7
  +
  + developer: RichardEasterling@OutsourceCafe.com
  + ======================================================================= +
  + Licensed under the Apache License, Version 2.0 (the "License");
  + you may not use this file except in compliance with the License.
  + You may obtain a copy of the License at
  +
  +   http://www.apache.org/licenses/LICENSE-2.0
  +
  + Unless required by applicable law or agreed to in writing, software
  + distributed under the License is distributed on an "AS IS" BASIS,
  + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + See the License for the specific language governing permissions and
  + limitations under the License.
  + =J=A=M===========================================J=A=V=A=G=E=N=.=C=O=M= +
	</description>
	<!-- notes:
		depricated tasks: InstallTask, RemoveTask
	-->
	<property name="APPSERVER.PRESENT" value="true"></property>
	<property name="TOMCAT5.PRESENT" value="true"></property>
	<!-- =================================================================== -->
	<!-- public targets: -->
	<!-- =================================================================== -->
	<target name="deploy" depends="-deploy" description="deploys war to tomcat "></target>
	<target name="undeploy" depends="-undeploy" description="removes webapp from tomcat"></target>
	<target name="redeploy" depends="-redeploy" description="reload already deployed webapp on tomcat"></target>
	<target name="fdeploy" depends="-fdeploy" description="copy deployment folder to tomcat "></target>
	<target name="fundeploy" depends="-undeploy" description="removes deployment folder from tomcat "></target>
	<target name="jspc" depends="-jspc" description="compile JSPs"></target>
	<target name="appc" depends="" description="generate/compile JSP/EJB support files - not implemented"></target>
	<target name="start" depends="started, -start" description="start tomcat server"></target>
	<target name="stop" depends="stopped, -stop" description="stop tomcat server"></target>
	<target name="list" depends="-list" description="list deployed apps"></target>
	<!-- ==================================================================== -->
	<!-- Tomcat directory and classpath properties: -->
	<!-- ==================================================================== -->
	<!-- tomcat.home must be set, try getting the environmental variable -->
	<condition property="tomcat.home" value="${env.CATALINA_HOME}">
		<isset property="env.CATALINA_HOME"></isset>
	</condition>
	<fail unless="tomcat.home">'tomcat.home' is not set. Set the 'tomcat.home' property or create an environmental variable called 'CATALINA_HOME' pointing to the top-level Tomcat installation directory.</fail>
	<property name="tomcat.base" location="${tomcat.home}"></property>
	<property name="tomcat.tmpdir" location="${tomcat.base}/temp"></property>
	<property name="tomcat.endorsed" location="${tomcat.home}/common/endorsed"></property>
	<property name="tomcat.lib.dir" location="${tomcat.home}/server/lib"></property>
	<property name="tomcat.client.dir" location="${tomcat.home}/common/lib"></property>
	<property name="catalina-ant.jar" location="${tomcat.home}/server/lib/catalina-ant.jar"></property>
	<property name="bootstrap.jar" location="${tomcat.home}/bin/bootstrap.jar"></property>
	<path id="tomcat.classpath">
		<pathelement path="${java.class.path}"></pathelement>
		<pathelement location="${catalina-ant.jar}"></pathelement>
		<path refid="dependencies.classpath"></path>
	</path>
	<path id="appserver.client.classpath">
		<fileset dir="${tomcat.client.dir}">
			<include name="*.jar"></include>
		</fileset>
	</path>
	<path id="jspc.classpath">
		<fileset dir="${tomcat.home}/bin">
			<include name="*.jar"></include>
		</fileset>
		<fileset dir="${tomcat.lib.dir}">
			<include name="*.jar"></include>
		</fileset>
		<path refid="appserver.client.classpath"></path>
		<pathelement path="${java.class.path}"></pathelement>
		<path refid="dependencies.classpath"></path>
	</path>
	<property name="jspc.src.dir" location="${build.web.webinf.dir}/src"></property>
	<property name="jspc.servlets.dir" location="${build.web.webinf.dir}"></property>
	<property name="jspc.servlets.frag" location="${jspc.servlets.dir}/generated_web.xml"></property>
	<echo>jspc.servlets.frag = ${jspc.servlets.frag}</echo>
	<!-- Configure properties to access the Manager application -->
	<property name="tomcat.url" value="http://localhost:8080/manager"></property>
	<property name="tomcat.username" value="tomcat"></property>
	<property name="tomcat.password" value="tomcat"></property>
	<!--
	<property name="jspc.servlets.frag" location="${build.web.webinf.dir}/generated_web.xml"/>
	-->
	<!-- ==================================================================== -->
	<!-- standard application server settings -->
	<!-- ==================================================================== -->
	<property name="appserver.name" value="Tomcat"></property>
	<property name="appserver.version" value="5.x"></property>
	<property name="appserver.deploy.dir" location="${tomcat.home}/webapps"></property>
	<property name="appserver.http.port" value="8080"></property>
	<property name="appserver.host" value="localhost"></property>
	<!-- adjust delays (in seconds) according to deployment speed: -->
	<property name="appserver.start.delay" value="15"></property>
	<property name="appserver.deploy.delay" value="15"></property>
	<property name="appserver.post.stop.delay" value="4"></property>
	<!-- used in Log4J config. to determine log file locations: -->
	<property name="appserver.log.folder" value="${tomcat.home}/logs/"></property>
	<!-- ==================================================================== -->
	<!-- Tomcat manager application taskdefs: -->
	<!-- ==================================================================== -->
	<taskdef name="deploy" classpathref="tomcat.classpath" classname="org.apache.catalina.ant.DeployTask"></taskdef>
	<taskdef name="list" classpathref="tomcat.classpath" classname="org.apache.catalina.ant.ListTask"></taskdef>
	<taskdef name="reload" classpathref="tomcat.classpath" classname="org.apache.catalina.ant.ReloadTask"></taskdef>
	<taskdef name="resources" classpathref="tomcat.classpath" classname="org.apache.catalina.ant.ResourcesTask"></taskdef>
	<taskdef name="roles" classpathref="tomcat.classpath" classname="org.apache.catalina.ant.RolesTask"></taskdef>
	<taskdef name="start" classpathref="tomcat.classpath" classname="org.apache.catalina.ant.StartTask"></taskdef>
	<taskdef name="stop" classpathref="tomcat.classpath" classname="org.apache.catalina.ant.StopTask"></taskdef>
	<taskdef name="undeploy" classpathref="tomcat.classpath" classname="org.apache.catalina.ant.UndeployTask"></taskdef>
	<taskdef name="jasper2" classpathref="jspc.classpath" classname="org.apache.jasper.JspC"></taskdef>
	<!-- ==================================================================== -->
	<!-- standard client properties -->
	<!-- ==================================================================== 
	<property name="appserver.java.naming.factory.initial" value="org.jnp.interfaces.NamingContextFactory"/>
	<property name="appserver.java.naming.provider.url" value="jnp://localhost:1099"/>
	<property name="appserver.java.naming.factory.url.pkgs" value="org.jboss.naming:org.jnp.interfaces"/>
	-->
	<!--=====================================================================-->
	<!--list tomcat/jasper classpath-->
	<!--=====================================================================-->
	<target name="tomcat.cp">
		<pathconvert pathsep="${CR}" refid="tomcat.classpath" property="tomcat.classpath.list"></pathconvert>
		<echo message="+ tomcat.classpath======================================+ +"></echo>
		<echo message="${tomcat.classpath.list}"></echo>
	</target>
	<target name="jspc.cp">
		<pathconvert pathsep="${CR}" refid="jspc.classpath" property="jspc.classpath.list"></pathconvert>
		<echo message="+ jspc.classpath======================================+ +"></echo>
		<echo message="${jspc.classpath.list}"></echo>
	</target>
	<!-- ==================================================================== -->
	<!-- depricated targets: -->
	<!-- ==================================================================== -->
	<target name="check.appserver">
		<echo>DEPRICATED, checks now in-lined</echo>
	</target>
	<!-- =================================================================== -->
	<!-- deploy archive (war) to server  -->
	<!-- =================================================================== -->
	<target name="-deploy">
		<echo>deploy: ${dist.dir}/${dist.name} to ${webapp.context} context</echo>
		<deploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="${webapp.context}" war="${dist.dir}/${dist.name}"></deploy>
	</target>
	<!-- =================================================================== -->
	<!-- undeploy archive (war) from server -->
	<!-- =================================================================== -->
	<target name="-undeploy">
		<echo>undeploy: ${webapp.context}</echo>
		<undeploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="${webapp.context}"></undeploy>
	</target>
	<!-- =================================================================== -->
	<!-- reload war without stopping server, web.xml not re-read -->
	<!-- =================================================================== -->
	<target name="-redeploy">
		<echo>redeploy: ${webapp.context}</echo>
		<reload url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="${webapp.context}"></reload>
	</target>
	<!-- =================================================================== -->
	<!-- list webapps on server -->
	<!-- =================================================================== -->
	<target name="-list">
		<echo>list: </echo>
		<list url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}"></list>
	</target>
	<!-- =================================================================== -->
	<!-- deploy unpacked files to server -->
	<!-- =================================================================== -->
	<target name="-fdeploy">
		<deploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="${webapp.context}" localWar="file://${build.web.dir}"></deploy>
	</target>
	<!-- =================================================================== -->
	<!-- server started check, sets server.started if already running -->
	<!-- =================================================================== -->
	<target name="started">
		<condition property="server.started">
			<and>
				<socket port="${appserver.http.port}" server="${appserver.host}"></socket>
			</and>
		</condition>
		<echo>server.started = ${server.started}</echo>
	</target>
	<!-- =================================================================== -->
	<!-- start jboss -->
	<!-- =================================================================== -->
	<target name="-start" unless="server.started">
		<echo>Using CATALINA_BASE:   ${tomcat.base}</echo>
		<echo>Using CATALINA_HOME:   ${tomcat.home}</echo>
		<echo>Using CATALINA_TMPDIR: ${tomcat.tmpdir}</echo>
		<java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
			<jvmarg value="-Djava.endorsed.dirs=${tomcat.endorsed}"></jvmarg>
			<jvmarg value="-Dcatalina.base=${tomcat.base}"></jvmarg>
			<jvmarg value="-Dcatalina.home=${tomcat.home}"></jvmarg>
			<jvmarg value="-Djava.io.tmpdir=${tomcat.tmpdir}"></jvmarg>
			<arg value="start"></arg>
			<classpath>
				<pathelement location="${tools.jar}"></pathelement>
				<pathelement location="${bootstrap.jar}"></pathelement>
			</classpath>
		</java>
	</target>
	<!-- =================================================================== -->
	<!-- server pre-stop check, sets can.end if server is running -->
	<!-- =================================================================== -->
	<target name="stopped">
		<condition property="can.end">
			<and>
				<socket port="${appserver.http.port}" server="${appserver.host}"></socket>
				<not>
					<isset property="server.started"></isset>
				</not>
			</and>
		</condition>
		<echo>can.end = ${can.end}</echo>
	</target>
	<!-- =================================================================== -->
	<!-- stop jboss -->
	<!-- =================================================================== -->
	<target name="-stop" if="can.end">
		<echo>Using CATALINA_BASE:   ${tomcat.base}</echo>
		<echo>Using CATALINA_HOME:   ${tomcat.home}</echo>
		<echo>Using CATALINA_TMPDIR: ${tomcat.tmpdir}</echo>
		<java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
			<jvmarg value="-Djava.endorsed.dirs=${tomcat.endorsed}"></jvmarg>
			<jvmarg value="-Dcatalina.base=${tomcat.base}"></jvmarg>
			<jvmarg value="-Dcatalina.home=${tomcat.home}"></jvmarg>
			<jvmarg value="-Djava.io.tmpdir=${tomcat.tmpdir}"></jvmarg>
			<arg value="stop"></arg>
			<classpath>
				<pathelement location="${tools.jar}"></pathelement>
				<pathelement location="${bootstrap.jar}"></pathelement>
			</classpath>
		</java>
		<echo>sleeping ${appserver.post.stop.delay}s...</echo>
		<sleep seconds="${appserver.post.stop.delay}"></sleep>
	</target>
	<!-- =================================================================== -->
	<!-- jasper jspc -->
	<!-- =================================================================== -->
	<target name="-jspc">
		<mkdir dir="${jspc.servlets.dir}"></mkdir>
		<jasper2 validateXml="false" uriroot="${build.web.dir}" webXmlFragment="${jspc.servlets.frag}" outputDir="${jspc.src.dir}"></jasper2>
		<mkdir dir="${build.classes.dir}"></mkdir>
		<javac destdir="${build.classes.dir}" target="${compiler.target}" source="${compiler.source}" classpathref="jspc.classpath" debug="${compiler.debug}" deprecation="${compiler.deprecation}" optimize="${compiler.optimize}" compiler="${compiler.type}" excludes="${compiler.excludes}">
			<src path="${jspc.src.dir}"></src>
			<patternset refid="source.modifications.patternset"></patternset>
		</javac>
	</target>
	<!-- =================================================================== -->
	<!-- jasper delete JSPs, JSP servlet source -->
	<!-- =================================================================== -->
	<target name="jsp.delete">
		<delete failonerror="false">
			<fileset dir="${build.web.dir}">
				<include name="**/*.jsp"></include>
			</fileset>
		</delete>
		<delete failonerror="false">
			<fileset dir="${jspc.src.dir}"></fileset>
		</delete>
		<delete dir="${jspc.src.dir}" failonerror="false"></delete>
		<delete file="${jspc.servlets.frag}" failonerror="false"></delete>
	</target>
</project>