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

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

Additional property used in filter step

File size: 9.8 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.servlet-url" value="http://localhost:8383/greenstone3/library"/>
67 <property name="external.servlet-url" value="http://localhost:8383/greenstone3/library"/>
68 <property name="external.webswing-url" value="http://localhost:8383/webswing-server"/>
69
70 <property name="internal.ws-webswingserver" value="${internal.websocket-baseurl}/webswing-server/"/>
71
72 <!-- local ext paths -->
73 <loadproperties prefix="gs3." srcFile="${basedir}/../../build.properties"/>
74 <property name="src.home" value="${basedir}/src"/>
75 <property name="dst.home" value="${basedir}/web"/>
76 <available property="ext.web.exists" file="${basedir}/web" type="dir" />
77
78 <property name="etc-config-files" value="catalina-opts-extra.args,webswing.config,webswing.properties"/>
79 <property name="etc-config-dirs" value="api,apps,fonts,ssl"/>
80
81 <condition property="tomcat.dir" value="${gs3.tomcat.installed.path}" else="${basedir}/../../packages/tomcat">
82 <and>
83 <isset property="gs3.tomcat.installed.path"/>
84 <not>
85 <equals arg1="${gs3.tomcat.installed.path}" arg2=""/>
86 </not>
87 </and>
88 </condition>
89 <condition property="webswing.context" value="${gs3.webswing.context}" else="webswing-server">
90 <and>
91 <isset property="gs3.webswing.context"/>
92 <not>
93 <equals arg1="${gs3.webswing.context}" arg2=""/>
94 </not>
95 </and>
96 </condition>
97
98
99 <!-- TARGETS -->
100 <target name="usage" description="Print a help message">
101 <echo message=" Execute 'ant -projecthelp' for a list of targets."/>
102 <echo message=" Execute 'ant -help' for Ant help."/>
103 <echo>To install the Webswing extension for Greenstone3, run 'ant add-webapp'.
104 To remove the files and folders installed by add-service, run 'ant del-webapp'.
105 </echo>
106 </target>
107
108 <target name="compile" description="Compile up the webswing java classes, war them up, and install webseing-server.war into Greenstone's Tomcats webapps dir">
109
110 <exec os="${os.unix}" executable="bash" dir="src" failonerror="true">
111 <arg value="-c" />
112 <arg value="./COMPILE.sh" />
113 </exec>
114
115 <echo>Copying src/webswing-20.2.5/webswing-server/webswing-server-war/target/webswing-server.war ${tomcat.dir}/webapps </echo>
116 <copy file="src/webswing-20.2.5/webswing-server/webswing-server-war/target/webswing-server.war" todir="${tomcat.dir}/webapps"/>
117
118 </target>
119
120 <target name="clean" description="Delete the webswing compiled classes">
121 <exec os="${os.unix}" executable="./CLEAN.sh" dir="src" failonerror="true" />
122 <exec os="${os.windows}" executable=".\\CLEAN.bat" dir="src" failonerror="true" />
123 </target>
124
125
126 <target name="install-etc-files">
127
128 <if>
129 <bool><not><available file="${web.extdir}" type="dir"/></not></bool>
130 <echo>Creating web extension directory: ${web.extdir}</echo>
131 <mkdir dir="${web.extdir}"/>
132 </if>
133 <if>
134 <bool><not><available file="${web.extdir.unix}/etc" type="dir"/></not></bool>
135 <echo>Creating web extension directory: ${web.extdir.unix}/etc</echo>
136 <mkdir dir="${web.extdir.unix}/etc"/>
137 </if>
138
139 <for param="configFile" list="${etc-config-files}">
140 <sequential>
141 <echo message="Installing ${basedir}/web/etc/@{configFile}.in"/>
142 <copy file="${basedir}/web/etc/@{configFile}.in" tofile="${web.extdir.unix}/etc/@{configFile}.in" overwrite="true" />
143 </sequential>
144 </for>
145
146 <for param="configDir" list="${etc-config-dirs}">
147 <sequential>
148 <echo/>
149 <echo>Installing directory ${basedir}/web/@{configDir}/ (excluding .svn)</echo>
150 <copy todir="${web.extdir}">
151 <fileset dir="${basedir}/web">
152 <include name="@{configDir}/**"/>
153 <exclude name="**/.svn"/>
154 </fileset>
155 </copy>
156 </sequential>
157 </for>
158 </target>
159
160 <target name="install-webswing-for-tomcat">
161 <echo>Copying ${basedir}/web/webswing-server.war to ${tomcat.dir}/webapps/${webswing.context}.war</echo>
162 <copy file="${basedir}/web/webswing-server.war" tofile="${tomcat.dir}/webapps/${webswing.context}.war" />
163 </target>
164
165
166 <target name="add-extension" depends="install-etc-files,install-webswing-for-tomcat"
167 description="Run this target to setup the Webswing extension for Greenstone3" />
168
169
170 <target name="configure-extension">
171 <for param="configFile" list="${etc-config-files}">
172 <sequential>
173 <echo message="Configuring ${web.extdir.unix}/etc/@{configFile}"/>
174 <copy file="${web.extdir.unix}/etc/@{configFile}.in" tofile="${web.extdir.unix}/etc/@{configFile}" filtering="true" overwrite="true">
175 <filterset>
176 <filter token="gsdl3srchome" value="${gsdl3srchome}"/>
177 <filter token="gsdl3srchomeunix" value="${gsdl3srchome.unix}"/>
178 <filter token="gsdlos" value="${gsdlos}"/>
179 <filter token="internal-ws-webswingserver" value="${internal.ws-webswingserver}"/>
180 <filter token="internal-servleturl" value="${internal.servlet-url}"/>
181 <filter token="external-servleturl" value="${external.servlet-url}"/>
182 <filter token="external-webswingurl" value="${external.webswing-url}"/>
183 </filterset>
184 </copy>
185 </sequential>
186 </for>
187 </target>
188
189 <target name="accept-del-extension" unless="delextension.accepted">
190 <input addproperty="delextension.ok" validargs="y,n">This will recursively delete all the files in:
191 ${web.extdir}
192Do you want to continue [y/n]
193 </input>
194 <condition property="do.abort-delextension">
195 <equals arg1="n" arg2="${delextension.ok}"/>
196 </condition>
197 <fail if="do.abort-delextension">... Exiting</fail>
198 </target>
199
200 <target name="del-etc-files" description="Helper-target to delete webswing installed files">
201 <!-- failonerror is set to false in case some files don't exist
202 and can't be deleted therefore -->
203 <echo/>
204 <echo>Removing 'webswing' from ${web.extdir}</echo>
205 <echo>
206 delete failonerror="false" includeEmptyDirs="true" dir="${web.extdir.unix}/webswing"
207 </echo>
208 </target>
209
210 <target name="del-webswing-for-tomcat" description="Helper-target to remove files for getting webswing to work with tomcat">
211 <!-- Actually need to ensure tomcat is not running at this point
212 But if webswing-server.war is deleted first, it can't be re-deployed when deleting the webswing folder subsequently
213 -->
214 <echo/>
215 <echo>Removing webswing webapp installed to tomcat</echo>
216 <delete failonerror="false" file="${tomcat.dir}/webapps/${webswing.context}.war"/>
217 <delete failonerror="false" includeEmptyDirs="true" dir="${tomcat.dir}/webapps/${webswing.context}"/>
218 </target>
219
220 <target name="del-extension" depends="accept-del-extension,del-etc-files,del-webswing-for-tomcat"
221 description="Run this target to remove the Webswing extension for Greenstone3" />
222
223</project>
Note: See TracBrowser for help on using the repository browser.