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

Last change on this file since 36525 was 36525, checked in by davidb, 20 months ago

Work in process

File size: 13.2 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="svn" classname="org.tigris.subversion.svnant.SvnTask" classpathref="project.classpath"/>-->
16 <taskdef name="if" classname="ise.antelope.tasks.IfTask" classpathref="project.classpath"/>
17 <taskdef name="for" classname="net.sf.antcontrib.logic.ForTask" classpathref="project.classpath"/>
18 <taskdef name="foreach" classname="net.sf.antcontrib.logic.ForEach" classpathref="project.classpath"/>
19 <taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask" classpathref="project.classpath"/>
20
21
22 <!-- Perhaps the following needs to be moved into a sub-module/sub-projectc so it can be imported (<import file="....xml") -->
23
24 <property name="os.linux" value="Linux"/>
25 <property name="os.mac" value="Mac OS X"/>
26 <property name="os.solaris" value="SunOS"/>
27 <property name="os.unix" value="${os.linux},${os.mac},${os.solaris}"/>
28 <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!!!-->
29
30
31 <property environment="env"/>
32
33 <!-- DIRECTORY LOCATIONS -->
34 <!-- local ext paths -->
35 <loadproperties prefix="gs3." srcFile="${basedir}/../../build.properties"/>
36 <property name="src.home" value="${basedir}/src"/>
37 <property name="dst.home" value="${basedir}/web"/>
38 <available property="ext.web.exists" file="${basedir}/web" type="dir" />
39
40
41 <!-- greenstone3 paths -->
42 <!-- http://stackoverflow.com/questions/3136849/how-do-i-convert-a-relative-path-in-ant-to-an-absolute-path
43 http://stackoverflow.com/questions/8295860/pathconvert-with-relative-file-names -->
44
45 <property name="gsdl3srchome" location="${basedir}/../.."/> <!-- location property creates an absolute path -->
46 <property name="web.home" location="${basedir}/../../web"/> <!-- location property creates an absolute path -->
47 <property name="web.extdir" value="${web.home}/ext/webswing"/>
48
49
50 <condition property="tomcat.dir" value="${gs3.tomcat.installed.path}" else="${basedir}/../../packages/tomcat">
51 <and>
52 <isset property="gs3.tomcat.installed.path"/>
53 <not>
54 <equals arg1="${gs3.tomcat.installed.path}" arg2=""/>
55 </not>
56 </and>
57 </condition>
58 <condition property="webswing.context" value="${gs3.webswing.context}" else="webswing">
59 <and>
60 <isset property="gs3.webswing.context"/>
61 <not>
62 <equals arg1="${gs3.webswing.context}" arg2=""/>
63 </not>
64 </and>
65 </condition>
66
67 <!--
68 <condition property="compile.javac.flags" value="${env.JAVACFLAGS}" else="">
69 <isset property="env.JAVACFLAGS"/>
70 </condition>
71 -->
72
73 <!-- FILE LISTINGS.-->
74 <!-- Created as property elements rather than as filelist elements, since
75 they can then be reused for the add-service and delete-service targets. -->
76 <!--
77 <property name="config-files"
78 value="${dst.home}/webswing.config
79 ${dst.home}/webswing.properties"/>
80
81 -->
82
83 <!-- TARGETS -->
84 <target name="usage" description="Print a help message">
85 <echo message=" Execute 'ant -projecthelp' for a list of targets."/>
86 <echo message=" Execute 'ant -help' for Ant help."/>
87 <echo>To install the Webswing extension for Greenstone3, run 'ant add-webapp'.
88 To remove the files and folders installed by add-service, run 'ant del-webapp'.
89 </echo>
90 </target>
91
92 <target name="compile" description="Compile up the webswing java classes, war them up, and install webseing-server.war into Greenstone's Tomcats webapps dir">
93
94 <exec os="${os.unix}" executable="bash" dir="src" failonerror="true">
95 <arg value="-c" />
96 <arg value="./COMPILE.sh" />
97 </exec>
98
99 <echo>Copying src/webswing-20.2.5/webswing-server/webswing-server-war/target/webswing-server.war ${tomcat.dir}/webapps </echo>
100 <copy file="src/webswing-20.2.5/webswing-server/webswing-server-war/target/webswing-server.war" todir="${tomcat.dir}/webapps"/>
101
102 </target>
103
104 <target name="clean" description="Delete the webswing compiled classes">
105 <exec os="${os.unix}" executable="./CLEAN.sh" dir="src" failonerror="true" />
106 <exec os="${os.windows}" executable=".\\CLEAN.bat" dir="src" failonerror="true" />
107 </target>
108
109 <property name="etc-config-files" value="catalina-opts-extra.args,webswing.config,webswing.properties"/>
110 <property name="etc-config-dirs" value="api,apps,fonts,ssl"/>
111
112 <target name="install-etc-files" description="Helper-target: copy web/etc config files across for add-extension target">
113
114 <echo/>
115 <!--
116 <echo>Adding to gsdl3 properties area: properties/${property-files}</echo>
117 <copy todir="${web.classesdir}">
118 <filelist id="prop-files" dir="properties" files="${property-files}"/>
119 </copy>
120 <echo/>
121 -->
122
123 <!--
124 <echo>Adding to gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars}</echo>
125 <copy todir="${web.libdir}">
126 <filelist id="jar-files" dir="lib/java" files="${jars}"/>
127 </copy>
128 -->
129
130
131 <if>
132 <bool><not><available file="${web.extdir}" type="dir"/></not></bool>
133 <echo>Creating web extension directory: ${web.extdir}</echo>
134 <mkdir dir="${web.extdir}"/>
135 </if>
136 <if>
137 <bool><not><available file="${web.extdir}/etc" type="dir"/></not></bool>
138 <echo>Creating web extension directory: ${web.extdir}/etc</echo>
139 <mkdir dir="${web.extdir}/etc"/>
140 </if>
141
142 <for param="configFile" list="${etc-config-files}">
143 <sequential>
144 <echo message="Processing ${basedir}/web/etc/@{configFile}.in"/>
145 <copy file="${basedir}/web/etc/@{configFile}.in" tofile="${web.extdir}/etc/@{configFile}" filtering="true" overwrite="true">
146 <filterset>
147 <filter token="gsdl3srchome" value="${gsdl3srchome}"/>
148 </filterset>
149 </copy>
150 </sequential>
151 </for>
152
153
154<!--
155 <for param="configFile" list="${etc-config-dirs}">
156 <sequential>
157 <echo message="Processing ${basedir}/web/etc/@{configFile}.in"/>
158
159 <echo>Adding to gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars}</echo>
160 <copy todir="${web.libdir}">
161 <filelist id="jar-files" dir="lib/java" files="${jars}"/>
162 </copy>
163
164 <copy file="${basedir}/web/etc/@{configFile}.in" tofile="${web.extdir}/etc/@{configFile}" filtering="true" overwrite="true">
165 <filterset>
166 <filter token="gsdl3srchome" value="${gsdl3srchome}"/>
167 </filterset>
168 </copy>
169 </sequential>
170 </for>
171
172-->
173
174
175 <!--
176 <echo/>
177 <echo>Copy to ${web.extdir}: the content of the ${basedir}/web/fonts folder (excluding .svn)</echo>
178 <copy todir="${web.extdir}">
179 <dirset dir="${basedir}/web/fonts">
180 <exclude name=".svn"/>
181 </dirset>
182 </copy>
183
184 -->
185 <!--
186
187 <echo/>
188 <echo>Adding to gsdl3 web solr ext directory: solr.xml and solr.xml.in</echo>
189 <copy file="solr.xml.in" tofile="${web.extdir}/solr.xml.in"/>
190 <pathconvert targetos="unix" property="src.gsdl3.home.unix">
191 <path path="../../web"/>
192 </pathconvert>
193 <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
194 <copy file="solr.xml.in" tofile="${web.extdir}/solr.xml" filtering="true" overwrite="true"/>
195
196 <echo/>
197 <echo>Adding example solr-jdbm-demo collection to ${localsite.collectdir}</echo>
198 <copy todir="${localsite.collectdir}/solr-jdbm-demo"
199 preservelastmodified="true"
200 failonerror="true" >
201 <fileset dir="${basedir}/collect/solr-jdbm-demo" includes="**"/>
202 </copy>
203 <echo>Unzipping pre-built index</echo>
204 <unzip dest="${localsite.collectdir}/solr-jdbm-demo" src="${localsite.collectdir}/solr-jdbm-demo/index.zip" />
205
206 -->
207 </target>
208
209 <target name="copy-etc-file">
210 <echo message="Copying ${theConfigFile} to ${web.extdir}/webswing/etc"/>
211 </target>
212
213 <!-- Setting up solr to work with tomcat server instead of jetty server -->
214 <target name="install-webswing-for-tomcat" description="Helper-target: setting up webswing to work with tomcat">
215
216 <!-- slf4j and commons logging bridge needed to avoid exception about incompatibility in tomcat log files-->
217 <echo>Copying ${basedir}/lib/ext/jcl-over-slf4j-1.6.6.jar again to ${web.libdir}</echo>
218 <copy todir="${web.libdir}">
219 <filelist id="logging-bridge" dir="lib/ext" files="jcl-over-slf4j-1.6.6.jar"/>
220 </copy>
221
222 <echo>Upddating xalan related jar files, morphology and gs3-solrserver jars from ${web.libdir} in solr.war</echo>
223 <war destfile="webapps/solr.war" update="true" >
224 <zipfileset dir="lib/russianmorphology" includes="*.jar" prefix="WEB-INF/lib"/>
225 <zipfileset dir="lib/ext" includes="*.jar" prefix="WEB-INF/lib"/>
226 <zipfileset dir="${web.libdir}" includes="${shared-xalan-jars}" prefix="WEB-INF/lib"/>
227 <zipfileset dir="${build.home}" includes="gs3-solrserver.jar" prefix="WEB-INF/lib"/>
228 </war>
229
230 <echo>Copying ${basedir}/webapps/solr.war to ${tomcat.dir}/webapps/${solr.context}.war</echo>
231 <copy file="webapps/solr.war" tofile="${tomcat.dir}/webapps/${solr.context}.war" />
232
233 <echo>Generating solr context file in ${tomcat.context.dir}</echo>
234
235 <!-- we want unix paths (forward slashes) in the tomcat context file -->
236 <pathconvert targetos="unix" property="gsdl3.web.home">
237 <path path="${web.home}"/><!-- creates an absolute path-->
238 </pathconvert>
239 <pathconvert targetos="unix" property="tomcat.home">
240 <path path="${tomcat.dir}"/><!-- creates an absolute path-->
241 </pathconvert>
242 <filter token="gsdl3webhome" value="${gsdl3.web.home}"/>
243 <filter token="tomcathome" value="${tomcat.home}"/>
244 <filter token="solr.context" value="${solr.context}"/>
245 <copy file="solr-tomcat-context.xml.in" tofile="${tomcat.context.dir}/${solr.context}.xml" filtering="true" overwrite="true"/>
246
247 </target>
248
249 <!-- copy the content of the web folder (avoiding the top-level .svn directory) -->
250 <!--
251 <target name="install-solr-web" if="ext.web.exists">
252 <echo/>
253 <echo>Copy to gsdl3 web: the content of the ${basedir}/web folder (excluding .svn)</echo>
254 <copy todir="${web.extdir}">
255 <dirset dir="${basedir}/web">
256 <exclude name=".svn"/>
257 </dirset>
258 </copy>
259 </target>
260
261 -->
262
263 <target name="add-extension" depends="install-etc-files,install-webswing-for-tomcat"
264 description="Run this target to setup the Webswing extension for Greenstone3" />
265
266 <target name="del-extension" depends="del-etc-files,del-webswing-for-tomcat"
267 description="Run this target to unset the Webswing extension for Greenstone3" />
268
269
270 <target name="del-etc-files" description="Helper-target to delete files for del-extension target">
271 <!-- failonerror is set to false in case some files don't exist
272 and can't be deleted therefore -->
273
274 <echo/>
275<!-- <echo>Removing from gsdl3 properties area: properties/${property-files}</echo>
276 <delete failonerror="false">
277 <filelist dir="${web.classesdir}" files="${property-files}"/>
278 </delete>
279
280 <echo/>-->
281 <echo>Removing from gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars} gs3-solr.jar</echo>
282 <delete failonerror="false">
283 <filelist dir="${web.libdir}" files="${jars} gs3-solr.jar"/>
284 </delete>
285
286 <echo/>
287 <echo>Removing web solr extension directory: ${web.extdir}</echo>
288 <delete failonerror="false" includeEmptyDirs="true" dir="${web.extdir}"/>
289
290 <echo/>
291 <echo>Removing solr-jdbm-demo collection from: ${localsite.collectdir}</echo>
292 <delete failonerror="false" includeEmptyDirs="true" dir="${localsite.collectcdir}/solr-jdbm-demo"/>
293
294 </target>
295
296 <target name="del-webswing-for-tomcat" description="Helper-target to remove files for getting webswing to work with tomcat">
297
298 <echo/>
299 <echo>Removing solr modifications to tomcat: context file, solr.war and deployed version, jar files</echo>
300
301 <!-- Actually need to ensure tomcat is not running at this point
302 But if solr.war is deleted first, it can't be re-deployed when deleting the solr folder subsequently
303 -->
304 <delete failonerror="false" file="${tomcat.dir}/webapps/${solr.context}.war"/>
305 <delete failonerror="false" includeEmptyDirs="true" dir="${tomcat.dir}/webapps/${solr.context}"/>
306
307 <delete failonerror="false" file="${tomcat.context.dir}/${solr.context}.xml"/>
308
309 <!-- delete all the jar files in tomcat/lib that were copied from ext/solr/lib/ext
310 which are all the jar files that are present in both tomcat/lib and ext/solr/lib/ext
311 https://ant.apache.org/manual/Types/selectors.html#presentselect -->
312 <delete failonerror="false">
313 <fileset dir="${tomcat.lib.dir}" includes="**/*.jar">
314 <present present="both" targetdir="lib/ext"/>
315 </fileset>
316 </delete>
317
318 <!-- remove logging bridge jar file that was added into greenstone 3 web lib area -->
319 <delete failonerror="false" file="${web.libdir}/jcl-over-slf4j-1.6.6.jar"/>
320
321 <!--http://stackoverflow.com/questions/2140637/how-do-i-build-a-list-of-file-names-->
322 </target>
323
324</project>
Note: See TracBrowser for help on using the repository browser.