summaryrefslogtreecommitdiffstats
path: root/verigraph/tomcat-build.xml
blob: 7dbf3b093623815dc8692a4de68503a0733c4273 (plain)
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
104
105
106
107
<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright (c) 2017 Politecnico di Torino and others.

 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Apache License, Version 2.0
 which accompanies this distribution, and is available at
 http://www.apache.org/licenses/LICENSE-2.0
-->
<project basedir="." name="tomcat-build">
  <description>
    Script for Controlling Tomcat (to be imported in main build)
  </description>

  <property name="tomcatUsername" value="to_be_defined" />
  <property name="tomcatPassword" value="to_be_defined" />
  <property name="server.location" location="to_be_defined" />
  <property name="tomcatPort" value="8080" />
  <property name="tomcatUrl" value="http://localhost:${tomcatPort}/manager/text" />
  <property name="root.location" location="." />
  <!--PROPERTIES AND TASKS TO BE OVERRIDDEN BY MAIN BUILD-->
  <property name="serviceName" value="verigraph" />
  <property name="rootDirectoryWS" value="verigraph"/>

  <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">
    <echo>Start Tomcat</echo>
    <java classname="org.apache.catalina.startup.Bootstrap" fork="true"
      classpathref="tomcat.class.path">
      <jvmarg value="-Dcatalina.home=${server.location}/" />
    </java>
  </target>


  <target name="stop-tomcat" depends="check-tomcat-status" if="tomcat.started">
    <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>
  </target>


  <target name="check-tomcat-status">
    <condition property="tomcat.started">
      <socket server="localhost" port="${tomcatPort}" />
    </condition>
  </target>


  <!-- WEBSERVICE LIFECICLE MANAGEMENT-->
  <target name="deployWS" description="Deploy service to tomcat">
    <echo>Deploying to tomcat...</echo>
    <deploy url="${tomcatUrl}" username="${tomcatUsername}"
        password="${tomcatPassword}" path="/${serviceName}"
        war="file:${root.location}/war/${serviceName}.war"
      />
  </target>


  <target name="undeployWS" description="Undeploy to tomcat">
    <echo>Undeploying...</echo>
    <undeploy url="${tomcatUrl}" username="${tomcatUsername}"
          password="${tomcatPassword}" path="/${serviceName}" failonerror="false"/>
  </target>


  <target name="startWS" description="Start service in tomcat">
    <echo>Starting...</echo>
    <start url="${tomcatUrl}" username="${tomcatUsername}" password="${tomcatPassword}"
         path="/${serviceName}" />
  </target>


  <target name="stopWS" description="Stop service in tomcat">
    <echo>Stopping...</echo>
    <stop url="${tomcatUrl}" username="${tomcatUsername}" password="${tomcatPassword}"
        path="/${serviceName}" />
  </target>


  <target name="reloadWS" description="Reload service in tomcat">
    <echo>Reloading...</echo>
    <reload url="${tomcatUrl}" username="${tomcatUsername}" password="${tomcatPassword}"
          path="/${serviceName}" />
  </target>


  <target name="redeployWS" depends="undeployWS" description="Redeploy service in tomcat">
    <antcall target="deployWS" />
  </target>

</project>