source: gs3-extensions/webswing/trunk/build.xml@ 37332

Last change on this file since 37332 was 37332, checked in by davidb, 14 months ago

Improvements to configuring and installing. Now controling the values of the libary_url and ws: urls via properties set in the top-level build.xml

File size: 9.7 KB
Line 
1<?xml version="1.0"?>
2<project name="gs3-webswing-ext" default="usage" basedir=".">
3
4 <!-- ============ classpath =================== -->
5 <path id="project.classpath">
6 <fileset dir="../../lib/java">
7 <include name="**/*.jar"/>
8 </fileset>
9 </path>
10
11 <!-- ============ self defined tasks =================== -->
12 <taskdef name="mysetproxy" classname="org.greenstone.anttasks.MySetProxy" classpathref="project.classpath"/>
13 <taskdef name="getuserandpassword" classname="org.greenstone.anttasks.MyGetUserAndPassword" classpathref="project.classpath"/>
14 <taskdef name="rsr" classname="org.greenstone.anttasks.RegexSearchReplace" classpathref="project.classpath"/>
15 <taskdef name="if" classname="ise.antelope.tasks.IfTask" classpathref="project.classpath"/>
16 <taskdef name="for" classname="net.sf.antcontrib.logic.ForTask" classpathref="project.classpath"/>
17 <taskdef name="foreach" classname="net.sf.antcontrib.logic.ForEach" classpathref="project.classpath"/>
18 <taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask" classpathref="project.classpath"/>
19
20 <!--
21 Perhaps the following (and the above) should bo be moved into a sub-module/sub-projectc so it can be imported
22 (<import file="<filename>.xml")
23 -->
24
25 <property name="os.linux" value="Linux"/>
26 <property name="os.mac" value="Mac OS X"/>
27 <property name="os.solaris" value="SunOS"/>
28 <property name="os.unix" value="${os.linux},${os.mac},${os.solaris}"/>
29 <property name="os.windows" value="Windows 95,Windows 98,Windows 2000,Windows 2003,Windows XP,Windows NT,Windows ME,Windows Vista,Windows 7,Windows Server 2008,Windows Server 2008 R2,Windows 8,Windows 10,Windows 11"/> <!-- check this!!!-->
30
31 <!--
32 <property environment="env"/>
33 -->
34
35 <!-- Directory Locations -->
36 <!-- http://stackoverflow.com/questions/3136849/how-do-i-convert-a-relative-path-in-ant-to-an-absolute-path
37 http://stackoverflow.com/questions/8295860/pathconvert-with-relative-file-names -->
38
39 <!-- greenstone3 paths -->
40 <property name="gsdl3srchome" location="${basedir}/../.."/> <!-- location property creates an absolute path -->
41 <pathconvert targetos="unix" property="gsdl3srchome.unix">
42 <path path="${gsdl3srchome}"/>
43 </pathconvert>
44
45 <!-- location property creates an absolute path, default if not set with -D argument -->
46 <property name="web.home" location="${basedir}/../../web"/>
47 <pathconvert targetos="unix" property="web.home.unix">
48 <path path="${web.home}"/>
49 </pathconvert>
50
51 <!-- location property creates an absolute path, default if not set with -D argument -->
52 <property name="web.writablehome" location="${basedir}/../../web"/>
53 <pathconvert targetos="unix" property="web.writablehome.unix">
54 <path path="${web.writablehome}"/>
55 </pathconvert>
56
57 <property name="web.extdir" value="${web.writablehome.unix}/ext/webswing"/>
58 <pathconvert targetos="unix" property="web.extdir.unix">
59 <path path="${web.extdir}"/>
60 </pathconvert>
61
62 <!-- if not set by -D argument from top-level build.xml, then provide some
63 useful/plausable backup-defaults for testing on a local machine -->
64 <property name="gsdlos" value="linux"/>
65 <property name="internal.websocket-baseurl" value="ws://localhost:8383"/>
66 <property name="internal.servleturl" value="http://localhost:8383/greenstone3/library"/>
67 <property name="external.servleturl" value="http://localhost:8383/greenstone3/library"/>
68
69 <property name="internal.ws-webswingserver" value="${internal.websocket-baseurl}/webswing-server/"/>
70
71 <!-- local ext paths -->
72 <loadproperties prefix="gs3." srcFile="${basedir}/../../build.properties"/>
73 <property name="src.home" value="${basedir}/src"/>
74 <property name="dst.home" value="${basedir}/web"/>
75 <available property="ext.web.exists" file="${basedir}/web" type="dir" />
76
77 <property name="etc-config-files" value="catalina-opts-extra.args,webswing.config,webswing.properties"/>
78 <property name="etc-config-dirs" value="api,apps,fonts,ssl"/>
79
80 <condition property="tomcat.dir" value="${gs3.tomcat.installed.path}" else="${basedir}/../../packages/tomcat">
81 <and>
82 <isset property="gs3.tomcat.installed.path"/>
83 <not>
84 <equals arg1="${gs3.tomcat.installed.path}" arg2=""/>
85 </not>
86 </and>
87 </condition>
88 <condition property="webswing.context" value="${gs3.webswing.context}" else="webswing-server">
89 <and>
90 <isset property="gs3.webswing.context"/>
91 <not>
92 <equals arg1="${gs3.webswing.context}" arg2=""/>
93 </not>
94 </and>
95 </condition>
96
97
98 <!-- TARGETS -->
99 <target name="usage" description="Print a help message">
100 <echo message=" Execute 'ant -projecthelp' for a list of targets."/>
101 <echo message=" Execute 'ant -help' for Ant help."/>
102 <echo>To install the Webswing extension for Greenstone3, run 'ant add-webapp'.
103 To remove the files and folders installed by add-service, run 'ant del-webapp'.
104 </echo>
105 </target>
106
107 <target name="compile" description="Compile up the webswing java classes, war them up, and install webseing-server.war into Greenstone's Tomcats webapps dir">
108
109 <exec os="${os.unix}" executable="bash" dir="src" failonerror="true">
110 <arg value="-c" />
111 <arg value="./COMPILE.sh" />
112 </exec>
113
114 <echo>Copying src/webswing-20.2.5/webswing-server/webswing-server-war/target/webswing-server.war ${tomcat.dir}/webapps </echo>
115 <copy file="src/webswing-20.2.5/webswing-server/webswing-server-war/target/webswing-server.war" todir="${tomcat.dir}/webapps"/>
116
117 </target>
118
119 <target name="clean" description="Delete the webswing compiled classes">
120 <exec os="${os.unix}" executable="./CLEAN.sh" dir="src" failonerror="true" />
121 <exec os="${os.windows}" executable=".\\CLEAN.bat" dir="src" failonerror="true" />
122 </target>
123
124
125 <target name="install-etc-files">
126
127 <if>
128 <bool><not><available file="${web.extdir}" type="dir"/></not></bool>
129 <echo>Creating web extension directory: ${web.extdir}</echo>
130 <mkdir dir="${web.extdir}"/>
131 </if>
132 <if>
133 <bool><not><available file="${web.extdir.unix}/etc" type="dir"/></not></bool>
134 <echo>Creating web extension directory: ${web.extdir.unix}/etc</echo>
135 <mkdir dir="${web.extdir.unix}/etc"/>
136 </if>
137
138 <for param="configFile" list="${etc-config-files}">
139 <sequential>
140 <echo message="Installing ${basedir}/web/etc/@{configFile}.in"/>
141 <copy file="${basedir}/web/etc/@{configFile}.in" tofile="${web.extdir.unix}/etc/@{configFile}.in" overwrite="true" />
142 </sequential>
143 </for>
144
145 <for param="configDir" list="${etc-config-dirs}">
146 <sequential>
147 <echo/>
148 <echo>Installing directory ${basedir}/web/@{configDir}/ (excluding .svn)</echo>
149 <copy todir="${web.extdir}">
150 <fileset dir="${basedir}/web">
151 <include name="@{configDir}/**"/>
152 <exclude name="**/.svn"/>
153 </fileset>
154 </copy>
155 </sequential>
156 </for>
157 </target>
158
159 <target name="install-webswing-for-tomcat">
160 <echo>Copying ${basedir}/web/webswing-server.war to ${tomcat.dir}/webapps/${webswing.context}.war</echo>
161 <copy file="${basedir}/web/webswing-server.war" tofile="${tomcat.dir}/webapps/${webswing.context}.war" />
162 </target>
163
164
165 <target name="add-extension" depends="install-etc-files,install-webswing-for-tomcat"
166 description="Run this target to setup the Webswing extension for Greenstone3" />
167
168
169 <target name="configure-extension">
170 <for param="configFile" list="${etc-config-files}">
171 <sequential>
172 <echo message="Configuring ${web.extdir.unix}/etc/@{configFile}"/>
173 <copy file="${web.extdir.unix}/etc/@{configFile}.in" tofile="${web.extdir.unix}/etc/@{configFile}" filtering="true" overwrite="true">
174 <filterset>
175 <filter token="gsdl3srchome" value="${gsdl3srchome}"/>
176 <filter token="gsdl3srchomeunix" value="${gsdl3srchome.unix}"/>
177 <filter token="gsdlos" value="${gsdlos}"/>
178 <filter token="internal-ws-webswingserver" value="${internal.ws-webswingserver}"/>
179 <filter token="internal-servleturl" value="${internal.servlet-url}"/>
180 <filter token="external-servleturl" value="${external.servlet-url}"/>
181 </filterset>
182 </copy>
183 </sequential>
184 </for>
185 </target>
186
187 <target name="accept-del-extension" unless="delextension.accepted">
188 <input addproperty="delextension.ok" validargs="y,n">This will recursively delete all the files in:
189 ${web.extdir}
190Do you want to continue [y/n]
191 </input>
192 <condition property="do.abort-delextension">
193 <equals arg1="n" arg2="${delextension.ok}"/>
194 </condition>
195 <fail if="do.abort-delextension">... Exiting</fail>
196 </target>
197
198 <target name="del-etc-files" description="Helper-target to delete webswing installed files">
199 <!-- failonerror is set to false in case some files don't exist
200 and can't be deleted therefore -->
201 <echo/>
202 <echo>Removing 'webswing' from ${web.extdir}</echo>
203 <echo>
204 delete failonerror="false" includeEmptyDirs="true" dir="${web.extdir.unix}/webswing"
205 </echo>
206 </target>
207
208 <target name="del-webswing-for-tomcat" description="Helper-target to remove files for getting webswing to work with tomcat">
209 <!-- Actually need to ensure tomcat is not running at this point
210 But if webswing-server.war is deleted first, it can't be re-deployed when deleting the webswing folder subsequently
211 -->
212 <echo/>
213 <echo>Removing webswing webapp installed to tomcat</echo>
214 <delete failonerror="false" file="${tomcat.dir}/webapps/${webswing.context}.war"/>
215 <delete failonerror="false" includeEmptyDirs="true" dir="${tomcat.dir}/webapps/${webswing.context}"/>
216 </target>
217
218 <target name="del-extension" depends="accept-del-extension,del-etc-files,del-webswing-for-tomcat"
219 description="Run this target to remove the Webswing extension for Greenstone3" />
220
221</project>
Note: See TracBrowser for help on using the repository browser.