-
Notifications
You must be signed in to change notification settings - Fork 0
/
tomcat-build.xml
103 lines (84 loc) · 3.65 KB
/
tomcat-build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="tomcat-build">
<description>
Script for Controlling Tomcat (to be imported in main build)
</description>
<property environment="env"/>
<condition property="serverloc" value="${env.CATALINA_HOME}" else="C:\Tomcat">
<!--<condition property="serverloc" value="${env.CATALINA_HOME}" else="to_be_defined">-->
<isset property="env.CATALINA_HOME" />
</condition>
<property name="tomcatUsername" value="admin" />
<property name="tomcatPassword" value="admin" />
<property name="server.location" location="${serverloc}" />
<property name="tomcatPort" value="8080" />
<property name="tomcatUrl" value="http://localhost:${tomcatPort}/manager/text" />
<!--PROPERTIES AND TASKS TO BE OVERRIDDEN BY MAIN BUILD-->
<property name="service.name" value="service" />
<target name="package.service">
</target>
<path id="tomcat.class.path">
<fileset dir="${server.location}/lib">
<include name="**/*.jar" />
<include name="**/*.zip" />
</fileset>
<pathelement location="${server.location}/bin/bootstrap.jar" />
<pathelement location="${server.location}/bin/tomcat-juli.jar" />
</path>
<!-- Configure the custom Ant tasks for the Manager application -->
<import file="${server.location}/bin/catalina-tasks.xml" />
<!-- TOMCAT LIFECICLE MANAGEMENT-->
<target name="start-tomcat" depends="check-tomcat-status" unless="tomcat.started" description="Start tomcat server">
<echo>Start Tomcat</echo>
<java classname="org.apache.catalina.startup.Bootstrap" fork="true"
classpathref="tomcat.class.path">
<jvmarg value="-Dcatalina.home=${server.location}" />
</java>
<sleep seconds="5"/>
</target>
<target name="stop-tomcat" depends="check-tomcat-status" if="tomcat.started" description="Stop tomcat server">
<echo>Stop Tomcat</echo>
<java classname="org.apache.catalina.startup.Bootstrap" fork="true"
classpathref="tomcat.class.path">
<jvmarg value="-Dcatalina.home=${server.location}" />
<arg line="stop" />
</java>
<sleep seconds="5"/>
</target>
<target name="check-tomcat-status">
<echo message="Checking whether Tomcat is running"/>
<condition property="tomcat.started">
<socket server="localhost" port="${tomcatPort}" />
</condition>
</target>
<!-- WEBSERVICE LIFECICLE MANAGEMENT-->
<target name="deployWS" depends="package.service" description="Deploy service to tomcat">
<echo>Deploying to tomcat...</echo>
<deploy url="${tomcatUrl}" username="${tomcatUsername}"
password="${tomcatPassword}" path="/${service.name}"
localWar="file:${root.location}/target/${service.name}.war" />
</target>
<target name="undeployWS" description="Undeploy service in tomcat">
<echo>Undeploying...</echo>
<undeploy url="${tomcatUrl}" username="${tomcatUsername}"
password="${tomcatPassword}" path="/${service.name}" failonerror="false"/>
</target>
<target name="startWS" description="Start service in tomcat">
<echo>Starting...</echo>
<start url="${tomcatUrl}" username="${tomcatUsername}" password="${tomcatPassword}"
path="/${service.name}" />
</target>
<target name="stopWS" description="Stop service in tomcat">
<echo>Stopping...</echo>
<stop url="${tomcatUrl}" username="${tomcatUsername}" password="${tomcatPassword}"
path="/${service.name}" />
</target>
<target name="reloadWS" description="Reload service in tomcat">
<echo>Reloading...</echo>
<reload url="${tomcatUrl}" username="${tomcatUsername}" password="${tomcatPassword}"
path="/${service.name}" />
</target>
<target name="redeployWS" depends="undeployWS" description="Redeploy service in tomcat">
<antcall target="deployWS" />
</target>
</project>