ANT SCRIPTS Tomcat

From Coder's Log

Jump to: navigation, search
<!-- REQUIRED PARAMETERS
	${tomcat} - location of tomcat installation
	${lib} - location of libs 
	${root} - root of the webapp
	${web-inf} - web-inf folder
-->

<project>
	<target name="clean-tomcat">
		<delete dir="${tomcat}/shared/lib" />
		<delete dir="${tomcat}/work" />
		<delete dir="${tomcat}/logs" />
		<delete dir="${tomcat}/temp" />
		<delete dir="${tomcat}/webapps" />
		<delete file="${tomcat}/common/classes/log4j.properties" />
	</target>

	<target name="init-tomcat">
		<mkdir dir="${tomcat}/shared/lib" />
		<mkdir dir="${tomcat}/logs" />
		<mkdir dir="${tomcat}/temp" />
		<mkdir dir="${tomcat}/webapps" />
		<mkdir dir="${web-inf}" />
		<mkdir dir="${web-inf}/lib" />
		<mkdir dir="${web-inf}/classes" />
	</target>

	<target name="compile-tomcat">
		<copy todir="${tomcat}/webapps/ROOT/WEB-INF">
			<fileset dir="${config}/web-inf">
				<include name="**/*" />
			</fileset>		
		</copy>
		<copy todir="${tomcat}/shared/lib">
			<fileset dir="${lib}">
				<include name="*.jar" />
			</fileset>
		</copy>
	</target>

	<target name="start" depends="compile">
		<fail message="Missing env variable" unless="env"/>
		<property file="conf/web-inf/env-${env}.properties"/>	
		<property file="conf/web-inf/env-default.properties"/>							
		<fail message="Missing context variable" unless="context"/>		
		<fail message="Missing shutdown_port variable" unless="shutdown_port"/>		
		<fail message="Missing http_port variable" unless="http_port"/>						
		<exec executable="${tomcat}/bin/catalina.sh">
			<env key="CATALINA_OPTS" value="-server -Xms128m -Xmx128m -Dcom.sun.management.jmxremote -DSHUTDOWN_PORT=${shutdown_port} -DHTTP_PORT=${http_port}" />
			<env key="CATALINA_HOME" value="" />
			<env key="ENV" value="${env}" />	
			<env key="CONTEXT" value="${context}" />
			<env key="agiport" value="${agi_port}" />			
			<arg line="start" />
		</exec>
	</target>

	<target name="stop">
		<fail message="Missing env variable" unless="env"/>
		<property file="conf/web-inf/env-${env}.properties"/>	
		<property file="conf/web-inf/env-default.properties"/>					
		<fail message="Missing shutdown_port variable" unless="shutdown_port"/>		
		<fail message="Missing http_port variable" unless="http_port"/>						
		<exec executable="tomcat/bin/catalina.sh">
			<env key="CATALINA_OPTS" value="-DSHUTDOWN_PORT=${shutdown_port} -DHTTP_PORT=${http_port}" />
			<env key="CATALINA_HOME" value="" />
			<arg line="stop" />
		</exec>
	</target>

	<target name="run" depends="compile">
		<fail message="Missing env variable" unless="env"/>
		<property file="conf/web-inf/env-${env}.properties"/>	
		<property file="conf/web-inf/env-default.properties"/>							
		<fail message="Missing context variable" unless="context"/>		
		<fail message="Missing shutdown_port variable" unless="shutdown_port"/>		
		<fail message="Missing http_port variable" unless="http_port"/>						
		<exec executable="tomcat/bin/catalina.sh">
			<env key="CATALINA_OPTS" value=" -DSHUTDOWN_PORT=${shutdown_port} -Dcom.sun.management.jmxremote -DHTTP_PORT=${http_port}" />
			<env key="CATALINA_HOME" value="${tomcat}" />
			<env key="ENV" value="${env}" />	
			<env key="CONTEXT" value="${context}" />
			<arg line="jpda run" />
		</exec>
	</target>
	
</project>
Personal tools