root/main/trunk/greenstone3/build.xml @ 32153

Revision 32153, 148.2 KB (checked in by ak19, 19 months ago)

2 Bugfixes and tidying up errorhandling in JarTools?. 1. Dr Bainbridge fixed issue surrounding env.Path rather than env.PATH being used on Windows, while the empty env.PATH was being concatenated as a variable name by build.xml. This resulted in a cyclical reference, noticed when running the GLI Web Start Application (converted from GLI Applet). Fix is in build.xml. 2. My bugfix to WebGatherer?.java, the new GLI Web Start Application. The collectionDir wasn't set correctly until the Gatherer object was instantiated, but the collect dir needed to be known by other code beforehand. So shifted the Gatherer object instantiation up a bit. 3. Can't yet reproduce the Exception seen twice before when running GLI Web Start application. The exception was thrown in ZipTools?.java. Tested by rerunning the applet repeatedly, but it hasn't struck again yet. Perhaps it's been fixed now because of the other changes?

Line 
1<?xml version="1.0"?>
2<!-- ======================================================================
3     March 2005                                                   
4
5     Greenstone3 build and install script
6                 
7     kjdon                                                               
8     ====================================================================== -->
9<project name="greenstone3" default="usage" basedir=".">
10  <echo>os.name: ${os.name}</echo>
11
12  <!-- ============ classpath =================== -->
13  <path id="project.classpath">
14    <fileset dir="lib/java">
15      <include name="**/*.jar"/>
16    </fileset>
17  </path>
18 
19  <!-- ============ self defined tasks =================== -->
20  <taskdef name="mysetproxy" classname="org.greenstone.anttasks.MySetProxy" classpathref="project.classpath"/>
21  <taskdef name="getuserandpassword" classname="org.greenstone.anttasks.MyGetUserAndPassword" classpathref="project.classpath"/>
22  <taskdef name="rsr" classname="org.greenstone.anttasks.RegexSearchReplace" classpathref="project.classpath"/>
23  <!--<taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" classpathref="project.classpath"/>-->
24  <taskdef name="if" classname="ise.antelope.tasks.IfTask" classpathref="project.classpath"/>
25  <taskdef name="for" classname="net.sf.antcontrib.logic.ForTask" classpathref="project.classpath"/>
26  <taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask" classpathref="project.classpath"/>
27
28 
29  <!-- ===================== Property Definitions =========================== -->
30 
31  <!--
32
33  Each of the following properties are used in the build script.
34  Values for these properties are set by the first place they are
35  defined, from the following list:
36
37  * Definitions on the "ant" command line (ant -Dfoo=bar compile).
38
39  * Definitions from a "build.properties" file in the top level
40  source directory of this application.
41
42  * Definitions from a "build.properties" file in the user's
43  home directory.
44
45  * Default definitions in this build.xml file.
46
47  You will note below that property values can be composed based on the
48  contents of previously defined properties.  This is a powerful technique
49  that helps you minimize the number of changes required when your development
50  environment is modified.  Note that property composition is allowed within
51  "build.properties" files as well as in the "build.xml" script.
52
53  -->
54
55  <property name="os.linux" value="Linux"/>
56  <property name="os.mac" value="Mac OS X"/>
57  <property name="os.solaris" value="SunOS"/>
58  <property name="os.unix" value="${os.linux},${os.mac},${os.solaris}"/>
59  <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"/> <!-- check this!!!-->
60
61  <!-- this is true for linux and macs -->
62  <condition property="current.os.isunix">
63    <os family="unix"/>
64  </condition>
65 
66  <condition property="current.os.isunixnotmac">
67    <and>
68      <os family="unix"/>
69      <not>
70    <os family="mac"/>
71      </not>
72    </and>
73  </condition>
74 
75  <condition property="current.os.ismac">
76    <os family="mac"/>
77  </condition>
78 
79  <condition property="current.os.iswindows">
80    <os family="windows"/>
81  </condition>
82
83  <!-- create build.properties if it has not been created yet -->
84  <if>
85    <bool><not><available file="build.properties"/></not></bool>
86    <copy file="build.properties.in" tofile="build.properties"/>
87  </if>
88
89  <!-- create the packages dir if it has not been created yet -->
90  <mkdir dir="packages"/>
91 
92  <!--the first three properties have to be put on the top to be used by build.properties-->
93  <property name="gs2build.home" value="${basedir}${file.separator}gs2build"/>
94  <property name="src.packages.home" value="${basedir}/src/packages"/>
95  <property name="flax.svn.root" value="http://svn.greenstone.org/flax"/>
96
97  <property name="solr-ext.home" value="${basedir}/ext/solr"/>
98
99  <property file="build.properties"/>
100  <if><bool><available file="${user.home}/build.properties"/></bool>
101    <property file="${user.home}/build.properties"/>
102  </if>
103
104  <!-- now we've read in properties, apply defaults -->
105  <property name="disable.collection.building" value="false"/>
106
107  <!-- get properties from the environment -->
108  <property environment="env"/>
109
110  <!-- get the filesets defining components and executables -->
111  <import file="resources/xml/components.xml"/>
112  <import file="resources/xml/executables.xml"/>
113   
114  <!-- version properties for external packages -->
115  <!-- for Java versions < 1.4, we print out the message that Java is too old.
116    For Java 1.4, we use Tomcat 5.5, for Java5 and higher, we use Tomcat 7.0-->
117  <condition property="tomcat.version" value="apache-tomcat-5.5.25" else="apache-tomcat-7.0.57">
118    <equals arg1="1.4" arg2="${ant.java.version}"/>
119  </condition>
120  <condition property="tomcat.version.major" value="5" else="7">
121    <equals arg1="1.4" arg2="${ant.java.version}"/>
122  </condition>
123  <condition property="privileged.attribute" value="privileged='true'" else="">
124    <equals arg1="7" arg2="${tomcat.version.major}"/>
125  </condition>
126
127  <!-- external access to the GS3 pages or not
128       https://tomcat.apache.org/tomcat-7.0-doc/config/valve.html -->
129  <condition property="allowed.IPs"
130         value=".*"
131         else="(127\.0\.0\.1|::1|0:0:0:0:0:0:0:1)">
132    <matches pattern="^(1|true|yes)$" string="${server.external.access}"/>
133  </condition>
134
135  <property name="axis.zip.version" value="axis-bin-1_4.zip"/>
136  <property name="axis.dir.version" value="axis-1_4"/>
137  <property name="sqlite.targz.version" value="sqlite-autoconf-3070602.tar.gz"/>
138
139  <property name="build.home" value="${basedir}/build"/>
140  <property name="src.home" value="${basedir}/src/java"/>
141
142  <if><bool><istrue value="${gsdl3home.isreadonly}"/></bool>
143    <property name="readonly-packages.home" value="${basedir}/packages"/>
144    <property name="packages.home" value="${gsdl3.writablehome}/packages"/>
145    <!--
146     To run solr from a read-only location (like a DVD-ROM), its locktype needs to be "single",
147     else solr tries to write out a lock file to the collection's index folder which is read-only.
148
149     https://cwiki.apache.org/confluence/display/solr/IndexConfig+in+SolrConfig
150     says that the "single" locktype is "for special situations of a read-only index directory, or ...."
151     
152     See also http://wiki.apache.org/lucene-java/AvailableLockFactories
153     And look for the documentation on "locktype" in solr collection's etc/conf/solrconfig.xml
154     for further information on the different locktypes.
155
156     To set the locktype property from the commandline (it's a property to the server web), pass in
157     "-Dsolr.lock.type=..." to the web server, as explained in
158     http://lucene.472066.n3.nabble.com/Where-can-we-set-the-parameters-in-Solr-Config-td4183706.html
159      -->
160    <property name="readonly.catalina.opts" value="-Dsolr.lock.type=single"/>
161  <else>
162    <property name="packages.home" value="${basedir}/packages"/>
163    <property name="readonly.catalina.opts" value=""/>
164  </else>
165  </if>
166
167  <!-- this may be set in build.properties, e.g. if you move the web dir to
168       tomcats webapps directory -->
169  <property name="web.home" value="${basedir}/web"/>
170  <property name="web.writablehome" value="${gsdl3.writablehome}"/>
171  <!-- If using a dispersed GS3 web folder, then the user web would not contain everything in the
172       default GS3 web (it won't contain a CGI or lib folder inside WEB-INF, for instance) -->
173  <if>
174    <bool><available file="${web.home}/WEB-INF/cgi" type="dir"/></bool>
175    <property name="full.web.dir" value="${web.home}"/>
176    <else>
177        <property name="full.web.dir" value="${basedir}/web"/>
178    </else>
179  </if> 
180 
181  <!-- jar files needed by applets go here -->
182  <property name="web.applet" value="${web.home}/applet"/>
183 
184  <!-- jar files needed by the servlet (and extra ones) go here -->
185  <property name="web.lib" value="${web.home}/WEB-INF/lib"/>
186  <property name="web.writablelib" value="${web.writablehome}/WEB-INF/lib"/>
187  <!-- other files needed by the servlet go here -->
188  <property name="web.classes" value="${web.home}/WEB-INF/classes"/>
189  <property name="web.writableclasses" value="${web.writablehome}/WEB-INF/classes"/>
190
191  <if>
192    <bool><istrue value="${gsdl3home.isreadonly}"/></bool>
193    <echo>Greenstone3 home directory is read-only</echo>
194    <echo>  => Writable area is: ${gsdl3.writablehome}</echo>
195
196    <condition property="gsdl3.writablehome.already-exists">
197      <available file="${gsdl3.writablehome}" type="dir"/>
198    </condition>
199
200    <if>
201      <bool><not><istrue value="${gsdl3.writablehome.already-exists}"/></not></bool>
202
203      <!-- set up writable area -->
204      <echo>No previous Greenstone home writable area detected</echo>
205      <echo>  => Setting up area</echo>
206      <mkdir dir="${gsdl3.writablehome}"/>
207      <mkdir dir="${gsdl3.writablehome}/packages"/>
208      <mkdir dir="${gsdl3.writablehome}/logs"/>
209      <mkdir dir="${gsdl3.writablehome}/ext/solr"/>
210
211      <chmod perm="a+rwx" dir="${gsdl3.writablehome}"/>
212      <chmod perm="a+rwx" dir="${gsdl3.writablehome}/packages"/>
213      <chmod perm="a+rwx" dir="${gsdl3.writablehome}/logs"/>
214      <chmod perm="a+rwx" dir="${gsdl3.writablehome}/ext/solr"/>
215
216      <!-- copy over packages tomcat folder -->
217
218      <if>
219    <bool><istrue value="${current.os.iswindows}"/></bool>
220    <copy todir="${gsdl3.writablehome}/packages/tomcat"
221          preservelastmodified="true"
222          failonerror="true" > 
223      <fileset dir="${readonly-packages.home}/tomcat" includes="**"/> 
224    </copy>
225     
226    <else>
227      <!-- else assume Unix -->
228      <!-- Can't go through the OS-independent <copy> task as it fails to preserve exec permissions -->
229      <echo>Copying to ${gsdl3.writablehome}/packages/tomcat</echo>
230      <exec executable="cp" output="/dev/null" spawn="false">
231            <arg value="-r"/>
232            <arg value="${readonly-packages.home}/tomcat"/>
233            <arg value="${gsdl3.writablehome}/packages/."/>
234      </exec>
235
236      <!-- the packages folder in tmp only has read permissions at this stage, it needs more permissions to work when running GS3 off a disc -->
237      <chmod perm="a+rwx" file="${gsdl3.writablehome}/packages/**" />
238
239    </else>
240      </if>
241     
242      <echo>  => Copying Greenstone's web/WEB-INF to writable area</echo>
243      <copy todir="${gsdl3.writablehome}/WEB-INF"
244        preservelastmodified="true"
245        failonerror="true" > 
246    <fileset dir="${full.web.dir}/WEB-INF" includes="**"/> 
247      </copy>
248
249      <copy todir="${gsdl3.writablehome}"
250        preservelastmodified="true"
251        failonerror="true" > 
252    <fileset dir="${web.home}" includes="index.html"/> 
253      </copy>
254
255    </if>
256  </if>
257
258
259  <!--- flax: the WordNet home -->
260  <property name="wn.home" value="${web.home}/WEB-INF/classes/flax/WordNet"/>
261
262  <!-- jni libraries and java wrappers go here -->
263  <property name="lib.jni" value="${basedir}/lib/jni"/>
264
265  <!-- other jar files needed for installation (but not runtime) go here -->
266  <property name="lib.java" value="${basedir}/lib/java"/>
267 
268  <property name="javadocs" value="${basedir}/docs/javadoc"/>
269
270  <property name="app.name"      value="greenstone3"/>
271  <property name="app.path"      value="/${greenstone.context}"/>
272
273   <property name="admin.dir"      value="${basedir}/admin"/>
274
275  <!-- defaults - set these on the command line or in build.properties or
276       they will take these default values-->
277  <property name="app.version" value="trunk"/>
278  <property name="branch.path" value="trunk"/>
279  <property name="branch.revision" value="HEAD"/>
280
281  <!--constants -->
282  <property name="svn.root" value="http://svn.greenstone.org"/>
283
284  <!-- catalina home is set to tomcat basedir if already installed, otherwise
285       use greenstone's tomcat -->
286  <condition property="catalina.home" value="${tomcat.installed.path}" else="${packages.home}/tomcat">
287    <and>
288      <isset property="tomcat.installed.path"/>
289      <not>
290    <equals arg1="" arg2="${tomcat.installed.path}"/>
291      </not>
292    </and>
293  </condition>
294 
295
296  <!-- is there a better way to do this?? what about solaris?? -->
297  <condition property="os.bin.dir" value="${cross.os}">
298      <istrue value="${compile.cross}"/>
299  </condition>
300  <condition property="os.bin.dir" value="windows">
301    <os family="windows"/>
302  </condition>
303  <condition property="os.bin.dir" value="darwin">
304    <os family="mac"/>
305  </condition>
306  <condition property="os.bin.dir" value="linux">
307    <and>
308      <os family="unix"/>
309      <not>
310    <os family="mac"/>
311      </not>
312    </and>
313  </condition>
314
315 
316  <condition property="collection.building.disabled">
317    <and>
318      <isset property="disable.collection.building"/>
319      <istrue value="${disable.collection.building}"/>
320    </and>
321  </condition>
322
323  <condition property="collection.building.enabled">
324    <not>
325      <istrue value="${disable.collection.building}"/>
326    </not>
327  </condition>
328 
329  <condition property="collection.building.enabled.windows">
330    <and>
331      <istrue value="${collection.building.enabled}"/>
332      <isset property="current.os.iswindows"/>
333    </and>
334  </condition>
335 
336  <condition property="collection.building.enabled.unix">
337    <and>
338      <istrue value="${collection.building.enabled}"/>
339      <isset property="current.os.isunix"/>
340    </and>
341  </condition>
342
343  <condition property="static.arg" value="LDFLAGS=-static" else=" ">
344    <isset property="compile.static"/>
345  </condition>
346
347  <!-- If building a release then we want to adjust environment variables so that the support library can be seen during compilation -->
348  <if><bool><isset property="use.gnomelib.ext"/></bool>
349    <property name="gnome-lib-dir" value="${basedir}/ext/gnome-lib-minimal/${os.bin.dir}"/>
350
351    <if><bool><isset property="env.CFLAGS"/></bool>
352        <property name="cflags.arg" value="CFLAGS=&quot;-I${gnome-lib-dir}/include ${env.CFLAGS}&quot;"/>
353    <else>
354        <property name="cflags.arg" value="CFLAGS=&quot;-I${gnome-lib-dir}/include&quot;"/>
355    </else>
356    </if>
357
358    <if><bool><isset property="env.CPPFLAGS"/></bool>
359        <property name="cppflags.arg" value="CPPFLAGS=&quot;-I${gnome-lib-dir}/include ${env.CPPFLAGS}&quot;"/>
360    <else>
361        <property name="cppflags.arg" value="CPPFLAGS=&quot;-I${gnome-lib-dir}/include&quot;"/>
362    </else>
363    </if>
364
365    <if><bool><isset property="env.CXXFLAGS"/></bool>
366        <property name="cxxflags.arg" value="CXXFLAGS=&quot;-I${gnome-lib-dir}/include ${env.CXXFLAGS}&quot;"/>
367    <else>
368            <property name="cxxflags.arg" value="CXXFLAGS=&quot;-I${gnome-lib-dir}/include&quot;"/>
369    </else>
370    </if>
371
372    <!--https://groups.google.com/forum/#!topic/openkinect/m-hfXeYwKtU
373      compiling up libwv on ElCapitan needs -framework CoreFoundation -->
374    <if><bool><isset property="env.LDFLAGS"/></bool>
375        <property name="ldflags.arg" value="LDFLAGS=&quot;-L${gnome-lib-dir}/lib ${env.LDFLAGS}&quot;"/>
376    <else>
377            <property name="ldflags.arg" value="LDFLAGS=&quot;-L${gnome-lib-dir}/lib&quot;"/>
378    </else>
379    </if>
380
381    <if><bool><isset property="env.PATH"/></bool>
382        <property name="path.arg" value="PATH=&quot;${gnome-lib-dir}/bin:${env.PATH}&quot;"/>
383    <else>
384            <property name="path.arg" value="PATH=&quot;${gnome-lib-dir}/bin&quot;"/>
385    </else>
386    </if>
387
388    <if><bool><isset property="env.PKG_CONFIG_PATH"/></bool>
389        <property name="pcpath.arg" value="PKG_CONFIG_PATH=&quot;${gnome-lib-dir}/lib/pkgconfig:${env.PKG_CONFIG_PATH}&quot;"/>
390    <else>
391            <property name="pcpath.arg" value="PKG_CONFIG_PATH=&quot;${gnome-lib-dir}/lib/pkgconfig&quot;"/>
392    </else>
393    </if>
394
395    <if><bool><equals arg1="${os.bin.dir}" arg2="darwin"/></bool>
396      <!--<if><bool><isset property="env.DYLD_LIBRARY_PATH"/></bool>
397          <property name="ldlpath.arg" value="DYLD_LIBRARY_PATH=&quot;${gnome-lib-dir}/lib:${env.DYLD_LIBRARY_PATH}&quot;"/>
398          <else>
399        <property name="ldlpath.arg" value="DYLD_LIBRARY_PATH=&quot;${gnome-lib-dir}/lib&quot;"/>
400              </else>
401          </if>
402            -->
403      <property name="ldlpath.arg" value="DYLD_LIBRARY_PATH=&quot;${env.DYLD_LIBRARY_PATH}&quot;"/>
404    <else>
405        <if><bool><isset property="env.LD_LIBRARY_PATH"/></bool>
406            <property name="ldlpath.arg" value="LD_LIBRARY_PATH=&quot;${gnome-lib-dir}/lib:${env.LD_LIBRARY_PATH}&quot;"/>
407        <else>
408            <property name="ldlpath.arg" value="LD_LIBRARY_PATH=&quot;${gnome-lib-dir}/lib&quot;"/>
409        </else>
410        </if>
411    </else>
412    </if>
413
414
415    <else>
416        <if><bool><isset property="env.CFLAGS"/></bool>
417            <property name="cflags.arg" value="CFLAGS=&quot;${env.CFLAGS}&quot;"/>
418            <else>
419            <property name="cflags.arg" value=" "/>
420        </else>
421        </if>
422
423        <if><bool><isset property="env.CPPFLAGS"/></bool>
424                <property name="cppflags.arg" value="CPPFLAGS=&quot;${env.CPPFLAGS}&quot;"/>
425            <else>
426            <property name="cppflags.arg" value=" "/>
427        </else>
428        </if>
429
430        <if><bool><isset property="env.CXXFLAGS"/></bool>
431            <property name="cxxflags.arg" value="CXXFLAGS=&quot;${env.CXXFLAGS}&quot;"/>
432        <else>
433            <property name="cxxflags.arg" value=" "/>
434        </else>
435        </if>
436
437        <if><bool><isset property="env.LDFLAGS"/></bool>
438            <property name="ldflags.arg" value="LDFLAGS=&quot;${env.LDFLAGS}&quot;"/>
439        <else>
440            <property name="ldflags.arg" value=" "/>
441        </else>
442        </if>
443
444        <if><bool><isset property="env.PATH"/></bool>
445            <property name="path.arg" value="PATH=&quot;${env.PATH}&quot;"/>
446        <else>
447            <property name="path.arg" value=" "/>
448        </else>
449        </if>
450
451        <if><bool><isset property="env.PKG_CONFIG_PATH"/></bool>
452            <property name="pcpath.arg" value="PKG_CONFIG_PATH=&quot;${env.PKG_CONFIG_PATH}&quot;"/>
453        <else>
454            <property name="pcpath.arg" value=" "/>
455        </else>
456        </if>
457
458        <if><bool><equals arg1="${os.bin.dir}" arg2="darwin"/></bool>
459            <if><bool><isset property="env.DYLD_LIBRARY_PATH"/></bool>
460                <property name="ldlpath.arg" value="DYLD_LIBRARY_PATH=&quot;${env.DYLD_LIBRARY_PATH}&quot;"/>
461            <else>
462                <property name="ldlpath.arg" value=" "/>
463            </else>
464            </if>
465        <else>
466            <if><bool><isset property="env.LD_LIBRARY_PATH"/></bool>
467                <property name="ldlpath.arg" value="LD_LIBRARY_PATH=&quot;${env.LD_LIBRARY_PATH}&quot;"/>
468            <else>
469                <property name="ldlpath.arg" value=" "/>
470            </else>
471            </if>
472        </else> 
473        </if>
474    </else>
475  </if>
476  <property name="allargs" value="${cflags.arg} ${cxxflags.arg} ${cppflags.arg} ${ldflags.arg} ${path.arg} ${ldlpath.arg} ${pcpath.arg}"/>
477
478  <condition property="opt.cross.build"
479         value="--build=${cross.build}" else=" ">
480    <isset property="cross.build"/>
481  </condition>
482
483
484  <condition property="cross.configure.args"
485         value="--host=${cross.host} ${opt.cross.build} CPP=${cross.host}-cpp CC=${cross.host}-gcc CXX=${cross.host}-g++ LD=${cross.host}-ld AR=${cross.host}-ar RANLIB=${cross.host}-ranlib STRIP=${cross.host}-strip ${cross.configure.extraargs} crossOS=${cross.os}" else=" ">
486    <istrue value="${compile.cross}"/>
487  </condition>
488
489  <!-- if we're told to work with gnome-lib, or if there's a gnome-lib-minimal that the user
490       has placed in gs2build/ext, then compile gs2build after sourcing gnome-lib environment -->
491  <condition property="opt.gnomelibext.arg"
492         value="--enable-gnome-lib-ext" else=" ">
493    <or>
494      <available file="${gs2build.home}/ext/gnome-lib-minimal" type="dir"/>
495      <istrue value="${use.gnomelib.ext}"/>
496      <istrue value="${checkout.gnomelib.ext}"/>
497    </or>
498   </condition>
499
500<!-- if you want to disable wvware, do so here: set the value (not else) field to contain minus-minus-disable-wvware -->
501  <condition property="gs2.opt.args" value="${opt.gnomelibext.arg} " else="--disable-mg --disable-mgpp --disable-accentfold --disable-gdbm --disable-sqlite">
502    <istrue value="${with.jni}"/>
503  </condition>
504  <condition property="gs2.compile.target" value="with-jni" else="without-jni">
505    <istrue value="${with.jni}"/>
506  </condition>
507  <condition property="gs2.install.target" value="install-with-jni" else="install-without-jni">
508    <istrue value="${with.jni}"/>
509  </condition>
510  <condition property="gs2.windows.enablejni" value="1" else="0">
511    <istrue value="${with.jni}"/>
512  </condition>
513  <condition property="gs2.windows.enablemg" value="1" else="0">
514    <istrue value="${with.jni}"/>
515  </condition>
516  <condition property="gs2.windows.enablemgpp" value="1" else="0">
517    <istrue value="${with.jni}"/>
518  </condition>
519  <!-- Should accent folding not also be set here ?? -->
520  <condition property="gs2.windows.usegdbm" value="1" else="0">
521    <istrue value="${with.jni}"/>
522  </condition>
523  <condition property="gs2.windows.usesqlite" value="1" else="0">
524    <istrue value="${with.jni}"/>
525  </condition>
526 
527  <!-- where is search4j tool -->
528  <condition property="search4j.exec" value="bin/search4j.exe" else="bin/search4j">
529    <isset property="current.os.iswindows"/>
530  </condition>
531
532 
533  <!-- ============= Base dirs for each package and component ============ -->
534  <property name="src.gsdl3.home" value="${src.home}/org/greenstone/gsdl3"/>
535  <property name="anttasks.home" value="${src.home}/org/greenstone/anttasks"/>
536  <property name="gli.home" value="${basedir}/gli"/>
537  <property name="javagdbm.home" value="${src.packages.home}/javagdbm"/>
538
539  <condition property="common.src.home" value="${basedir}/common-src" else="${gs2build.home}${file.separator}common-src">
540    <istrue value="${disable.collection.building}"/>
541  </condition>
542 
543  <property name="build.src.home" value="${gs2build.home}/build-src"/>
544  <property name="gdbm.home" value="${common.src.home}/packages/gdbm"/>
545  <property name="mg.home" value="${common.src.home}/indexers/mg"/>
546  <property name="mgpp.home" value="${common.src.home}/indexers/mgpp"/>
547  <property name="lucene.home" value="${common.src.home}/indexers/lucene-gs"/>
548
549  <!--  ==================== Compilation Control Options ==================== -->
550
551  <!--
552
553  These properties control option settings on the Javac compiler when it
554  is invoked using the <javac> task.
555
556  compile.debug        Should compilation include the debug option?
557
558  compile.deprecation  Should compilation include the deprecation option?
559
560  compile.optimize     Should compilation include the optimize option?
561
562  -->
563
564  <property name="compile.debug"       value="true"/>
565  <property name="compile.deprecation" value="true"/>
566  <property name="compile.optimize"    value="true"/>
567  <property name="compile.encoding"    value="UTF8"/>
568  <property name="compile.includeantruntime" value="false"/> <!-- to get rid of annoying 'ant' warning -->
569
570  <!--
571
572  Rather than relying on the CLASSPATH environment variable, Ant includes
573  features that makes it easy to dynamically construct the classpath you
574  need for each compilation.  The example below constructs the compile
575  classpath to include the servlet.jar file, as well as the other components
576  that Tomcat makes available to web applications automatically, plus anything
577  that you explicitly added.
578
579  -->
580 
581  <!-- All elements that Tomcat 5 exposes to applications -->
582  <path id="tomcat5">
583    <pathelement location="${catalina.home}/common/classes"/>
584    <fileset dir="${catalina.home}/common/endorsed">
585      <include name="*.jar"/>
586    </fileset>
587    <fileset dir="${catalina.home}/common/lib">
588      <include name="*.jar"/>
589    </fileset>
590    <!-- seems to be empty, but will leave in just in case some people make use of this to customise their install: -->
591    <pathelement location="${catalina.home}/shared/classes"/>
592    <fileset dir="${catalina.home}/shared/lib">
593      <include name="*.jar"/>
594    </fileset>
595  </path>
596 
597  <!-- All elements that Tomcat 7 exposes to applications -->
598  <path id="tomcat7">
599    <fileset dir="${catalina.home}/lib">
600      <include name="*.jar"/>
601    </fileset>
602  </path>
603 
604  <path id="compile.classpath">
605    <!-- Include all jar files and libraries in our jni lib directory -->
606    <pathelement location="${lib.jni}"/>
607    <fileset dir="${lib.jni}">
608      <include name="*.jar"/>
609    </fileset>
610    <!-- Include all jar files in our web lib directory -->
611    <pathelement location="${web.lib}"/>
612    <fileset dir="${web.lib}">
613      <include name="*.jar"/>
614    </fileset>
615   
616    <pathelement location="${lib.java}"/>
617    <fileset dir="${lib.java}">
618      <include name="*.jar"/>
619    </fileset>
620   
621    <!-- include the jar files from the source packages -->
622    <!-- mg and mgpp get installed into lib/jni but they may not be there yet
623    so we add them in by name -->
624    <!-- *** is there any way to make this optional, based on ${with.jni}? -->
625    <pathelement location="${lib.jni}/mg.jar"/>
626    <pathelement location="${lib.jni}/mgpp.jar"/>
627   
628    <!-- Include all elements that Tomcat exposes to applications -->
629    <path refid="tomcat${tomcat.version.major}"/>
630   
631  </path>
632
633  <path id="local.tomcat.classpath">
634    <!-- explicitly include the jni java wrappers in the classpath -->
635    <pathelement location="${lib.jni}"/>
636    <fileset dir="${lib.jni}">
637      <include name="*.jar"/>
638    </fileset>
639   
640    <pathelement location="${web.writablelib}"/>
641    <fileset dir="${web.writablelib}">
642      <include name="derbyclient.jar"/> <!--<include name="derby.jar"/>-->
643    </fileset>
644  </path>
645 
646  <path id="derby.server.classpath">
647    <pathelement location="${web.writablelib}/derbynet.jar"/>
648    <pathelement location="${web.writablelib}/derby.jar"/>
649  </path>
650
651 
652    <if><bool><isset property="env.PATH"/></bool>
653      <path id="local.tomcat.path">
654        <pathelement location="${basedir}/bin/script"/>
655        <pathelement location="${basedir}/bin"/>
656        <pathelement location="${lib.jni}"/>   
657        <pathelement path="${env.PATH}"/>
658        <pathelement path="${wn.home}/bin"/>
659      </path>
660      <!-- Windows can be case sensitive about env.PATH, preferring env.Path. See https://ant.apache.org/manual/Tasks/property.html  -->
661      <else><if><bool><isset property="env.Path"/></bool>
662        <path id="local.tomcat.path">
663          <pathelement location="${basedir}/bin/script"/>
664          <pathelement location="${basedir}/bin"/>
665          <pathelement location="${lib.jni}"/>
666          <pathelement path="${env.Path}"/>
667          <pathelement path="${wn.home}/bin"/>
668        </path>
669      <!-- else print error about no path set -->
670      <else>
671        <echo>No env.PATH (or env.Path) set. Unable to set local.tomcat.path property</echo>
672      </else></if></else>   
673    </if>   
674
675  <target name="test-setup">
676    <echo>ant java version=${ant.java.version}</echo>
677    <echo>is unix : ${current.os.isunix}</echo>
678    <echo>is mac : ${current.os.ismac}</echo>
679    <echo>is unixnotmac : ${current.os.isunixnotmac}</echo>
680    <echo>is windows : ${current.os.iswindows}</echo>
681    <echo>os.unix: ${os.unix}</echo>
682    <echo>env.PATH: ${env.PATH}</echo>
683    <echo>env.Path: ${env.Path}</echo> 
684  </target>
685
686  <target name="needs-gs3-setup">
687    <!-- has the gs3-setup script been run?? -->
688    <condition property="gs3-setup-not-done">
689      <not>
690    <isset property="env.GSDL3HOME"/>
691      </not>
692    </condition>
693
694    <fail if="gs3-setup-not-done" message="Please run 'gs3-setup' (Windows) or 'source gs3-setup.sh' (Linux/Mac) before starting the Greenstone server."/>
695  </target>
696
697  <!-- Appends the current env to the file environment.txt. For debugging env vars used by the release-kit. -->
698  <target name="write-env" description="Writes out the environment that this build.xml is executed in to file environment.txt. For debugging.">
699    <echo message="*****************ENVIRONMENT OUTPUT:****************${line.separator}" file="environment.txt" append="true" />
700
701    <if><bool><istrue value="${current.os.iswindows}"/></bool>
702      <exec executable="cmd" dir="${basedir}" failonerror="false" output="environment.txt" append="true">     
703    <arg value="/c" />
704    <arg value="set" />
705      </exec>
706      <else>
707    <exec executable="env" dir="${basedir}" failonerror="false" output="environment.txt" append="true" />
708      </else>
709    </if>
710
711    <echo message="${line.separator}" file="environment.txt" append="true" />
712  </target>
713
714 
715  <!-- ==================== Primary and Global Targets ============================= -->
716
717  <target name="prepare" depends="accept-properties,init,copy-dot-in-files,prepare-core,prepare-packages,prepare-common-src,prepare-collection-building,prepare-tomcat,prepare-axis,prepare-web,prepare-collections, prepare-flax"
718    description="Use this when you first checkout the code: 'ant prepare install'. This will do some additional subversion checkouts and downloads, so you need to be online to run this.">
719
720    <!-- make sure .sh files are executable -->
721    <chmod dir="${basedir}" perm="ugo+rx"
722      includes="*.sh"/>
723    <chmod dir="${basedir}/bin/script" perm="ugo+rx"
724      includes="*.sh,*.pl"/>
725  </target>
726
727  <!-- install-common-src and install-collection-building are mutually exclusive and either one or the other will be done depending on whether collection building is enabled or not -->
728  <!--before configuring build-src, make sure that gnome-lib is compiled up-->
729  <target name="install" depends="init,compile-imagemagick,compile-gnome-lib,install-common-src,install-collection-building,install-runtime,install-solr-ext,setup-for-eclipse,get-isisgdl"
730    description="Install Greenstone 3. Use this when you first checkout the code: 'ant prepare new-install'."/>
731
732  <target name="install-common-src" depends="init"
733    description="Install (configure, compile, install) only the common-src package (shared code from Greenstone 2). " >
734    <antcall target="configure-common-src">
735      <param name="set.ld.path" value="true"/>
736    </antcall>
737    <antcall target="compile-common-src">
738      <param name="set.ld.path" value="true"/>
739    </antcall>
740    <antcall target="install-auxiliary-jar-files"/>
741    <antcall target="install-jni-files"/>
742  </target>
743
744  <target name="install-collection-building" depends="init" if="collection.building.enabled"
745    description="Install (configure, compile, install) the Greenstone 2 collection building package." >
746    <antcall target="configure-collection-building"/>
747    <antcall target="tweak-makefiles" />
748    <antcall target="compile-collection-building"/>
749  </target>
750   
751
752  <target name="install-runtime" depends="init,configure,configure-packages,configure-core,compile-web,compile-packages,compile-core,compile-classpath-jars"
753    description="Install (configure, compile, install) the runtime system. Needs either common-src or collection-building to have been installed first." />
754   
755  <target name="svnupdate" depends="init,svnupdate-packages,svnupdate-core,svnupdate-common-src,svnupdate-collection-building,svnupdate-web"
756    description="Do a `svn update` for all sources. Doesn't recompile the code. You need to be online to run this."/>
757 
758  <target name="configure" depends="init,configure-tomcat,configure-web"
759    description="Configure the installation (not the C++ code). Includes setting up config files. Should be re-run if you change the build.properties file, including if you change the port number."/>
760
761  <target name="clean" depends="init,clean-packages,clean-core,clean-common-src,clean-collection-building,clean-classpath-jars"
762    description="Remove all old compiled code. Includes runtime and collection-building if necessary"/>
763 
764  <target name="distclean" depends="init,distclean-packages,clean-core,distclean-common-src,distclean-collection-building,clean-classpath-jars"
765    description="Remove all compiled code and also any Makefiles etc generated during configure-c++. Includes runtime and collection-building as necessary"/>
766 
767  <target name="update" depends="init,svnupdate,clean,install"
768    description="Update (thru Subversion) all the source (including common-src or collection-building, and runtime), then clean, and re-install. To do this without any SVN updates, run it like 'ant -Dnosvn.mode=yes update'"/>
769
770
771  <target name="perl-for-building" depends="init">
772    <!-- uses perl.path if set in build.properties, otherwise try for
773         environment variable PERLPATH, and failing that assumes 'perl'
774         is on environment PATH -->
775    <!-- if, outside build.properties, we only set perl.path if we have gs2build/build-src (collection building), then we won't set perl.path in a (flax) binary, since it doesn't have build-src -->
776    <if><bool><available file="${gs2build.home}"/></bool>
777
778      <if><bool><not><isset property="perl.path"/></not></bool>
779
780        <if>
781          <bool>
782            <and>
783              <isset property="env.PERLPATH"/>
784              <not><equals arg1="${env.PERLPATH}" arg2=""/></not>
785            </and>
786          </bool>
787          <!-- set perlpath to env.PERLPATH.
788            This is the path to perl\bin that's found by findperl.bat when the server is launched
789            through GLI instead of the console.
790            For windows, this env.PERLPATH is the bin folder and needs a backslash at end, since it
791            will appear suffixed with "perl.exe" in the perl setting in packages\tomcat\config\web.xml.
792            This web.xml's path to perl is then used to find perl when running the perl scripts in the
793            cgi folder, so without a slash appended at this point it becomes "binperl" in web.xml, and
794            things will break when GLI launches the server on Windows and the online GS3 metadata editor
795            is used to save user-edited metadata. -->
796          <if><bool><istrue value="${current.os.iswindows}"/></bool>
797            <property name="perl.path" value="${env.PERLPATH}\"/>
798          <else>
799            <property name="perl.path" value="${env.PERLPATH}"/>
800          </else>   
801          </if>
802         
803          <else>
804            <echo>
805  Using PATH environment variable to locate Perl.
806            </echo>
807            <exec executable="which" os="${os.unix}" spawn="false" outputproperty="full.perl.path">
808              <arg value="perl" />
809            </exec>
810
811        <exec executable="${gs2build.home}/bin/windows/which" osfamily="windows" spawn="false" outputproperty="full.perl.path">
812              <arg value="perl" />
813            </exec>
814
815            <stringutil string="${full.perl.path}" property="partial.perl.path">
816                <replace regex="\/[^\/]*$" replacement="/" />
817            </stringutil>
818        <stringutil string="${partial.perl.path}" property="perl.path">
819                <replace regex="\\[^\\]*$" replacement="\\" />
820            </stringutil>
821            <if><bool><istrue value="${current.os.isunix}"/></bool>
822              <if><bool><not><equals arg1="${full.perl.path}" arg2="/usr/bin/perl"/></not></bool>
823                <echo>
824    Non-standard location of Perl found: ${full.perl.path}
825    Set the environment variable PERLPATH or the perl.path property in
826    build.properties to explicitly control the version of Perl used.
827                </echo>
828              </if>
829            </if>
830          </else>
831        </if>
832      </if>
833
834      <!-- full.perl.path is for pretty-printing only, e.g. used in target "start" -->
835      <if><bool><isset property="perl.path"/></bool>
836        <property name="full.perl.path" value="${perl.path}${file.separator}perl"/>
837        <else>
838          <property name="full.perl.path" value="perl (will use the enviroment variable PATH to find this executable)"/>
839        </else>
840      </if>
841
842      <!-- gs2build not available, perl.path -->
843      <else>
844    <property name="perl.path" value=""/>
845      </else>
846    </if>
847    <stringutil string="${perl.path}" property="escaped.perl.path">
848      <replace regex="\\" replacement="\\\\" />
849    </stringutil>
850  </target>
851
852  <target name="get-default-servlet-url">
853    <echo>${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}</echo>
854  </target>
855
856  <target name="get-solr-servlet-url">
857    <echo>${server.protocol}://${tomcat.server}:${tomcat.port}/${solr.context}</echo>
858  </target>
859
860  <target name="check-derbyserver-running">
861    <condition property="derby.isrunning" value="true" else="false">
862      <!--<socket server="jdbc:derby://${derby.server}" port="${derby.server.port}"/>-->
863      <socket server="${derby.server}" port="${derby.server.port}"/><!-- like telnet machine port -->
864    </condition>
865    <echo>Derby is running: ${derby.isrunning}</echo>
866  </target>
867
868  <!-- Need a copy of the check-derby-running target with a distinct property, because ant restart runs
869       both stop and start, which stop and start derby respectively. Both  need check the derby socket.
870       Because each property can be set only once during an invocation with ant, ant restart will need
871       two check-derbyserver properties, one for each derby check. -->
872  <target name="check-derbyserver-started">
873    <condition property="derby.isstarted" value="true" else="false">
874      <socket server="${derby.server}" port="${derby.server.port}"/>
875    </condition>
876    <echo>Derby is running: ${derby.isstarted}</echo>
877  </target>
878
879
880  <!-- Unused -->
881  <target name="start-derby-java" depends="check-derbyserver-running">
882    <if><bool><not><istrue value="${derby.isrunning}"/></not></bool>
883      <echo>Launching derby on ${derby.server}:${derby.server.port}...</echo>
884      <java classname="org.apache.derby.drda.NetworkServerControl" fork="true" spawn="true" clonevm="true">     
885    <arg value="start"/>
886    <classpath refid="derby.server.classpath"/>
887      </java>
888      <else>
889    <echo>Derby server ALREADY RUNNING on ${derby.server}:${derby.server.port}</echo>
890      </else>
891    </if>
892  </target>
893 
894  <target name="start-derby" depends="check-derbyserver-started">
895    <if><bool><not><istrue value="${derby.isstarted}"/></not></bool>
896      <echo>About to launch derby on ${derby.server}:${derby.server.port}</echo>
897      <antcall target="force-start-derby"/>
898      <else>
899    <echo>Derby networked server ALREADY RUNNING on ${derby.server}:${derby.server.port}</echo>
900      </else>
901    </if>
902  </target>
903
904  <!-- Using derby 10.1.2.1
905       See db-derby-10.1.2.1-bin/docs/html/adminguide/index.html -->
906  <target name="force-start-derby">
907      <property name="derby.server.classpath.prop" refid="derby.server.classpath" />
908     
909      <exec executable="java" spawn="true"><!-- failonerror="true"-->
910    <env key="CLASSPATH" path="${derby.server.classpath.prop}"/>
911    <arg value="org.apache.derby.drda.NetworkServerControl"/>
912    <arg value="start"/>
913    <arg value="-p"/>
914    <arg value="${derby.server.port}"/>
915      </exec>
916
917  </target>
918
919  <target name="force-stop-derby">
920    <java classname="org.apache.derby.drda.NetworkServerControl">
921      <arg value="shutdown"/>
922      <arg value="-p"/>
923      <arg value="${derby.server.port}"/>
924      <classpath refid="derby.server.classpath"/>
925    </java>
926  </target>
927
928  <target name="stop-derby" description="Shutdown derby server only if running" depends="check-derbyserver-running"><!-- if="${derby.isrunning}" checks if true or false only from ant 1.8 on -->
929    <if><bool><istrue value="${derby.isrunning}"/></bool>
930      <!--<echo>Derby is |${derby.isrunning}| running</echo>-->
931      <antcall target="force-stop-derby"/>
932      <else>
933    <echo>Derby is not running</echo>
934      </else>
935    </if>
936  </target>
937
938  <target name="start" depends="needs-gs3-setup,init,configure-tomcat,configure-web,configure-solr-ext,start-derby,start-tomcat"
939    description="Startup the Tomcat server." >
940    <echo>${app.name} (${app.version}) server running using Apache Tomcat and Java</echo>
941    <echo>Tomcat: ${catalina.home}</echo>
942    <echo>Java  : ${java.home}</echo>
943    <if><bool><available file="${build.src.home}"/></bool>
944      <echo>Perl  : ${full.perl.path}</echo>
945    </if>
946    <if><bool><isset property="install.flax"/></bool>
947        <property name="url" value="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/flax"/>
948    <else>
949        <property name="url" value="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/"/>
950    </else>
951    </if>
952    <echo>URL   : ${url}</echo>
953    <!-- assuming that index.html is not needed here -->   
954
955    <!--Now write out the url with oaiserver suffix as the baseURL property in OAIConfig.xml-->
956    <available file="${basedir}/resources/oai/OAIConfig.xml" property="oaiconfig.present"/>
957    <antcall target="init-oaiconfig">
958      <param name="url" value="${url}"/>
959    </antcall>
960  </target>
961
962  <target name="init-oaiconfig" if="oaiconfig.present">
963    <echo>Writing out baseURL ${url}oaiserver to ${web.writableclasses}/OAIConfig.xml</echo>
964    <copy file="${basedir}/resources/oai/OAIConfig.xml" tofile="${web.writableclasses}/OAIConfig.xml"/>
965    <rsr verbosity="1" file="${web.writableclasses}/OAIConfig.xml" pattern="&lt;baseURL&gt;.*&lt;/baseURL&gt;" replacement="&lt;baseURL&gt;${url}oaiserver&lt;/baseURL&gt;" />   
966  </target>
967
968  <target name="stop" depends="init,stop-tomcat,stop-derby"
969    description="Shutdown the Tomcat server."/>
970 
971  <target name="restart" description="Shutdown and restart Tomcat"  depends="init,stop,start"/>
972
973  <!-- =========== Help targets ===================================  -->
974 
975  <property name="install-command" value="ant [options] prepare install"/>
976 
977  <target name="usage" description="Print a help message">
978    <echo message="  Execute 'ant -projecthelp' for a list of targets."/>
979    <echo message="  Execute 'ant -help' for Ant help."/>
980    <echo>
981  To install Greenstone3, run '${install-command}'.
982    There are properties defined in build.properties. The install
983      process will ask you if these properties are set correctly.
984      To avoid this prompt, use the '-Dproperties.accepted=yes'
985      option.
986    To log the output, use the '-logfile build.log' option.
987  The README.txt file has more information about the ant targets
988    and install process.
989    </echo>
990  </target>
991 
992  <target name="help" depends="usage" description="Print a help message"/>
993 
994  <target name="debug" depends="init" description="Display all the currently used properties">
995    <echoproperties/>
996  </target>
997
998  <!-- ====== initialization and setup targets ================== -->
999
1000  <target name="accept-properties" unless="properties.accepted">
1001    <input addproperty="properties.ok" validargs="y,n">The following properties (among others) are being used from a build.properties file found in this directory:
1002      tomcat.server=${tomcat.server}
1003      tomcat.port=${tomcat.port}
1004      tomcat.installed.path=${tomcat.installed.path} (this is the location of Tomcat's base dir if it is already installed)
1005      proxy.host=${proxy.host}
1006      proxy.port=${proxy.port}
1007      disable.collection.building=${disable.collection.building}
1008      If these are not acceptable, please change them and rerun this target. Continue [y/n]?
1009    </input>
1010    <condition property="do.abort">
1011      <equals arg1="n" arg2="${properties.ok}"/>
1012    </condition>
1013    <fail if="do.abort">Build aborted by user. Please change your properties settings and re-run the target</fail>
1014  </target>
1015 
1016  <!-- this sets up some initial properties -->
1017  <target name="init">
1018   
1019    <condition property="java.too.old">
1020      <or>
1021        <equals arg1="1.1" arg2="${ant.java.version}"/>
1022        <equals arg1="1.2" arg2="${ant.java.version}"/>
1023        <equals arg1="1.3" arg2="${ant.java.version}"/>
1024      </or>
1025    </condition>
1026    <fail if="java.too.old" message="You need Java 1.4 or greater to run Greenstone 3"/>
1027   
1028    <available file="${basedir}/gli" property="gli.present"/>
1029    <available file="${basedir}/common-src" property="common.src.present"/>
1030    <available file="${basedir}/gs2build" property="gs2build.present"/>
1031    <available file="${gnome-lib-dir}" property="gnome-lib.present"/>
1032
1033    <condition property="tomcat.islocal">
1034      <or>
1035        <not><isset property="tomcat.installed.path"/></not>
1036        <equals arg1="" arg2="${tomcat.installed.path}"/>
1037      </or>
1038    </condition>
1039   
1040    <echo>tomcat.port = ${tomcat.port}</echo>
1041
1042    <condition property="proxy.present">
1043      <and>
1044        <isset property="proxy.host"/>
1045        <not><equals arg1="" arg2="${proxy.host}"/></not>
1046      </and>
1047    </condition>
1048
1049    <!--
1050    the next block checks if the bundled tomcat is present in the 'packages' directory,
1051    and checks for the lethal combination of tomcat 7 and java 1.4. Test for
1052    tomcat6 is based on the presence of a file inserted by greenstone into the tomcat6
1053    download, as there is no other surefire way to check tomcat version under java 1.4
1054    -->
1055    <condition property="packages.tomcat.ispresent" value="true" else="false">
1056      <available file="packages/tomcat"/>
1057    </condition>
1058    <condition property="packages.tomcat.istomcat7" value="true" else="false">
1059      <available file="packages/tomcat/tomcat7.txt"/>
1060    </condition>
1061    <if>
1062      <bool>
1063        <and>
1064          <istrue value="${packages.tomcat.ispresent}"/>
1065          <istrue value="${packages.tomcat.istomcat7}"/>
1066          <equals arg1="1.4" arg2="${ant.java.version}"/>
1067        </and>
1068      </bool>
1069      <fail>Your Java (version 1.4) is too old to work with the bundled Apache Tomcat (version 6). Please upgrade to Java version 1.5 or greater. Alternatively, you may remove the bundled Apache Tomcat from the 'packages' folder and then run 'ant prepare-tomcat'.</fail>
1070    </if>
1071
1072  </target>
1073
1074  <target name="setup-proxy" depends="init" if="proxy.present">
1075    <condition property="ask.user">
1076      <or>
1077        <equals arg1="" arg2="${proxy.user}"/>
1078        <equals arg1="" arg2="${proxy.password}"/>
1079      </or>
1080    </condition>
1081   
1082    <getuserandpassword message="Using proxy: ${proxy.host}:${proxy.port}" if="ask.user" username="${proxy.user}" userproperty="proxy.username" pwordproperty="proxy.password"/>
1083    <mysetproxy proxyhost="${proxy.host}" proxyport="${proxy.port}" proxyuser="${proxy.username}" proxypassword="${proxy.password}"/>
1084  </target>
1085 
1086  <target name="copy-dot-in-files" depends="init"
1087      description="Copies all resources .in files to version without the .in suffix" >
1088    <if><bool><available file="${basedir}/resources/tomcat/greenstone3.xml"/></bool>
1089      <copy file="${basedir}/resources/tomcat/greenstone3.xml" tofile="${basedir}/resources/tomcat/greenstone3.xml.backup"  overwrite="true"/>
1090    </if>
1091   
1092    <copy file="${basedir}/resources/tomcat/greenstone3.xml.in" tofile="${basedir}/resources/tomcat/greenstone3.xml"  overwrite="true"/>
1093    <if><bool><available file="${basedir}/resources/tomcat/server_tomcat5.xml"/></bool>
1094      <copy file="${basedir}/resources/tomcat/server_tomcat5.xml" tofile="${basedir}/resources/tomcat/server_tomcat5.xml.backup"  overwrite="true"/>
1095    </if>
1096    <copy file="${basedir}/resources/tomcat/server_tomcat5.xml.in" tofile="${basedir}/resources/tomcat/server_tomcat5.xml"  overwrite="true"/>
1097    <if><bool><available file="${basedir}/resources/tomcat/server_tomcat7.xml"/></bool>
1098      <copy file="${basedir}/resources/tomcat/server_tomcat7.xml" tofile="${basedir}/resources/tomcat/server_tomcat7.xml.backup"  overwrite="true"/>
1099    </if>
1100    <copy file="${basedir}/resources/tomcat/server_tomcat7.xml.in" tofile="${basedir}/resources/tomcat/server_tomcat7.xml" overwrite="true"/>
1101    <if><bool><available file="${basedir}/resources/tomcat/web.xml"/></bool>
1102      <copy file="${basedir}/resources/tomcat/web.xml" tofile="${basedir}/resources/tomcat/web.xml.backup"  overwrite="true"/>
1103    </if>
1104    <copy file="${basedir}/resources/tomcat/web.xml.in" tofile="${basedir}/resources/tomcat/web.xml"  overwrite="true"/>
1105    <if><bool><available file="${basedir}/resources/oai/OAIConfig.xml"/></bool>
1106    <copy file="${basedir}/resources/oai/OAIConfig.xml" tofile="${basedir}/resources/oai/OAIConfig.xml.backup"  overwrite="true"/>
1107    </if>
1108    <copy file="${basedir}/resources/oai/OAIConfig.xml.in" tofile="${basedir}/resources/oai/OAIConfig.xml"  overwrite="true"/>
1109    <if><bool><available file="${basedir}/resources/cgi/gsdl3site.cfg"/></bool>
1110      <copy file="${basedir}/resources/cgi/gsdl3site.cfg" tofile="${basedir}/resources/cgi/gsdl3site.cfg.backup" overwrite="true"/>
1111    </if>
1112    <copy file="${basedir}/resources/cgi/gsdl3site.cfg.in" tofile="${basedir}/resources/cgi/gsdl3site.cfg" overwrite="true"/>
1113    <if><bool><available file="${basedir}/resources/web/global.properties"/></bool>
1114    <copy file="${basedir}/resources/web/global.properties" tofile="${basedir}/resources/web/global.properties.backup" overwrite="true"/>
1115    </if>
1116    <copy file="${basedir}/resources/web/global.properties.in" tofile="${basedir}/resources/web/global.properties" overwrite="true"/>
1117    <if><bool><available file="${basedir}/resources/web/log4j.properties"/></bool>
1118    <copy file="${basedir}/resources/web/log4j.properties" tofile="${basedir}/resources/web/log4j.properties.backup" overwrite="true"/>
1119    </if>
1120    <copy file="${basedir}/resources/web/log4j.properties.in" tofile="${basedir}/resources/web/log4j.properties" overwrite="true"/>
1121  </target>
1122  <!-- ========== Web app Targets ================================ -->
1123 
1124  <target name="prepare-web" depends="init">
1125    <mkdir dir="${web.writablehome}/applet"/>
1126    <mkdir dir="${web.writablehome}/logs"/>
1127    <mkdir dir="${web.writablehome}/logs/tmp"/>
1128  </target>
1129 
1130  <!-- if we are using java 1.5+, we need the xalan.jar file in web/WEB-INF/lib,  but if we are using java 1.4, we can't have it there.
1131       The test for whether we need it assumes we won't be trying to compile GS3 against Java versions less than 1.4. -->
1132  <target name="configure-java-version" depends="init"
1133    description="Activates or deactivates some jar libraries as needed depending on your java version">
1134
1135    <available property="have.xalan.jar" file="${web.lib}/xalan.jar"/>
1136    <condition property="need.xalan.jar">
1137      <or>
1138        <not><equals arg1="1.4" arg2="${ant.java.version}"/></not>
1139      </or>
1140    </condition>
1141
1142    <!-- if they have xalan.jar but dont need it -->
1143    <if>
1144      <bool>
1145        <and>
1146          <isset property="have.xalan.jar"/>
1147          <not><isset property="need.xalan.jar"/></not>
1148        </and>
1149      </bool>
1150      <antcall target="deactivate-xalan-jar"/>
1151    </if>
1152
1153    <!-- if they need xalan.jar but dont have it -->
1154    <if>
1155      <bool>
1156        <and>
1157          <not><isset property="have.xalan.jar"/></not>
1158          <isset property="need.xalan.jar"/>
1159        </and>
1160      </bool>
1161      <antcall target="activate-xalan-jar"/>
1162    </if>
1163
1164  </target>
1165 
1166  <target name="activate-xalan-jar">
1167    <echo>activating xalan.jar</echo>
1168    <copy file="${web.lib}/xalan.jar.tmp" tofile="${web.lib}/xalan.jar"/>
1169    <if>
1170      <bool>
1171    <and>
1172      <isset property="current.os.ismac"/>
1173      <available file="${catalina.home}/common/endorsed" type="dir"/>
1174    </and>
1175      </bool>
1176      <copy file="${web.lib}/xalan.jar.tmp" tofile="${catalina.home}/common/endorsed/xalan.jar"/>
1177    </if>
1178  </target>
1179
1180  <target name="deactivate-xalan-jar">
1181    <echo>deactivating xalan.jar</echo>
1182    <delete file="${web.lib}/xalan.jar"/>
1183    <!-- should we be deleting common/endorsed/xalan.jar on mac?? -->
1184  </target>
1185
1186
1187  <target name="prepare-collections" depends="init"
1188    description="Unpack all the collections from their svn zipped versions">
1189    <property name="collect.dir" value="${web.home}/sites/localsite/collect"/>
1190    <property name="index.zip" value="index.zip"/>
1191
1192    <echo message="installing collections..."/>
1193    <antcall target="gs2mgdemo-install"/>
1194    <antcall target="gs2mgppdemo-install"/>
1195    <antcall target="gberg-install"/>
1196    <antcall target="lucene-jdbm-demo-install"/>
1197  </target>
1198
1199  <target name="gs2mgdemo-prepare" if="collect.dir">
1200    <property name="gs2mgdemo.dir" value="${collect.dir}/gs2mgdemo"/>
1201
1202    <condition property="gs2mgdemo.present">
1203      <and>
1204        <available file="${gs2mgdemo.dir}/${index.zip}"/>
1205      </and>
1206    </condition>
1207  </target>
1208
1209  <target name="gs2mgdemo-install" if="gs2mgdemo.present" depends="gs2mgdemo-prepare">
1210    <unzip dest="${gs2mgdemo.dir}" src="${gs2mgdemo.dir}/${index.zip}" />
1211    <echo>collection gs2mgdemo installed</echo>
1212  </target>
1213
1214  <target name="gs2mgppdemo-prepare" if="collect.dir">
1215    <property name="gs2mgppdemo.dir" value="${collect.dir}/gs2mgppdemo"/>
1216 
1217    <condition property="gs2mgppdemo.present">
1218      <and>
1219        <available file="${gs2mgppdemo.dir}/${index.zip}"/>
1220      </and>
1221    </condition>
1222  </target>
1223
1224  <target name="gs2mgppdemo-install" if="gs2mgppdemo.present" depends="gs2mgppdemo-prepare">
1225    <unzip dest="${gs2mgppdemo.dir}" src="${gs2mgppdemo.dir}/${index.zip}" />
1226    <echo>collection gs2mgppdemo installed</echo>
1227  </target>   
1228
1229  <target name="gberg-prepare" if="collect.dir">
1230    <property name="gberg.dir" value="${collect.dir}/gberg"/>
1231    <available file="${gberg.dir}/index/${index.zip}" property="gberg.present"/>
1232  </target>
1233
1234  <target name="gberg-install" if="gberg.present" depends="gberg-prepare">
1235    <unzip dest="${gberg.dir}/index" src="${gberg.dir}/index/${index.zip}"/>
1236    <echo>collection gberg installed</echo>
1237  </target>
1238
1239  <target name="lucene-jdbm-demo-prepare" if="collect.dir">
1240    <property name="lucene-jdbm-demo.dir" value="${collect.dir}/lucene-jdbm-demo"/>
1241    <available file="${lucene-jdbm-demo.dir}/${index.zip}" property="lucene-jdbm-demo.present"/>
1242  </target>
1243
1244  <target name="lucene-jdbm-demo-install" if="lucene-jdbm-demo.present" depends="lucene-jdbm-demo-prepare">
1245    <unzip dest="${lucene-jdbm-demo.dir}" src="${lucene-jdbm-demo.dir}/${index.zip}"/>
1246    <echo>collection lucene-jdbm-demo installed</echo>
1247  </target>
1248
1249 
1250  <target name="install-solr-ext" depends="init" >
1251    <exec executable="ant.bat" osfamily="windows" dir="${solr-ext.home}" spawn="false">
1252      <arg value="add-service"/>
1253    </exec>
1254    <exec executable="ant" os="${os.unix}" dir="${solr-ext.home}" spawn="false">
1255      <arg value="add-service"/>
1256    </exec>
1257    <antcall target="solr-jdbm-demo-install"/>
1258  </target>
1259
1260  <target name="solr-jdbm-demo-prepare" if="collect.dir">
1261    <property name="solr-jdbm-demo.dir" value="${collect.dir}/solr-jdbm-demo"/>
1262    <available file="${solr-jdbm-demo.dir}/${index.zip}" property="solr-jdbm-demo.present"/>
1263  </target>
1264
1265  <target name="solr-jdbm-demo-install" if="solr-jdbm-demo.present" depends="solr-jdbm-demo-prepare">
1266    <unzip dest="${solr-jdbm-demo.dir}" src="${solr-jdbm-demo.dir}/${index.zip}"/>
1267    <echo>collection solr-jdbm-demo installed</echo>
1268  </target>
1269
1270  <!-- Until 64 bit Linux and Mac (Lion) machines can generate a working IsisGdl,
1271       use the ones generated on a 32 bit Linux and Mac (Leopard), respectively -->
1272  <target name="get-isisgdl" if="${current.os.isunix}">
1273    <exec executable="uname" dir="${basedir}" failonerror="false"
1274      outputproperty="uname.val">
1275      <arg value="-m"/>
1276    </exec>
1277   
1278    <if><bool><equals arg1="${uname.val}" arg2="x86_64"/></bool>
1279      <echo>Bitness: ${uname.val}</echo>
1280      <if><bool><contains string="${os.bin.dir}" substring="darwin" casesensitive="false"/></bool>
1281    <get src="http://www.greenstone.org/caveat-emptor/IsisGdl.macleopard"
1282             dest="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl"/>   
1283      </if>
1284      <if><bool><contains string="${os.bin.dir}" substring="linux" casesensitive="false"/></bool>
1285    <get src="http://www.greenstone.org/caveat-emptor/IsisGdl.bin32"
1286             dest="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl"/>
1287      </if>
1288      <chmod file="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl" perm="755"/>
1289    </if>
1290  </target>
1291
1292  <target name="set-perl-shebangs" depends="perl-for-building">
1293    <if>
1294      <bool>
1295        <and><isset property="perl.path"/>
1296          <not><equals arg1="${perl.path}" arg2=""/></not>
1297        </and>
1298      </bool>
1299
1300      <if><bool><istrue value="${current.os.iswindows}"/></bool>
1301    <property name="perl.exec" value="${perl.path}perl.exe"/>
1302    <else>
1303      <property name="perl.exec" value="${perl.path}perl"/>   
1304    </else>
1305      </if>
1306
1307      <!--<echo>**** PERLPATH: ${perl.path}</echo>-->
1308      <echo>Setting perl shebangs to Perl Exec: ${perl.exec}</echo>
1309
1310      <!-- set the shebangs in the cgi files to point to the correct perlpath -->
1311      <if>
1312    <bool><not><equals arg1="${web.home}" arg2="${web.writablehome}"></equals></not></bool>
1313    <mkdir dir="${web.writablehome}"/>
1314    <copy file="${full.web.dir}/WEB-INF/cgi/gliserver.pl"       tofile="${web.writablehome}/WEB-INF/cgi/gliserver.pl"       overwrite="true"/>
1315    <copy file="${full.web.dir}/WEB-INF/cgi/metadata-server.pl" tofile="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" overwrite="true"/>
1316    <copy file="${full.web.dir}/WEB-INF/cgi/checksum.pl"        tofile="${web.writablehome}/WEB-INF/cgi/checksum.pl"        overwrite="true"/>
1317      </if>
1318
1319      <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/gliserver.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1320      <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1321      <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/checksum.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>     
1322      <else>
1323    <echo>WARNING: perl.path is empty. Unable to set the shebangs in the perl files in ${web.writablehome}/WEB-INF/cgi</echo>
1324      </else>
1325    </if>
1326  </target>
1327
1328  <target name="configure-web" depends="init,perl-for-building"
1329    description="Configure only the web app config files">
1330    <!-- we want a unix path in the global.properties file -->
1331    <pathconvert targetos="unix" property="src.gsdl3.home.unix">
1332      <path path="${web.home}"/>
1333    </pathconvert>
1334    <pathconvert targetos="unix" property="src.gsdl3.writablehome.unix">
1335      <path path="${web.writablehome}"/>
1336    </pathconvert>
1337
1338    <antcall target="set-perl-shebangs" inheritAll="true" />
1339   
1340    <filter token="gsdlhome" value="${gs2build.home}"/>
1341    <filter token="gsdlhomequoted" value="&quot;${gs2build.home}&quot;"/>
1342    <filter token="gsdl3srchome" value="${basedir}"/>
1343    <filter token="gsdl3srchomequoted" value="&quot;${basedir}&quot;"/>
1344    <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
1345    <filter token="gsdl3homequoted" value="&quot;${src.gsdl3.home.unix}&quot;"/>
1346    <filter token="gsdl3writablehome" value="${src.gsdl3.writablehome.unix}"/>
1347    <filter token="gsdl3version" value="${app.version}"/>
1348    <filter token="tomcat.server" value="${tomcat.server}"/>
1349    <filter token="tomcat.port" value="${tomcat.port}"/>
1350    <filter token="greenstone.context" value="${greenstone.context}"/>
1351    <filter token="derbyserver" value="${derby.server}"/>
1352    <filter token="derbyserver.port" value="${derby.server.port}"/>
1353    <filter token="perlpath" value="${escaped.perl.path}"/>
1354    <filter token="disable.collection.building" value="${disable.collection.building}"/>
1355    <copy file="${basedir}/resources/cgi/gsdl3site.cfg" tofile="${web.writablehome}/WEB-INF/cgi/gsdl3site.cfg" filtering="true" overwrite="true"/>
1356    <copy file="${basedir}/resources/web/global.properties" tofile="${web.writableclasses}/global.properties" filtering="true" overwrite="true"/>
1357    <copy file="${basedir}/resources/web/log4j.properties" tofile="${web.writableclasses}/log4j.properties" filtering="true" overwrite="true"/>
1358    <if><bool><istrue value="${gsdl3home.isreadonly}"/></bool>
1359      <!-- uncomment the writablehome properties -->
1360      <rsr verbosity="1" file="${web.writableclasses}/global.properties" pattern="^#gsdl3\.(writable{1})?home" replacement="gsdl3.$1home" />
1361    </if>
1362    <chmod file="${web.writableclasses}/global.properties" perm="644"/>
1363    <chmod file="${web.writableclasses}/log4j.properties" perm="644"/>
1364  </target>
1365
1366  <target name="compile-web" depends="init">
1367    <javac srcdir="${web.classes}"
1368      destdir="${web.classes}"
1369      includeantruntime="${compile.includeantruntime}"
1370      debug="${compile.debug}"
1371      deprecation="${compile.deprecation}"
1372      optimize="${compile.optimize}"
1373      encoding="${compile.encoding}">
1374      <classpath><path refid="compile.classpath"/></classpath>
1375    </javac>
1376  </target>
1377
1378  <target name="compile-classpath-jars" depends="init">
1379    <if><bool><available file="admin/cp.mf"/></bool>
1380      <jar destfile="admin/cp.jar" manifest="admin/cp.mf"/>
1381    </if>
1382    <if><bool><available file="${lib.java}/cp.mf"/></bool>
1383      <jar destfile="${lib.java}/cp.jar" manifest="${lib.java}/cp.mf"/>
1384    </if>
1385    <if><bool><available file="${lib.jni}/cp.mf"/></bool>
1386      <jar destfile="${lib.jni}/cp.jar" manifest="${lib.jni}/cp.mf"/>
1387    </if>
1388    <if><bool><available file="${web.lib}/cp.mf"/></bool>
1389      <jar destfile="${web.lib}/cp.jar" manifest="${web.lib}/cp.mf"/>
1390    </if>
1391    <jar destfile="cp.jar">
1392      <manifest>
1393        <attribute name="Class-Path" value="server.jar admin/cp.jar lib/java/cp.jar lib/jni/cp.jar web/WEB-INF/lib/cp.jar"/>
1394      </manifest>
1395    </jar>
1396  </target>
1397
1398  <target name="clean-classpath-jars" depends="init">
1399    <delete file="admin/cp.jar"/>
1400    <delete file="${lib.java}/cp.jar"/>
1401    <delete file="${lib.jni}/cp.jar"/>
1402    <delete file="${web.lib}/cp.jar"/>
1403    <delete file="cp.jar"/>
1404  </target>
1405
1406
1407  <target name="svnupdate-web" unless="nosvn.mode">
1408    <exec executable="svn">
1409      <arg value="update"/>
1410      <arg value="${web.writablehome}"/>
1411      <arg value="-r"/><arg value="${branch.revision}"/>
1412    </exec>
1413  </target>
1414
1415  <target name="update-web" depends="init,svnupdate-web,configure-web"
1416    description="update only the web stuff (config files)"/>
1417
1418  <!-- ======================= Tomcat Targets ========================== -->
1419 
1420  <!-- this target downloads and installs Tomcat -->
1421  <!-- we download tomcat (version 7 for Java 1.5 and later, version 5 for Java 1.4 plus the 1.4 compatibility package). -->
1422  <target name="prepare-tomcat" depends="init,setup-proxy" if="tomcat.islocal"
1423    description="downloads the appropriate version of Tomcat (Tomcat 5 if using Java 1.4, Tomcat 7 if using Java 1.5 or higher). If you want to change which version of Java you are using between 1.4 and 1.5/7 then you need to run prepare-tomcat">
1424  <if>
1425      <bool>
1426        <not><available file="${packages.home}/tomcat/.flagfile"/></not>
1427      </bool>
1428
1429      <!-- check that packages dir is there -->
1430      <mkdir dir="${packages.home}"/>
1431      <get src="http://www.greenstone.org/gs3files/${tomcat.version}.zip"
1432        dest="${packages.home}/${tomcat.version}.zip"
1433        usetimestamp="true"/>
1434      <unzip src="${packages.home}/${tomcat.version}.zip"
1435        dest="${packages.home}"/>
1436     
1437      <!-- If we are using Java 1.4, we'd be using tomcat 5.5 in which case
1438      we would need to have the tomcat compat package to work with Java 1.4-->
1439      <if>
1440    <bool><equals arg1="1.4" arg2="${ant.java.version}"/></bool>
1441    <get src="http://www.greenstone.org/gs3files/${tomcat.version}-compat.zip"
1442      dest="${packages.home}/${tomcat.version}-compat.zip"
1443      usetimestamp="true"/>
1444    <unzip src="${packages.home}/${tomcat.version}-compat.zip"
1445      dest="${packages.home}"/>
1446      </if>
1447     
1448      <!-- delete any existing tomcat -->
1449      <delete dir="${packages.home}/tomcat"/>
1450      <move todir="${packages.home}/tomcat">
1451        <fileset dir="${packages.home}/${tomcat.version}"/>
1452      </move>
1453     
1454      <!-- To avoid the CGI permissions error appearing continuously in the (localhost) log,
1455        need privileged=true set in the root context.xml file too, not just greenstone context file.
1456        See http://stackoverflow.com/questions/9845936/tomcat-v7-0-load-exception-marking-servlet-ssi-as-unavailable/10305471#10305471
1457        For usage of IfTask IsLessThan: http://antelope.stage.tigris.org/nonav/docs/manual/bk03ch05s02.html -->
1458      <if><bool><not><islessthan arg1="${tomcat.version.major}" arg2="7"/></not></bool>     
1459        <copy file="${basedir}/resources/tomcat/root_context.xml" tofile="${packages.home}/tomcat/conf/context.xml" overwrite="true" />     
1460      </if>
1461       
1462     
1463      <!--
1464      <copy file="${basedir}/resources/tomcat/setclasspath.bat"
1465        tofile="${packages.home}/tomcat/bin/setclasspath.bat"
1466        overwrite="true"/>
1467      <copy file="${basedir}/resources/tomcat/setclasspath.sh"
1468        tofile="${packages.home}/tomcat/bin/setclasspath.sh"
1469        overwrite="true"/>
1470      -->
1471      <!-- make sure we have execute permission for the .sh files -->
1472      <chmod dir="${packages.home}/tomcat/bin" perm="ugo+rx"
1473        includes="*.sh"/>   
1474
1475      <echo file="${packages.home}/tomcat/.flagfile">
1476        the timestamp of this file is the time that tomcat was extracted from the zip files.
1477        it is used to figure out whether the files need to be refreshed or not in `ant prepare-tomcat`
1478      </echo>
1479
1480      <!-- this is not strictly a prepare tomcat thing, but if one changes
1481      Java, then they need to change tomcat as well, so might as well call
1482      it here -->
1483      <antcall target="configure-java-version"/>
1484      <else>
1485        <echo>Tomcat has been prepared, will not prepare</echo>
1486        <echo>Delete ${packages.home}/tomcat/.flagfile to force refresh</echo>
1487      </else>
1488
1489    </if>
1490
1491  </target> 
1492 
1493  <target name="configure-tomcat" depends="init,configure-tomcat-local,configure-tomcat-external"/>
1494 
1495  <target name="configure-tomcat-local" depends="init,perl-for-building" if="tomcat.islocal">
1496    <!-- re-setup the server.xml file -->
1497    <copy file="${basedir}/resources/tomcat/server_tomcat${tomcat.version.major}.xml"
1498        tofile="${packages.home}/tomcat/conf/server.xml" overwrite="true">
1499      <filterset>
1500        <filter token="port" value="${tomcat.port}"/>
1501        <filter token="shutdown-port" value="${tomcat.shutdown.port}"/>
1502      </filterset>
1503    </copy>
1504
1505    <!-- set up the solr context -->
1506
1507    <!-- First work out the IPv4 address for this machine -->
1508    <exec executable="${basedir}/bin/script/IPv4.sh" os="${os.unix}" failonerror="false" outputproperty="ipv4.val">
1509      <arg value="-format-for-tomcat-context"/>
1510    </exec>
1511    <exec executable="${basedir}/bin/script/IPv4.bat" osfamily="windows" failonerror="false" outputproperty="ipv4.val">
1512      <arg value="-format-for-tomcat-context"/>
1513    </exec>
1514
1515    <copy file="${basedir}/ext/solr/solr-tomcat-context.xml.in" tofile="${packages.home}/tomcat/conf/Catalina/localhost/solr.xml" overwrite="true">
1516      <filterset>
1517        <filter token="gsdl3webhome" value="${web.writablehome}"/>
1518    <filter token="tomcathome" value="${basedir}/packages/tomcat"/>
1519    <filter token="IPv4" value="${ipv4.val}"/>
1520      </filterset>
1521    </copy>
1522
1523    <!-- set up the greenstone3 context, it may have a custom name specified in build.properties -->
1524    <if><bool><not><equals arg1="greenstone3" arg2="${greenstone.context}"></equals></not></bool>
1525        <copy file="${basedir}/resources/tomcat/greenstone3.xml" tofile="${basedir}/resources/tomcat/${greenstone.context}.xml" overwrite="true"/>
1526    </if>
1527    <copy file="${basedir}/resources/tomcat/${greenstone.context}.xml" tofile="${packages.home}/tomcat/conf/Catalina/localhost/${greenstone.context}.xml" overwrite="true">
1528      <filterset>
1529        <filter token="gsdl3webhome" value="${web.home}"/>
1530        <filter token="gsdl3webwritablehome" value="${web.writablehome}"/>
1531    <filter token="privilegedattribute" value="${privileged.attribute}"/>
1532    <filter token="allowedIPs" value="${allowed.IPs}"/>
1533    <filter token="derbyserver" value="${derby.server}"/>
1534    <filter token="derbyserverport" value="${derby.server.port}"/>
1535      </filterset>
1536    </copy>
1537    <if>
1538        <bool>
1539            <and>
1540                <available file="${packages.home}/tomcat/conf/Catalina/localhost/greenstone3.xml"/>
1541                <not><equals arg1="greenstone3" arg2="${greenstone.context}"></equals></not>
1542            </and>
1543        </bool>
1544        <delete file="${packages.home}/tomcat/conf/Catalina/localhost/greenstone3.xml"/>
1545    </if>
1546   
1547    <!-- set up the greenstone3 web.xml file -->
1548    <copy file="${basedir}/resources/tomcat/web.xml" tofile="${packages.home}/tomcat/conf/web.xml" overwrite="true">
1549      <filterset>
1550    <filter token="perlpath" value="${perl.path}"/>
1551      </filterset>
1552    </copy>
1553  </target>
1554 
1555  <target name="configure-tomcat-external" depends="init" unless="tomcat.islocal">
1556    <!-- re-setup the server.xml file -->
1557    <!-- need to edit the config file, or do we get the user to do this???-->
1558  </target>
1559
1560  <target name="configure-solr-ext" depends="init" >
1561    <!-- re-setup the web/ext/solr/solr.xml file -->
1562    <copy file="${web.home}/ext/solr/solr.xml.in"
1563      tofile="${gsdl3.writablehome}/ext/solr/solr.xml" filtering="true" overwrite="true">
1564      <filterset>
1565        <filter token="gsdl3.home" value="${src.gsdl3.home.unix}"/>
1566        <filter token="gsdl3.writablehome" value="${src.gsdl3.writablehome.unix}"/>
1567      </filterset>
1568    </copy>
1569  </target>
1570 
1571  <!-- This target runs tomcat's "bin/catalina.bat(.sh) jpda start"
1572       to allow debugging the running GS3 server in Eclipse. See the instructions at
1573       http://www.wikijava.org/wiki/Debugging_a_servlet_with_tomcat_and_Eclipse_tutorial
1574       on how to use this with eclipse
1575    -->
1576  <target name="debug-start-tomcat" description="Startup Tomcat for debugger" depends="init" if="tomcat.islocal">
1577    <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
1578    <property name="tomcat.path" refid="local.tomcat.path"/>
1579
1580    <if><bool>
1581    <isset property="fedora.maxpermsize"/></bool>
1582      <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx800M ${readonly.catalina.opts} ${fedora.maxpermsize}"/>
1583      <else>
1584    <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx800M ${readonly.catalina.opts}"/>
1585      </else>
1586    </if>
1587
1588    <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
1589    <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
1590   
1591    <exec executable="${catalina.home}/bin/catalina.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
1592      <arg value="jpda" />
1593      <arg value="start" />
1594      <env key="JPDA_ADDRESS" value="8000"/> <!-- for debugging Tomcat in Eclipse -->
1595      <env key="JPDA_TRANSPORT" value="dt_socket"/> <!-- for debugging Tomcat in Eclipse -->
1596      <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
1597      <env key="PATH" path="${tomcat.path}"/>
1598      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1599      <env key="CATALINA_HOME" value="${catalina.home}"/>
1600      <env key="CLASSPATH" path="${tomcat.classpath}"/>
1601      <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
1602      <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
1603      <env key="WNHOME" path="${wn.home}"/>
1604      <env key="FEDORA_HOME" path="${fedora.home}"/>
1605    </exec>
1606    <exec executable="${catalina.home}/bin/catalina.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="true">
1607      <arg value="jpda" />
1608      <arg value="start" />
1609      <env key="JPDA_ADDRESS" value="8000"/> <!-- for debugging Tomcat in Eclipse -->
1610      <env key="JPDA_TRANSPORT" value="dt_socket"/> <!-- for debugging Tomcat in Eclipse -->
1611      <env key="GSDLOS" value="windows"/>
1612      <env key="GSDL3HOME" value="${basedir}"/>
1613      <env key="Path" path="${tomcat.path}"/>
1614      <env key="PATH" path="${tomcat.path}"/>
1615      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1616      <env key="CATALINA_HOME" value="${catalina.home}"/>
1617      <env key="CLASSPATH" path="${tomcat.classpath}"/>
1618      <env key="FEDORA_HOME" path="${fedora.home}"/>
1619    </exec>
1620    <!-- wait for the server to startup in case other targets need it running -->
1621    <waitfor maxwait="5" maxwaitunit="second">
1622      <and>
1623        <socket server="${tomcat.server}" port="${tomcat.port}"/>
1624        <http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/index.html"/>
1625      </and>
1626    </waitfor>
1627  </target> 
1628 
1629  <target name="start-tomcat" description="Startup only Tomcat" depends="check-tomcat-started">
1630
1631    <if><bool><istrue value="${tomcat.isstarted}"/></bool>
1632      <echo>**************************************</echo>
1633      <echo>A WEB SERVER IS ALREADY RUNNING ON ${server.protocol}://${tomcat.server}:${tomcat.port}. NOT STARTING.</echo>
1634      <echo>**************************************</echo>
1635      <else>
1636    <antcall target="force-start-tomcat"/>
1637      </else>
1638      </if>
1639  </target>
1640
1641  <!-- Another way: http://ptrthomas.wordpress.com/2006/03/25/how-to-start-and-stop-tomcat-from-ant/ -->
1642  <target name="force-start-tomcat" description="Startup only Tomcat" depends="init" if="tomcat.islocal">
1643
1644    <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
1645    <property name="tomcat.path" refid="local.tomcat.path"/>
1646
1647    <if><bool>
1648    <isset property="fedora.maxpermsize"/></bool>
1649      <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx800M ${readonly.catalina.opts} ${fedora.maxpermsize}"/>
1650      <else>
1651    <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx800M ${readonly.catalina.opts}"/>
1652      </else>
1653    </if>
1654
1655    <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
1656    <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
1657
1658    <!-- using osfamily instead of testing os against os.windows list of recognised windows versions
1659     so that future windows versions are included. See http://simonharrer.wordpress.com/tag/osfamily/
1660    Can't use the osfamily test for linux-type machines as a group since osfamily=unix is separate from osfamily=mac,
1661    see http://ant-contrib.sourceforge.net/tasks/tasks/osfamily.html -->
1662
1663    <exec executable="${catalina.home}/bin/startup.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
1664      <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
1665      <env key="GSDL3HOME" value="${basedir}"/>
1666      <env key="PATH" path="${tomcat.path}"/>
1667      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1668      <env key="CATALINA_HOME" value="${catalina.home}"/>
1669      <env key="CLASSPATH" path="${tomcat.classpath}"/>
1670      <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
1671      <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
1672      <env key="WNHOME" path="${wn.home}"/>
1673      <env key="FEDORA_HOME" path="${fedora.home}"/>
1674    </exec>
1675    <exec executable="${catalina.home}/bin/startup.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="true">
1676      <env key="GSDLOS" value="windows"/>
1677      <env key="GSDL3HOME" value="${basedir}"/>
1678      <env key="Path" path="${tomcat.path}"/>
1679      <env key="PATH" path="${tomcat.path}"/>
1680      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1681      <env key="CATALINA_HOME" value="${catalina.home}"/>
1682      <env key="CLASSPATH" path="${tomcat.classpath}"/>
1683      <env key="FEDORA_HOME" path="${fedora.home}"/>
1684    </exec>
1685    <!-- wait for the server to startup in case other targets need it running -->
1686    <waitfor maxwait="5" maxwaitunit="second">
1687      <and>
1688        <socket server="${tomcat.server}" port="${tomcat.port}"/>
1689        <http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/index.html"/>
1690      </and>
1691    </waitfor>
1692
1693  </target>
1694
1695  <!--ant task http: http://www.jajakarta.org/ant/ant-1.6.1/docs/ja/manual/api/org/apache/tools/ant/taskdefs/condition/Http.html-->
1696  <target name="reconfigure" description="Reconfigure the message router">
1697    <waitfor maxwait="5" maxwaitunit="second">
1698      <http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c"/>
1699    </waitfor>
1700  </target>
1701
1702  <!--Command-line args to Ant: http://www.jguru.com/faq/view.jsp?EID=471794-->
1703  <target name="reconfigure-collection" description="Reconfigure the collection">
1704    <waitfor maxwait="5" maxwaitunit="second">
1705      <http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c&amp;sc=${collection}"/>
1706    </waitfor>
1707  </target>
1708
1709  <!-- windows: do we want to launch a webrowser?? -->
1710  <!-- shouldn't this test whether anything is running first?
1711       It's safer to always attempt to stop tomcat: that way we won't be dependent on the right time
1712       to check whether the server is stopped or still running before attempting to start again.
1713       This target, which was recently called force-stop-tomcat for a while but is back to being
1714       called stop-tomcat, now hides the Java exception output that appears whenever tomcat is already
1715       stopped as happens when stop-tomcat is called consecutively. -->
1716  <target name="force-stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal">
1717    <exec executable="${catalina.home}/bin/shutdown.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
1718      <env key="FEDORA_HOME" path="${fedora.home}"/>
1719      <env key="CATALINA_HOME" value="${catalina.home}"/>
1720      <arg line=">/dev/null 2>&amp;1"/>
1721    </exec>
1722    <exec executable="${catalina.home}/bin/shutdown.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="false">
1723      <env key="FEDORA_HOME" path="${fedora.home}"/>
1724      <env key="CATALINA_HOME" value="${catalina.home}"/>
1725      <arg line=">nul 2>&amp;1"/>
1726    </exec>   
1727  </target>
1728
1729  <!-- Can also try the "socket" condition in place of the "http" condition
1730       And also use a <waitfor> in place of <condition>, such as:
1731       <waitfor maxwait="5" maxwaitunit="second" timeoutproperty="tomcat.isstopped"><http url="..."/></waitfor>
1732       The http URL resolves to host:port/greenstone3
1733       Condition uses <http/> rather than <socket/> for testing, since if the server was stopped, the socket
1734       might still be in use for some moments. We test the URL with the http condition since it's likelier to
1735       fail sooner if the server has indeed been stopped. -->
1736  <target name="check-tomcat-running">
1737    <condition property="tomcat.isrunning">
1738      <!--<http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}"/>-->
1739      <http url="${server.protocol}://${tomcat.server}:${tomcat.port}"/>
1740    </condition>
1741  </target>
1742 
1743  <!--
1744      <target name="verbose-check-tomcat-running">
1745      <condition property="tomcat.isrunning" value="true" else="false">
1746      <http url="${server.protocol}://${tomcat.server}:${tomcat.port}"/>
1747      </condition>
1748      <echo>Tomcat is running: ${tomcat.isrunning}</echo>
1749      </target>
1750  -->
1751  <target name="verbose-check-tomcat-running" depends="check-tomcat-running">   
1752    <if>
1753      <bool>
1754    <istrue value="${tomcat.isrunning}"/>
1755      </bool>     
1756      <echo>Tomcat is running: ${tomcat.isrunning}</echo>
1757      <else><echo>Tomcat is running: false</echo></else><!-- tomcat.isrunning not set -->
1758    </if>
1759  </target> 
1760 
1761  <!-- Need a copy of the check-tomcat-running target with a distinct property, because ant restart runs
1762       both stop and start, both of which need to do tomcat checks. Each property can be set only once during
1763       an invocation with ant. So ant restart will need two properties to store each of the tomcat checks -->
1764  <target name="check-tomcat-started">
1765    <condition property="tomcat.isstarted">
1766      <http url="${server.protocol}://${tomcat.server}:${tomcat.port}"/>
1767    </condition>
1768  </target>
1769
1770
1771
1772  <!-- stop-tomcat checks if the tomcat server is already running. If it appears to be running
1773       (regardless of whether tomcat was just starting to shut down), this target calls force-stop-tomcat
1774       to issue the shutdown command to tomcat. Then it waits for at most 15 seconds for the server to
1775       actually stop by checking the socket at which tomcat listens every second, printing a warning
1776       at the end of the max wait time of 15 seconds if tomcat was still running. -->
1777  <target name="stop-tomcat" description="Shutdown only Tomcat if running" depends="check-tomcat-running" if="tomcat.isrunning">
1778     <antcall target="force-stop-tomcat"/>
1779
1780     <property name="wait.numchecks" value="15"/>
1781     <echo>Waiting for the server to shutdown... (${wait.numchecks} seconds max)</echo>
1782     <waitfor maxwait="${wait.numchecks}" maxwaitunit="second" checkevery="1" checkeveryunit="second" timeoutproperty="tomcat.timedout">
1783       <not><socket server="${tomcat.server}" port="${tomcat.port}"/></not>
1784     </waitfor>
1785     
1786     <if>
1787       <bool>
1788     <isset property="${tomcat.timedout}"/>
1789       </bool>
1790       <property name="tomcat.isrunning" value="true"/>
1791       <echo>WARNING: Checked the socket ${wait.numchecks} times, but port ${tomcat.port} is still busy.</echo>
1792       <else>
1793     <echo>Tomcat is stopped.</echo>
1794     <property name="tomcat.isrunning" value="false"/>
1795       </else>
1796     </if>
1797  </target>
1798
1799  <target name="restart-tomcat" description="Shutdown and restart only Tomcat" depends="init,stop-tomcat,force-start-tomcat"/>
1800
1801  <target name="setup-catalina-ant-tasks">
1802    <!-- Configure the custom Ant tasks for the Tomcat Manager application -->
1803    <taskdef name="deploy"    classname="org.apache.catalina.ant.DeployTask"
1804      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1805    <taskdef name="list"      classname="org.apache.catalina.ant.ListTask"
1806      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1807    <taskdef name="reload"    classname="org.apache.catalina.ant.ReloadTask"
1808      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1809    <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"
1810      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1811    <taskdef name="roles"     classname="org.apache.catalina.ant.RolesTask"
1812      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1813    <taskdef name="start"     classname="org.apache.catalina.ant.StartTask"
1814      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1815    <taskdef name="stop"      classname="org.apache.catalina.ant.StopTask"
1816      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1817    <taskdef name="undeploy"  classname="org.apache.catalina.ant.UndeployTask"
1818      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1819  </target>
1820
1821  <!-- http://blog.andrewbeacock.com/2007/11/how-to-truncate-log-file-using-ubuntu.html
1822    Doing "cat </dev/null > packages/tomcat/logs/catalina.out" doesn't work as an ant target.
1823    It seems to have a problem with cat or </dev/null, with or without the < sign. -->
1824  <target name="reset-logs" description="Empties catalina.out, greenstone.log and contents of web/logs/tmp">
1825    <echo>Truncating catalina.out, solr.log, greenstone.log and server.log, and emptying ${web.writablehome}/logs/tmp</echo>   
1826    <exec executable="rm" os="${os.unix}" dir="${catalina.home}/logs" spawn="false">
1827      <arg value="-f"/>
1828      <arg value="catalina.out"/>
1829    </exec>
1830    <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
1831      <arg value="-f"/>
1832      <arg value="greenstone.log"/>
1833    </exec>
1834    <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
1835      <arg value="-f"/>
1836      <arg value="server.log"/>
1837    </exec>
1838
1839    <exec executable="touch" os="${os.unix}" dir="${catalina.home}/logs"
1840    spawn="false">
1841      <arg value="catalina.out"/>
1842    </exec>
1843    <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
1844      spawn="false">
1845      <arg value="greenstone.log"/>
1846    </exec>
1847    <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
1848      spawn="false">
1849      <arg value="server.log"/>
1850    </exec>
1851
1852    <exec executable="cmd" osfamily="windows" dir="${catalina.home}/logs" spawn="false">
1853      <arg line="/c echo. > catalina.out"/>
1854    </exec>
1855    <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
1856      <arg line="/c echo. > greenstone.log"/>
1857    </exec>
1858    <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
1859      <arg line="/c echo. > server.log"/>
1860    </exec>
1861
1862    <!-- if ext/solr/logs/solr.log exists, truncate it -->
1863    <if><bool><available file="${solr-ext.home}/logs/solr.log" type="file"/></bool>     
1864        <exec executable="rm" os="${os.unix}" dir="${solr-ext.home}/logs" spawn="false">
1865          <arg value="-f"/>
1866          <arg value="solr.log"/>
1867        </exec>
1868        <exec executable="touch" os="${os.unix}" dir="${solr-ext.home}/logs" spawn="false">
1869          <arg value="solr.log"/>
1870        </exec>   
1871        <exec executable="cmd" osfamily="windows" dir="${solr-ext.home}/logs" spawn="false">
1872          <arg line="/c echo. > solr.log"/>
1873        </exec>
1874    </if>
1875   
1876    <if>
1877      <bool><available file="${web.writablehome}/logs/tmp" type="dir"/></bool>
1878      <delete>
1879    <fileset dir="${web.writablehome}/logs/tmp" includes="**/*"/>
1880      </delete>
1881    </if>
1882  </target>
1883
1884  <target name="clear-tomcat-sessions" description="Clear the Tomcat Session info." depends="init">
1885    <exec executable="cmd" osfamily="windows" dir="${catalina.home}/work/Catalina/localhost/greenstone3" spawn="false">
1886      <arg line="/c echo. > SESSIONS.ser"/>
1887    </exec>
1888    <exec executable="rm" os="${os.unix}" dir="${catalina.home}/work/Catalina/localhost/greenstone3" spawn="false">
1889      <arg value="-f"/>
1890      <arg value="SESSIONS.ser"/>
1891    </exec>
1892
1893  </target>
1894  <!-- ======================= ant Targets ============================ -->
1895  <target name="prepare-ant" depends="init">
1896    <if>
1897      <bool>
1898        <not><available file="${packages.home}/ant/.flagfile"/></not>
1899      </bool>
1900
1901      <get src="http://www.greenstone.org/gs3files/apache-ant-1.7.0-bin.zip"
1902        dest="${packages.home}/apache-ant-1.7.0-bin.zip"
1903        usetimestamp="true"/>
1904      <unzip src="${packages.home}/apache-ant-1.7.0-bin.zip"
1905        dest="${packages.home}"/>
1906      <move todir="${packages.home}/ant">
1907        <fileset dir="${packages.home}/apache-ant-1.7.0"/>
1908      </move>
1909      <echo file="${packages.home}/ant/.flagfile">
1910        the timestamp of this file is the time that ant was extracted from the zip files.
1911        it is used to figure out whether the files need to be refreshed or not in `ant prepare-ant`
1912      </echo>
1913
1914      <else>
1915        <echo>Ant has been prepared, will not prepare</echo>
1916        <echo>Delete ${packages.home}/ant/.flagfile to force refresh</echo>
1917      </else>
1918
1919    </if>
1920  </target>
1921
1922  <!-- ======================= Admin Targets ============================ --> 
1923
1924  <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
1925    See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
1926    But you can do: echo mypassword | ant config-admin -->
1927  <target name="config-admin" description="Reset admin password">
1928    <input addproperty="admin.password" defaultvalue="admin" message="New admin password (3-20 characters):&gt;">
1929      <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
1930    </input>
1931    <!--<echo>PWD: ${admin.password}</echo>-->
1932    <antcall target="update-userdb">
1933      <param name="user.username" value="admin"/>
1934      <param name="user.password" value="${admin.password}"/>
1935      <param name="user.groups" value=""/>
1936      <param name="user.status" value=""/>
1937      <param name="user.comment" value="Password updated."/>
1938      <param name="user.email" value=""/>
1939    </antcall>
1940  </target>
1941
1942  <target name="config-user" description="Add or modify users" depends="get-user-data,update-userdb"/>
1943
1944  <target name="get-user-data" description="Get user details">
1945    <input addproperty="user.username" message="Username:&gt;"/>
1946    <input addproperty="user.password" defaultvalue="" message="Password (3-20 characters):&gt;">
1947      <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
1948    </input>
1949    <input addproperty="user.groups" defaultvalue="" message="Groups (comma-separated list, e.g. personal-collections-editor):&gt;"/>
1950    <input addproperty="user.status" defaultvalue="true" message="Enabled (true/false):&gt;"/>
1951    <input addproperty="user.comment" defaultvalue="" message="Comment:&gt;"/>
1952    <input addproperty="user.email" defaultvalue="" message="Email:&gt;"/>
1953  </target>
1954
1955  <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
1956       See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
1957       But you can do: echo mypassword | ant config-admin -->
1958  <target name="update-userdb" description="Add or modify users" depends="start-derby">
1959
1960    <!--
1961       We're now using derby networked server, so stopping and starting tomcat is not necessary.
1962       For embedded derby: stop tomcat if running, since derby db is embedded
1963       and only allows connections from one jvm instance at a time
1964     See http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html
1965     The ${tomcat.isrunning} property is set by the depends-target "check-tomcat-running" -->
1966   
1967    <!-- Need the derby networked server to be running in order to modify the usersDB.
1968     The start-derby task will check if derby is already running (if not, ${derby.isstarted} will
1969     be false) and will only start up networked derby if it is not already running.
1970     The ${derby.isstarted} property is set by the depends-target "start-derby", since it won't
1971     set the property if called with antcall (like launching in a subshell). Have to use 'depends'.
1972     We'll check ${derby.isstarted} at the end to stop derby again if we had to start it up now.-->
1973    <!--<antcall target="start-derby"/>-->
1974
1975    <!-- wait a max of 5 seconds for the derbyserver to have started up -->
1976    <waitfor maxwait="5" maxwaitunit="second">
1977      <socket server="${derby.server}" port="${derby.server.port}"/>
1978    </waitfor>
1979
1980    <!--<echo>${admin.password}</echo>--> <!-- for testing -->
1981    <echo>gsdl3.writablehome: ${gsdl3.writablehome}</echo> <!-- for testing -->
1982    <echo>web.home: ${web.home}</echo> <!-- for testing -->
1983    <java classname="org.greenstone.gsdl3.util.ModifyUsersDB">
1984      <classpath refid="compile.classpath"/> <!--for ${web.lib}/gsdl3.jar and supporting files-->
1985      <sysproperty key="gsdl3.writablehome" value="${gsdl3.writablehome}" /> <!-- passes -D<syspropKey=syspropVal> to java class ModifyUsersDB. Available in java code as System.getProperty("syspropKey") -->
1986      <arg file="${web.home}/etc/usersDB"/>
1987      <arg value="${user.username}"/>
1988      <arg value="password=${user.password}"/>
1989      <arg value="groups=${user.groups}"/>
1990      <arg value="status=${user.status}"/>
1991      <arg value="comment=${user.comment}"/>
1992      <arg value="email=${user.email}"/>
1993    </java>
1994
1995    <!-- Need to stop networked derby again if we ran it for this target with the depends=start-derby call.
1996     The test here is for <not>derby.isstarted</not>, as the property would be the same as before
1997     derby was started, since properties are immutable within a single ant command. -->
1998    <if>
1999      <bool>
2000    <not><istrue value="${derby.isstarted}"/></not>
2001      </bool>
2002      <antcall target="force-stop-derby"/>
2003    </if>
2004
2005  </target>
2006
2007
2008  <!-- ======================= Axis Targets ============================ --> 
2009 
2010  <target name="prepare-axis" depends="init">
2011
2012    <if>
2013      <bool>
2014        <not><available file="${packages.home}/axis/.flagfile"/></not>
2015      </bool>
2016
2017      <get src="http://www.greenstone.org/gs3files/${axis.zip.version}"
2018        dest="${packages.home}/${axis.zip.version}"
2019        usetimestamp="true"/>
2020      <unzip src="${packages.home}/${axis.zip.version}"
2021        dest="${packages.home}"/>
2022      <move todir="${packages.home}/axis">
2023        <fileset dir="${packages.home}/${axis.dir.version}"/>
2024      </move>
2025      <!-- install axis into greenstone web app -->
2026      <copy todir="${web.lib}">
2027        <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/lib">
2028          <include name="*.jar"/>
2029        </fileset>
2030      </copy>
2031      <copy todir="${web.home}">
2032        <fileset dir="${packages.home}/axis/webapps/axis/">
2033          <include name="*.jsp"/>
2034          <include name="*.jws"/>
2035        </fileset>
2036      </copy>
2037      <copy tofile="${web.home}/axis.html" file="${packages.home}/axis/webapps/axis/index.html"/>
2038      <copy todir="${web.classes}">
2039        <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/classes">
2040          <include name="*.properties"/>
2041        </fileset>
2042      </copy>
2043      <echo file="${packages.home}/axis/.flagfile">
2044        the timestamp of this file is the time that axis was extracted from the zip files.
2045        it is used to figure out whether the files need to be refreshed or not in `ant prepare-axis`
2046      </echo>
2047
2048      <else>
2049        <echo>Axis has been prepared, will not prepare</echo>
2050        <echo>Delete ${packages.home}/axis/.flagfile to force refresh</echo>
2051      </else>
2052
2053    </if>
2054  </target>
2055
2056  <target name="soap-deploy-site" depends="init,get-sitename,get-siteuri,get-webservices,create-deployment-files,deploy-site"
2057    description="Deploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work."/>
2058   
2059    <target name="deploy-site">
2060    <java classname="org.apache.axis.client.AdminClient">
2061      <classpath refid="compile.classpath"/>
2062      <arg value="-l"/>
2063      <arg value="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/servlet/AxisServlet"/>
2064      <arg file="${basedir}/resources/soap/deploy.wsdd"/>
2065    </java>
2066    <delete file="${basedir}/resources/soap/deploy.wsdd"/> <!--clean up, no longer used-->
2067  </target>
2068 
2069  <target name="soap-undeploy-site" depends="get-undeploy-service-name"
2070    description="Undeploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work.">
2071    <filter token="servicesname" value="${axis.undeploy.servicename}"/>
2072    <copy file="${basedir}/resources/soap/undeploy-site.wsdd.template"
2073      tofile="${basedir}/resources/soap/undeploy.wsdd"
2074      filtering="true"
2075      overwrite="true"/>
2076    <java classname="org.apache.axis.client.AdminClient">
2077      <classpath refid="compile.classpath"/>
2078      <arg value="-l"/>
2079      <arg value="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/servlet/AxisServlet"/>
2080      <arg file="${basedir}/resources/soap/undeploy.wsdd"/>
2081    </java>
2082    <delete file="${basedir}/resources/soap/undeploy.wsdd"/> <!--clean up, no longer used-->
2083  </target> 
2084
2085  <!-- this target used to deploy the default web service SOAPServer (base.webservice.name) on the localsite server
2086  with the default servicename of localsite-->
2087  <target name="deploy-localsite" depends="init"
2088    description="Deploy the SOAP server for localsite. Will start and stop Tomcat.">
2089    <antcall target="force-start-tomcat"/>
2090    <echo>Deploying ${base.webservice.name} web services for localsite under service name: localsite</echo>
2091    <antcall target="create-deployment-files">
2092      <param name="axis.sitename" value="localsite"/>
2093      <param name="axis.servicesname" value="${base.webservice.name}"/>
2094      <param name="axis.siteuri" value="localsite"/>
2095    </antcall>
2096    <antcall target="deploy-site">
2097      <param name="axis.sitename" value="localsite"/>
2098      <param name="axis.servicesname" value="${base.webservice.name}"/>
2099      <param name="axis.siteuri" value="localsite"/>
2100    </antcall>
2101    <echo>The Greenstone server has been started up. If you do not want it running, please type: ant stop.</echo>
2102  </target>
2103   
2104  <target name="get-sitename" unless="axis.sitename">
2105    <input addproperty="axis.sitename" defaultvalue="localsite">What site do you want to deploy services for?
2106Press Enter for default:localsite</input>
2107  </target>
2108
2109  <target name="get-undeploy-service-name" unless="axis.undeploy.servicename">
2110    <input addproperty="axis.undeploy.servicename" defaultvalue="localsite">Please enter the full name of the service you wish to undeploy.
2111To find out which web services you've got deployed, point your browser to ${server.protocol}://${tomcat.server}:${tomcat.port}/greenstone3/services
2112Or press Enter for undeploying the default:localsite /&gt;</input>
2113     <echo>Name of service to undeploy: ${axis.undeploy.servicename}</echo>
2114  </target>
2115
2116  <target name="get-webservices" unless="axis.servicesname">
2117    <input addproperty="axis.servicesname" defaultvalue="${base.webservice.name}">Which set of web services do you want to deploy?
2118Choose from: ${web.services.list}
2119Or press Enter for default:${base.webservice.name} /&gt;</input>
2120    <echo>${axis.servicesname}</echo>
2121  </target>
2122
2123  <target name="get-siteuri" depends="get-sitename,get-webservices" unless="axis.siteuri">
2124    <input addproperty="axis.siteuri" defaultvalue="${axis.servicesname}${axis.sitename}">What name do you want the service to have? (Press Enter for default:${axis.servicesname}${axis.sitename})</input>
2125    <echo>Site: ${axis.sitename}, services: ${axis.servicesname}, servicesname: ${axis.siteuri}</echo>
2126  </target>
2127
2128  <target name="set-soapmethod" description="Determines whether the service in the wsdd should have the style attribute set to message or the provider attribute set to java:RPC"  if="axis.servicesname">
2129   <condition property="soap.method" value="provider='java:MSG' style='message' use='literal'">
2130      <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
2131    </condition>
2132   
2133   <!--everything else defaults to java:RPC at present-->
2134   <condition property="soap.method" value="provider='java:RPC'">
2135     <not>
2136      <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
2137    </not>
2138    </condition>
2139  </target>
2140   
2141  <target name="create-deployment-files" depends="set-soapmethod" if="axis.sitename">
2142    <filter token="sitename" value="${axis.sitename}"/>
2143    <filter token="siteuri" value="${axis.siteuri}"/>
2144    <filter token="servicesname" value="${axis.servicesname}"/>
2145    <filter token="soapmethod" value="${soap.method}"/>
2146    <copy file="${basedir}/resources/soap/site.wsdd.template"
2147      tofile="${basedir}/resources/soap/deploy.wsdd"
2148      filtering="true"
2149      overwrite="true"/>
2150    <!-- create the java files and compile them -->
2151    <copy file="${basedir}/resources/java/${axis.servicesname}.java.in"
2152      tofile="${src.gsdl3.home}/${axis.servicesname}${axis.sitename}.java"
2153      filtering="true"
2154      overwrite="true"/>
2155    <mkdir dir="${build.home}"/>
2156    <javac srcdir="${src.home}"
2157      destdir="${build.home}"
2158      includeantruntime="${compile.includeantruntime}"
2159      debug="${compile.debug}"
2160      deprecation="${compile.deprecation}"
2161      optimize="${compile.optimize}"
2162      encoding="${compile.encoding}">
2163      <classpath refid="compile.classpath"/>
2164      <include name="org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.java" />
2165    </javac>
2166    <mkdir dir="${web.classes}/org/greenstone/gsdl3"/>
2167    <copy file="${build.home}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
2168      tofile="${web.classes}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
2169      overwrite="true" />
2170  </target>
2171 
2172
2173  <!-- ====================== Core targets ============================== -->
2174  <!-- core targets refer to the core gsdl3 java src -->
2175 
2176  <target name="prepare-core"/>
2177 
2178  <target name="configure-core"/>
2179
2180  <target name="update-core" depends="init,svnupdate-core,clean-core,compile-core"
2181    description="Update only the Greenstone core" />
2182 
2183  <target name="svnupdate-core" unless="nosvn.mode">
2184    <exec executable="svn">
2185      <arg value="update"/>
2186      <arg value="${basedir}"/>
2187      <arg value="-r"/><arg value="${branch.revision}"/>
2188    </exec>
2189  </target>
2190
2191  <target name="clean-core"
2192    description="Clean only the Greenstone core">
2193    <!-- should this delete the gsdl3.jar from web/WEB-INF?? -->
2194    <delete dir="${build.home}"/>
2195  </target>
2196
2197  <target name="compile-core" depends="init"
2198    description="Compile only the Greenstone core">
2199    <mkdir dir="${build.home}"/>
2200   
2201    <if><bool><isset property="with.jni"/></bool>
2202    <javac srcdir="${src.home}"
2203           destdir="${build.home}"
2204           includeantruntime="${compile.includeantruntime}"
2205           debug="${compile.debug}"
2206           deprecation="${compile.deprecation}"
2207           optimize="${compile.optimize}"
2208           encoding="${compile.encoding}">
2209      <classpath>
2210            <path refid="compile.classpath"/>
2211      </classpath>
2212    </javac>
2213    <else>
2214      <property name="gsprefix" value=""/>   
2215      <javac srcdir="${src.home}"
2216         destdir="${build.home}"
2217         includeantruntime="${compile.includeantruntime}"
2218         debug="${compile.debug}"
2219         deprecation="${compile.deprecation}"
2220         optimize="${compile.optimize}"
2221         encoding="${compile.encoding}">
2222        <classpath>
2223              <path refid="compile.classpath"/>
2224        </classpath>
2225        <exclude name="org/greenstone/gsdl3/service/GS2MGPPRetrieve.java"/>
2226        <exclude name="org/greenstone/gsdl3/service/GS2MGPPSearch.java"/>
2227        <exclude name="org/greenstone/gsdl3/service/GS2MGSearch.java"/>
2228        <exclude name="org/greenstone/gsdl3/service/GS2MGRetrieve.java"/>
2229        <exclude name="org/greenstone/gsdl3/service/GoogleNgramMGPPSearch.java"/>
2230        <exclude name="org/greenstone/gsdl3/service/PhindPhraseBrowse.java"/>
2231        <exclude name="org/greenstone/gsdl3/util/GDBMWrapper.java"/>
2232      </javac>
2233    </else>
2234    </if>
2235    <jar destfile="${build.home}/gsdl3.jar">
2236      <fileset dir="${build.home}">
2237        <include name="org/greenstone/gsdl3/**"/>
2238        <include name="org/flax/**"/>
2239        <exclude name="**/Test.class"/>
2240      </fileset>
2241      <manifest>
2242        <attribute name="Built-By" value="${user.name}" />
2243      </manifest>
2244    </jar>
2245    <copy file="${build.home}/gsdl3.jar" todir="${web.lib}"/>
2246
2247    <jar destfile="${build.home}/gutil.jar">
2248      <fileset dir="${build.home}">
2249        <include name="org/greenstone/util/**"/>
2250      </fileset>
2251      <manifest>
2252        <attribute name="Built-By" value="${user.name}" />
2253      </manifest>
2254    </jar>
2255    <copy file="${build.home}/gutil.jar" todir="${web.lib}"/>
2256
2257    <!-- copy the localsite server in case we need it -->
2258    <copy file="${build.home}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" tofile="${web.classes}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" />
2259
2260    <!-- Greenstone Administrator Interface -->
2261    <jar destfile="${build.home}/GAI.jar">
2262      <fileset dir="${build.home}">
2263        <include name="org/greenstone/admin/**"/>
2264      </fileset>
2265      <manifest>
2266        <attribute name="Built-By" value="${user.name}" />
2267      </manifest>
2268    </jar>
2269    <copy file="${build.home}/GAI.jar" todir="${web.lib}"/>
2270    <copy file="${build.home}/GAI.jar" todir="${admin.dir}"/>
2271    <jar destfile="${build.home}/phind.jar">
2272      <fileset dir="${build.home}">
2273        <include name="org/greenstone/applet/phind/**"/>
2274      </fileset>
2275      <manifest>
2276        <attribute name="Built-By" value="${user.name}" />
2277      </manifest>
2278    </jar>
2279    <mkdir dir="${web.applet}"/>
2280    <copy file="${build.home}/phind.jar" todir="${web.applet}"/>
2281    <!-- phind also needs xercesImpl.jar and xml-apis.jar to be in web/applet -->
2282    <if>
2283      <bool><istrue value="${tomcat.islocal}"/></bool>
2284      <if><bool><available file="${catalina.home}/lib/xercesImpl.jar"/></bool><!-- moved for solr -->
2285    <copy file="${catalina.home}/lib/xercesImpl.jar" todir="${web.applet}"/>
2286    <copy file="${catalina.home}/lib/xml-apis.jar" todir="${web.applet}"/>
2287   
2288    <else><!-- get from default GS3 web lib location-->
2289      <copy file="${web.lib}/xercesImpl.jar" todir="${web.applet}"/>
2290      <copy file="${web.lib}/xml-apis.jar" todir="${web.applet}"/>
2291    </else>
2292      </if>
2293    </if>
2294
2295
2296    <!-- skip anttasks for now
2297    <jar destfile="${build.home}/anttasks.jar">
2298      <fileset dir="${build.home}">
2299        <include name="org/greenstone/anttasks/**"/>
2300      </fileset>
2301      <manifest>
2302        <attribute name="Built-By" value="${user.name}" />
2303      </manifest>
2304    </jar>
2305    <copy file="${build.home}/anttasks.jar" todir="${basedir}/lib/java"/>-->
2306    <jar destfile="${build.home}/gsdl3test.jar">
2307      <fileset dir="${build.home}">
2308        <include name="org/greenstone/gsdl3/**/*Test.class"/>
2309        <include name="org/greenstone/testing/**"/>
2310      </fileset>
2311      <manifest>
2312        <attribute name="Built-By" value="${user.name}" />
2313      </manifest>
2314    </jar>
2315    <jar destfile="${build.home}/server.jar">
2316      <fileset dir="${build.home}">
2317        <include name="org/greenstone/server/**"/>
2318        <include name="org/greenstone/util/**"/>
2319      </fileset>
2320      <fileset file="${basedir}/resources/java/server.properties"/>
2321      <manifest>
2322        <attribute name="Built-By" value="${user.name}"/>
2323      </manifest>
2324    </jar>
2325    <copy file="${build.home}/server.jar" todir="${basedir}"/>
2326  </target>
2327
2328  <!-- === Eclipse targets == -->
2329  <target name="setup-for-eclipse">
2330
2331    <filter token="gsdlhome" value="${gs2build.home}"/>
2332    <filter token="gsdl3srchome" value="${basedir}"/>
2333    <filter token="gsdl3home" value="${basedir}/web"/>
2334
2335    <if>
2336      <bool><not><available file="${basedir}/TransformingLibrary.launch"/></not></bool>         
2337      <copy file="${basedir}/TransformingLibrary.launch.in" tofile="${basedir}/TransformingLibrary.launch" filtering="true" overwrite="true"/>
2338    </if>
2339<!--
2340    <if>
2341      <bool><not><available file="${basedir}/LibraryCommandline.launch"/></not></bool>         
2342      <copy file="${basedir}/LibraryCommandline.launch.in" tofile="${basedir}/LibraryCommandline.launch" filtering="true" overwrite="true"/>
2343    </if>
2344-->
2345  </target>
2346 
2347  <!-- ================== Packages targets ================================ -->
2348  <!-- these targets refer to the greenstone source packages - these need
2349  updating less often, so are in  separate targets to the core -->
2350  <target name="prepare-packages" depends="init"/>
2351 
2352  <target name="update-packages" depends="init,svnupdate-packages,configure-packages,clean-packages,compile-packages"
2353    description="Update only the source packages"/>
2354
2355  <target name="svnupdate-packages" unless="nosvn.mode">
2356    <exec executable="svn">
2357      <arg value="update"/>
2358      <arg value="${src.packages.home}"/>
2359      <arg value="-r"/><arg value="${branch.revision}"/>
2360    </exec>
2361  </target>
2362
2363 
2364  <target name="configure-packages" depends="init,configure-javagdbm"
2365    description="Configure only the packages."/>
2366 
2367  <target name="configure-javagdbm" if="with.jni">
2368    <echo>
2369      Configuring JavaGDBM
2370    </echo>
2371   
2372    <exec executable="${javagdbm.home}/configure" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
2373      <arg value="--prefix=${basedir}"/>
2374      <arg value="--libdir=${lib.jni}"/>
2375      <arg value="--with-gdbm=${gdbm.home}"/>
2376      <arg line="${cross.configure.args}"/>
2377    </exec>   
2378  </target>
2379
2380  <target name="clean-packages" depends="init,clean-javagdbm" description="Clean only the packages"/>
2381
2382  <target name="clean-javagdbm" depends="init">
2383    <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
2384    <exec executable="make" os="${os.unix}"
2385      dir="${javagdbm.home}" failonerror="true">
2386      <arg value="clean"/>
2387    </exec>
2388    </if>
2389  </target>
2390 
2391  <target name="distclean-packages" depends="init,distclean-javagdbm" description="Distclean only the packages"/>
2392
2393  <target name="distclean-javagdbm" depends="init">
2394    <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
2395    <exec executable="make" os="${os.unix}"
2396      dir="${javagdbm.home}" failonerror="true">
2397      <arg value="distclean"/>
2398    </exec>
2399    </if>
2400  </target>
2401 
2402  <target name="compile-packages" description="Compile only the source packages">
2403    <!-- javagdbm -->
2404    <antcall target="compile-javagdbm"/>
2405    <!-- Search4j -->
2406    <antcall target="compile-search4j"/>
2407  </target>
2408
2409  <target name="compile-javagdbm" description="Compile JavaGDBM" if="with.jni">
2410   
2411    <!-- unix: -->
2412    <echo>compile javagdbm</echo>
2413    <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
2414      <arg value="JAVACOPTIONS=-encoding UTF8"/>
2415    </exec>
2416    <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
2417      <arg value="install"/>
2418    </exec>
2419
2420    <!-- windows: Calling without the "compile" argument first will run winMake.bat with
2421         "all" which will then perform both the compile AND link targets in jni/win32.mak
2422         (thereby also generating gdbmjava.dll). Then we run the same command with
2423         the "install" argument to copy the gdbmjava.dll into the correct location. -->
2424    <echo>Windows: compile javagdbm</echo>
2425    <exec executable="${javagdbm.home}/winMake.bat" osfamily="windows" dir="${javagdbm.home}" failonerror="true">     
2426      <env key="GSDL3SRCHOME" path="${basedir}"/>
2427    </exec>
2428    <exec executable="${javagdbm.home}/winMake.bat" osfamily="windows" dir="${javagdbm.home}" failonerror="true">
2429      <env key="GSDL3SRCHOME" path="${basedir}"/>
2430      <arg value="install"/>
2431    </exec>
2432
2433    <!-- install the jar file -->
2434    <echo>Install the javagdbm jar file ${javagdbm.home}/javagdbm.jar ${lib.jni}</echo>
2435    <copy file="${javagdbm.home}/javagdbm.jar" todir="${lib.jni}"/>
2436  </target>
2437
2438  <target name="compile-search4j">
2439
2440    <!-- windows -->
2441    <if><bool><istrue value="${current.os.iswindows}"/></bool>
2442      <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
2443        <arg value="/f"/>
2444        <arg value="win32.mak"/>
2445        <arg value='BINDIR="${basedir}\bin"'/>
2446      </exec>
2447      <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
2448        <arg value="/f"/>
2449        <arg value="win32.mak"/>
2450        <arg value="install"/>
2451        <arg value='BINDIR="${basedir}\bin"'/>
2452      </exec>
2453
2454    <!-- unix -->
2455    <else><if><bool><istrue value="${current.os.isunix}"/></bool>
2456      <exec executable="${src.packages.home}/search4j/configure" dir="${src.packages.home}/search4j" failonerror="true">
2457        <arg value="--bindir=${basedir}/bin"/>
2458        <arg value="${static.arg}"/>
2459        <arg line="${cross.configure.args}"/>
2460      </exec>
2461      <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true"/>
2462      <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true">
2463        <arg value="install"/>
2464      </exec>
2465
2466    <!-- else warn -->
2467    <else>
2468      <fail>this target does not support the current os</fail>
2469
2470    </else></if></else></if>
2471
2472  </target>
2473
2474  <target name="install-auxiliary-jar-files" depends="init">
2475
2476    <if>
2477      <bool><available file="${mg.home}/mg.jar"/></bool>
2478      <copy file="${mg.home}/mg.jar" todir="${lib.jni}"/>
2479    </if>
2480
2481    <if>
2482      <bool><available file="${mgpp.home}/mgpp.jar"/></bool>
2483      <copy file="${mgpp.home}/mgpp.jar" todir="${lib.jni}"/>
2484    </if>
2485
2486    <copy file="${lucene.home}/LuceneWrapper4.jar" todir="${web.lib}"/>   
2487  </target>
2488 
2489  <target name="install-jni-files" depends="init" if="with.jni">
2490    <antcall target="install-jni-files-linux"/>
2491    <antcall target="install-jni-files-windows"/>
2492    <antcall target="install-jni-files-macos"/>
2493  </target>
2494
2495  <target name="install-jni-files-linux" depends="init" if="current.os.isunixnotmac">
2496
2497    <if>
2498
2499      <bool><equals arg1="${os.bin.dir}" arg2="windows"/></bool>
2500      <!-- cross compiling to windows -->
2501      <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
2502      <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
2503      <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
2504      <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
2505      <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
2506      <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
2507     
2508      <else>
2509    <!-- otherwise do the usual Unix copies -->
2510    <copy file="${mg.home}/jni/libmgretrievejni.so" todir="${lib.jni}"/>
2511    <copy file="${mg.home}/jni/libmgsearchjni.so" todir="${lib.jni}"/>
2512    <copy file="${mg.home}/jni/libmgpassjni.so" todir="${lib.jni}"/>
2513    <copy file="${mgpp.home}/jni/libmgppretrievejni.so" todir="${lib.jni}"/>
2514    <copy file="${mgpp.home}/jni/libmgppsearchjni.so" todir="${lib.jni}"/>
2515    <copy file="${mgpp.home}/jni/libmgpppassjni.so" todir="${lib.jni}"/>
2516      </else>
2517    </if>
2518
2519
2520  </target>
2521  <target name="install-jni-files-windows" depends="init" if="current.os.iswindows">
2522    <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
2523    <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
2524    <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
2525    <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
2526    <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
2527    <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
2528  </target>
2529  <target name="install-jni-files-macos" depends="init" if="current.os.ismac">
2530    <copy file="${mg.home}/jni/libmgretrievejni.jnilib" todir="${lib.jni}"/>
2531    <copy file="${mg.home}/jni/libmgsearchjni.jnilib" todir="${lib.jni}"/>
2532    <copy file="${mg.home}/jni/libmgpassjni.jnilib" todir="${lib.jni}"/>
2533    <copy file="${mgpp.home}/jni/libmgppretrievejni.jnilib" todir="${lib.jni}"/>
2534    <copy file="${mgpp.home}/jni/libmgppsearchjni.jnilib" todir="${lib.jni}"/>
2535    <copy file="${mgpp.home}/jni/libmgpppassjni.jnilib" todir="${lib.jni}"/>
2536  </target>
2537 
2538  <!-- ========common-src targets =================================-->
2539  <!-- these are used to get common-src (for indexers, gdbm, sqlite etc) when
2540  collection building is not enabled -->
2541
2542  <target name="update-common-src" depends="init" if="collection.building.disabled">
2543  </target>
2544
2545  <target name="svnupdate-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
2546    <exec executable="svn">
2547      <arg value="update"/>
2548      <arg value="${common.src.home}"/>
2549      <arg value="-r"/><arg value="${branch.revision}"/>
2550    </exec>
2551  </target>
2552
2553  <target name="prepare-common-src" depends="init" if="collection.building.disabled" unless="common.src.present">
2554    <antcall target="checkout-common-src"/>
2555    <antcall target="unzip-windows-packages"/>
2556  </target>
2557
2558  <target name="checkout-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
2559    <echo>checking out common-src</echo>
2560    <exec executable="svn">
2561      <arg value="checkout"/>
2562      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src"/>
2563            <arg value="common-src"/>
2564      <arg value="-r"/><arg value="${branch.revision}"/>
2565    </exec>
2566  </target>
2567   
2568  <target name="configure-common-src" depends="init">
2569<!--
2570    <echo>cross configure args: ${cross.configure.args}</echo>
2571-->
2572    <exec executable="${common.src.home}/configure" os="${os.unix}"
2573      dir="${common.src.home}" failonerror="true">
2574      <arg value="--prefix=${gs2build.home}"/> <!-- what value to use?? -->
2575      <arg value="--bindir=${gs2build.home}/bin/${os.bin.dir}"/> <!-- what value to use?? -->
2576      <arg line="${gs2.opt.args}"/>
2577      <arg line="${static.arg}"/>
2578      <arg line="${cross.configure.args}"/>
2579      <arg line="${allargs}"/>
2580    </exec>
2581  </target>
2582
2583  <target name="clean-common-src" depends="init">
2584    <!-- unix:  -->
2585    <if><bool><available file="${common.src.home}/Makefile"/></bool>
2586    <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2587      <arg value="clean"/>
2588    </exec>
2589    </if>
2590    <!-- windows: -->   
2591    <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
2592      <arg value="/f"/>
2593      <arg value="win32.mak"/>
2594      <arg value="clean"/>
2595      <arg value="GSDLHOME=${gs2build.home}"/>
2596    </exec>
2597  </target>
2598  <target name="distclean-common-src" depends="init">
2599    <!-- unix:  -->
2600    <if><bool><available file="${common.src.home}/Makefile"/></bool>
2601    <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2602      <arg value="distclean"/>
2603    </exec>
2604    </if>
2605    <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->   
2606    <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
2607      <arg value="/f"/>
2608      <arg value="win32.mak"/>
2609      <arg value="clean"/>
2610      <arg value="GSDLHOME=${gs2build.home}"/>
2611    </exec>
2612  </target>
2613  <target name="compile-common-src" depends="init">
2614    <!-- unix: -->
2615    <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2616      <arg value="${gs2.compile.target}"/>
2617    </exec>
2618    <!-- windows: -->
2619    <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
2620      <arg value="/f"/>
2621      <arg value="win32.mak"/>
2622      <arg value="GSDLHOME=${gs2build.home}"/>
2623      <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
2624      <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
2625      <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
2626      <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
2627      <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
2628    </exec>
2629  </target>
2630 
2631  <!-- ======= collection-building targets ===========================-->
2632
2633  <target name="update-collection-building" if="collection.building.enabled"
2634    depends="init,svnupdate-collection-building,gs2build-edit-setup-bat,configure-common-src,clean-common-src,compile-common-src,configure-collection-building,clean-collection-building,compile-collection-building"
2635    description="Update (SVN update, configure, compile etc) only the collection building components"/>
2636
2637  <target name="svnupdate-collection-building" if="collection.building.enabled" depends="init,svnupdate-gs2build,svnupdate-cgi,svnupdate-gli" unless="nosvn.mode"
2638    description="SVN update the collection building components">
2639  </target>
2640
2641  <target name="prepare-collection-building" depends="init,prepare-gs2build,svnupdate-cgi,prepare-gli" if="collection.building.enabled">
2642  </target>
2643
2644  <target name="configure-collection-building" depends="init,configure-build-src" if="collection.building.enabled"
2645    description="Configure the collection building components">
2646  </target>
2647
2648  <target name="clean-collection-building" depends="init,clean-gli,clean-build-src"
2649    description="Clean only the collection building components"
2650    if="collection.building.enabled"/>
2651
2652  <target name="distclean-collection-building" depends="init,clean-build-src,distclean-build-src"
2653    description="Distclean only the collection building components"
2654    if="collection.building.enabled"/>
2655
2656  <target name="compile-collection-building" depends="init,compile-build-src,compile-gli" if="collection.building.enabled"
2657    description="Compile only the collection building components">
2658    <!-- make install for common-src -->
2659    <!-- unix: -->
2660    <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2661      <arg value="${gs2.install.target}"/>
2662    </exec>
2663     
2664    <!-- windows: -->
2665    <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
2666      <arg value="/f"/>
2667      <arg value="win32.mak"/>
2668      <arg value="install"/>
2669      <arg value="GSDLHOME=${gs2build.home}"/>
2670      <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
2671      <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
2672      <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
2673      <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
2674      <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
2675      <!--
2676      <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
2677      <arg value="USE_SQLITE=0"/>--> <!-- why is this not on by default? -->
2678    </exec>
2679
2680    <!-- install gs2build indexers for windows -->
2681      <if>
2682    <bool><istrue value="${current.os.iswindows}"/></bool>
2683    <copy todir="${gs2build.home}/bin/windows">
2684      <fileset dir="${gs2build.home}/common-src/indexers/bin">
2685        <include name="*.*"/>
2686      </fileset>
2687    </copy>
2688      </if>
2689
2690    <!-- LuceneWrapper jar file not installed by default -->
2691    <mkdir dir="${gs2build.home}/bin/java"/>
2692    <copy file="${lucene.home}/LuceneWrapper4.jar" todir="${gs2build.home}/bin/java"/>
2693
2694  </target>
2695
2696  <!-- ============== gli targets ================================= -->
2697 
2698  <!-- gliserver.pl, gsdlCGI.pm, metadata-server.pl and checksum.pl are updated alongside
2699       this in target svnupdate-collection-building -->
2700  <target name="svnupdate-gli" if="collection.building.enabled" depends="init" unless="nosvn.mode">
2701
2702    <exec executable="svn">
2703      <arg value="update"/>
2704      <arg value="${gli.home}"/>
2705      <arg value="-r"/><arg value="${branch.revision}"/>
2706    </exec>
2707
2708  </target>
2709
2710  <!-- gliserver.pl, gsdlCGI.pm, metadata-server.pl and checksum.pl are updated
2711       alongside this prepare-gli target in target prepare-collection-building -->
2712  <target name="prepare-gli" depends="init" if="collection.building.enabled" unless="gli.present">
2713    <!-- checkout -->
2714    <if><bool><and><not><istrue value="${nosvn.mode}"/></not><isset property="with.gli.and.gems"/></and></bool>
2715
2716    <exec executable="svn">
2717      <arg value="checkout"/>
2718      <arg value="${svn.root}/main/${branch.path}/gli"/>
2719      <arg value="-r"/><arg value="${branch.revision}"/>
2720    </exec>
2721
2722    </if>
2723  </target>
2724
2725  <!-- svn checkout gliserver.pl, gsdlCGI.pm for gli applet, as well as gsdlCGI.pm-dependent metadata-server.pl
2726       (checksum.pl is used by GS2 for depositdspace.dm and may eventually be used by GS3 too) -->
2727  <target name="svnupdate-cgi">
2728
2729    <exec executable="svn" dir="web/WEB-INF/cgi">
2730      <arg value="export"/>
2731      <arg value="-r"/><arg value="${branch.revision}"/>
2732      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/gliserver.pl"/>
2733    </exec>
2734    <exec executable="svn" dir="web/WEB-INF/cgi">
2735      <arg value="export"/>
2736      <arg value="-r"/><arg value="${branch.revision}"/>
2737      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/gsdlCGI.pm"/>
2738    </exec>
2739    <exec executable="svn" dir="web/WEB-INF/cgi">
2740      <arg value="export"/>
2741      <arg value="-r"/><arg value="${branch.revision}"/>
2742      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/metadata-server.pl"/>
2743    </exec>
2744    <exec executable="svn" dir="web/WEB-INF/cgi">
2745      <arg value="export"/>
2746      <arg value="-r"/><arg value="${branch.revision}"/>
2747      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/checksum.pl"/>
2748    </exec>
2749  </target>
2750
2751 
2752  <target name="clean-gli" depends="init" if="collection.building.enabled">
2753    <!-- gli -->
2754    <property name="gli.home" value="${basedir}/gli"/>
2755    <!-- linux -->
2756    <exec executable="clean.sh" os="${os.unix}" dir="${gli.home}"
2757      resolveExecutable="true" failonerror="true"/>
2758    <!-- windows -->
2759    <exec executable="clean.bat" osfamily="windows" dir="${gli.home}"
2760      resolveExecutable="true" failonerror="true"/>
2761  </target>
2762 
2763  <target name="compile-gli" depends="init" if="collection.building.enabled">
2764    <if><bool><isset property="with.gli.and.gems"/></bool>
2765      <!-- gli -->
2766      <property name="gli.home" value="${basedir}/gli"/>
2767
2768      <!-- linux -->
2769      <exec executable="makegli.sh" os="${os.unix}" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
2770      <!--remote gli-->
2771      <exec executable="makejar.sh" os="${os.unix}" dir="${gli.home}"
2772        resolveExecutable="true" failonerror="true"/>
2773      <!-- windows -->
2774      <exec executable="makegli.bat" osfamily="windows" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
2775      <!--remote gli-->
2776      <exec executable="makejar.bat" osfamily="windows" dir="${gli.home}"
2777        resolveExecutable="true" failonerror="true"/>
2778      <copy file="${gli.home}/GLIServer.jar" todir="${gs2build.home}/bin/java" />
2779    </if>
2780  </target>
2781
2782  <target name="gli" description="Run the Greenstone Librarian Interface" depends="init" if="collection.building.enabled">
2783    <exec executable="${basedir}/gli/gli.sh" os="${os.linux},${os.solaris}" dir="${basedir}/gli" spawn="true">
2784      <env key="gsdl3path" path="${basedir}"/>
2785      <env key="gsdlpath" path="${gs2build.home}"/>
2786    </exec>
2787    <exec executable="${basedir}/gli/gli.sh" os="${os.mac}" dir="${basedir}/gli" spawn="true">
2788      <env key="gsdl3path" path="${basedir}"/>
2789      <env key="gsdlpath" path="${gs2build.home}"/>
2790      <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${gdbm.home}/lib"/>
2791    </exec>
2792    <exec executable="${basedir}/gli/gli.bat" osfamily="windows" dir="${basedir}/gli" spawn="true">
2793      <env key="GSDL3PATH" path="${basedir}"/>
2794      <env key="GSDLPATH" path="${gs2build.home}"/>
2795    </exec>
2796    <echo>Running GLI from Ant means that you don't get to see any of the terminal output. If you have problems with GLI and want to see the output, please run the script gli.sh/bat from the greenstone3/gli directory.
2797    </echo>
2798  </target>
2799
2800  <!-- ================ gs2build targets =========================== -->
2801
2802  <target name="svnupdate-gs2build" if="collection.building.enabled" depends="init" unless="nosvn.mode">
2803    <echo>svn updating gs2build</echo>
2804    <exec executable="svn">
2805      <arg value="update"/>
2806      <arg value="${gs2build.home}"/>
2807      <arg value="-r"/><arg value="${branch.revision}"/>
2808    </exec>
2809  </target>
2810   
2811  <target name="prepare-gs2build" depends="init" if="collection.building.enabled" unless="gs2build.present">
2812    <antcall target="checkout-gs2build"/>
2813    <antcall target="prepare-pdfbox"/>
2814    <antcall target="prepare-imagemagick"/> <!-- has to be done before calling prepare-gnome-lib -->
2815    <antcall target="prepare-gnome-lib"/>
2816    <antcall target="unzip-windows-packages"/>
2817    <antcall target="checkout-winbin"/>
2818    <antcall target="get-windows-binaries"/>
2819    <antcall target="delete-winbin"/>
2820  </target>
2821
2822  <target name="checkout-gs2build" depends="init" if="collection.building.enabled" unless="nosvn.mode">
2823    <echo>checking out gs2build</echo>
2824    <exec executable="svn">
2825      <arg value="checkout"/>
2826      <arg value="${svn.root}/main/${branch.path}/gs2build"/>
2827      <arg value="-r"/><arg value="${branch.revision}"/>
2828    </exec>
2829  </target>
2830
2831  <!-- Gets the PDFBox extension into gs2build/ext if checkout.pdfbox.ext is set to true in build.properties
2832       (which it is by default) -->
2833  <target name="prepare-pdfbox" depends="init" if="collection.building.enabled">
2834    <if>
2835      <bool>
2836    <istrue value="${checkout.pdfbox.ext}"/>
2837      </bool>
2838     
2839      <property name="pdfbox.ext.dir" value="${gs2build.home}/ext/pdf-box"/>
2840      <condition property="pdfbox.ext.present">
2841    <available file="${pdfbox.ext.dir}" type="dir" />
2842      </condition>
2843     
2844      <!-- get the pdfbox tar.gz file if we don't already have it and extract it if there's no pdf-box directory in gs2build/ext-->
2845      <if>
2846    <bool>
2847      <not><istrue value="${pdfbox.ext.present}"/></not>
2848    </bool>
2849
2850    <if>
2851      <bool>
2852        <not><istrue value="${gs2build.home}/ext/pdf-box-java.tar.gz"/></not>
2853      </bool>
2854
2855      <echo>Checking out the PDFBox extension into the GSDLHOME extension area</echo>
2856      <exec executable="svn">
2857        <arg value="export"/>
2858        <arg value="${svn.root}/gs2-extensions/pdf-box/trunk/pdf-box-java.tar.gz"/>
2859        <arg value="${gs2build.home}/ext/pdf-box-java.tar.gz"/>
2860      </exec>
2861    </if>   
2862
2863    <echo>Extacting the PDFBox extension into the GSDLHOME extension area</echo>
2864    <untar compression="gzip"
2865           src="${gs2build.home}/ext/pdf-box-java.tar.gz"
2866           dest="${gs2build.home}/ext"/>
2867
2868    <delete file="${gs2build.home}/ext/pdf-box-java.tar.gz"/>
2869
2870    <else>
2871      <echo>The PDFBox extension already exists at ${pdfbox.ext.dir}</echo>
2872    </else>
2873      </if>
2874
2875      <else>
2876    <echo>**** Not preparing the PDFBox extension:</echo>
2877    <echo>The property checkout.pdfbox.ext in build.properties was not set or was set to false</echo>
2878      </else>
2879    </if>
2880  </target>
2881
2882  <target name="prepare-imagemagick" depends="init" if="collection.building.enabled">
2883    <if>
2884      <bool>
2885    <istrue value="${checkout.imagemagick.ext}"/>
2886      </bool>
2887
2888      <antcall target="checkout-imagemagick"/>
2889      <!--Compilation of imagemagick now happens during ant install, still before configuring the src code, as before -->
2890
2891      <else>
2892    <echo>**** Not preparing imagemagick:</echo>
2893    <echo>property checkout.imagemagick.ext in build.properties was not set or was set to false</echo>
2894      </else>
2895    </if>
2896  </target>
2897
2898  <target name="checkout-imagemagick" depends="init" if="collection.building.enabled" unless="nosvn.mode">
2899   
2900    <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
2901    <condition property="imagemagick.src.present">
2902      <available file="${imagemagick.src.dir}" type="dir" />
2903    </condition>
2904
2905    <if>
2906      <bool>
2907    <not><istrue value="${imagemagick.src.present}"/></not>
2908      </bool>
2909     
2910      <echo>checking out imagemagick source into the extension area</echo>
2911
2912      <exec executable="svn">
2913    <arg value="checkout"/>
2914    <arg value="${svn.root}/gs2-extensions/imagemagick/trunk/src"/>
2915    <arg value="${imagemagick.src.dir}"/>
2916      </exec>
2917
2918      <else>
2919    <echo>imagemagick source code already exists at ${imagemagick.src.dir}</echo>
2920      </else>
2921    </if>
2922  </target>
2923
2924 <!-- Compile up imagemagick src folder if: the checkout.imagemagick.ext flag is turned on, if the imagick source code exists and if hasn't already been compiled up, then compile it up. Later can check if a gs-specific binary version has been installed already, in which case compilation won't be necessary. -->
2925  <target name="compile-imagemagick" if="checkout.imagemagick.ext">
2926   
2927    <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
2928    <property name="imagemagick.compiled.dir" value="${gs2build.home}/ext/imagemagick/${os.bin.dir}"/>
2929
2930    <condition property="imagemagick.src.present.firstcheck">
2931      <available file="${imagemagick.src.dir}" type="dir" />
2932    </condition>
2933    <condition property="imagemagick.compiled.present">
2934      <available file="${imagemagick.compiled.dir}" type="dir"/>
2935    </condition>
2936    <!--<condition property="imagemagick.bin.present">
2937      <available file="${basedir}/wherever/the/imgmagick/binary/is/to/be/found" type="dir" />
2938    </condition>-->
2939
2940    <!-- imagemagick will only be checked out if the user set the checkout.imagemagick.ext in build.properties -->
2941    <if>
2942      <bool>
2943    <isfalse value="${imagemagick.src.present.firstcheck}"/>
2944      </bool>
2945      <antcall target="checkout-imagemagick"/>
2946    </if>
2947
2948    <!-- keep track of whether the imagemagick src is now indeed present. Need to know this for a subsequent test -->
2949    <condition property="imagemagick.src.present">
2950      <available file="${imagemagick.src.dir}" type="dir" />
2951    </condition>
2952
2953    <if>
2954      <bool>
2955    <and>
2956      <istrue value="${imagemagick.src.present}"/> <!-- imagemagick src code is present -->
2957      <isfalse value="${imagemagick.compiled.present}"/> <!-- imagemagick src not compiled yet, so no imagemagick/os subfolder yet -->
2958    </and>
2959      </bool>
2960      <!-- then compile it. Only necessary for mac/linux, since windows has a stable working binary of imagemagick -->
2961      <exec executable="/bin/bash" dir="${imagemagick.src.dir}" failonerror="true">
2962        <arg value="CASCADE-MAKE.sh"/>
2963      </exec> 
2964    </if>
2965  </target>
2966
2967
2968  <!-- Compile up gnome-lib src folder if: checkout.gnomelib.ext is turned on, and if not using the binary
2969       version (gnome-lib-minimal), and if the gnome-lib src folder is not already compiled up. -->
2970  <target name="compile-gnome-lib" if="checkout.gnomelib.ext">
2971
2972    <!-- http://stackoverflow.com/questions/3290307/sourcing-a-shell-profile-in-an-ant-build-file
2973     TODO: CASCADE-MAKE already sources devel.bash, but we still want to source it more globally,
2974     so that the rest of the GS3 compilation process also has access to those env variables -->
2975   
2976    <property name="gnome.lib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
2977    <property name="gnome.lib.compiled.dir" value="${basedir}/gs2build/ext/gnome-lib/${os.bin.dir}"/>
2978
2979    <condition property="gnome.src.lib.present.firstcheck" value="true" else="false">
2980      <available file="${gnome.lib.src.dir}" type="dir" />
2981    </condition>
2982    <condition property="gnome.compiled.lib.present" value="true" else="false">
2983      <available file="${gnome.lib.compiled.dir}" type="dir"/>
2984    </condition>
2985    <condition property="gnome.lib.min.present" value="true" else="false">
2986      <available file="${basedir}/gs2build/ext/gnome-lib-minimal" type="dir" />
2987    </condition>
2988
2989    <!-- Make sure to checkout gnome-lib if it was not checked out at this stage
2990     since we're instructed to do so in th pre-condition to this target -->
2991    <if>
2992      <bool>
2993    <and>
2994      <isfalse value="${gnome.lib.min.present}"/>
2995      <isfalse value="${gnome.src.lib.present.firstcheck}"/>
2996    </and>
2997      </bool>
2998      <antcall target="checkout-gnome-lib"/>
2999    </if>
3000
3001    <!-- Keep track of whether we have the gnome-lib src folder now. Need to know this for a subsequent test -->
3002    <condition property="gnome.src.lib.present" value="true" else="false">
3003      <available file="${gnome.lib.src.dir}" type="dir" />
3004    </condition>
3005
3006    <!--<echo>MIN: ${gnome.lib.min.present}
3007      SRC LIB: ${gnome.src.lib.present}
3008      COMPILED: ${gnome.compiled.lib.present}</echo>-->
3009
3010    <if>
3011      <bool>
3012    <and>
3013      <isfalse value="${gnome.lib.min.present}"/> <!-- no gnome-lib-minimal binary present -->
3014      <istrue value="${gnome.src.lib.present}"/> <!-- gnome-lib folder for compilation is present-->
3015      <isfalse value="${gnome.compiled.lib.present}"/> <!-- gnome-lib not yet compiled, so no gnome-lib/os subfolder yet -->
3016    </and>
3017      </bool>
3018
3019      <!-- then compile it. Only necessary for mac/linux, since windows doesn't need gnome lib -->
3020      <exec executable="/bin/bash" dir="${gnome.lib.src.dir}" failonerror="true">
3021        <arg value="CASCADE-MAKE.sh"/>
3022      </exec> 
3023    </if>
3024  </target>
3025
3026
3027  <target name="prepare-gnome-lib" depends="init" if="collection.building.enabled" unless="gnome-lib.present">
3028    <if>
3029      <bool>
3030    <istrue value="${checkout.gnomelib.ext}"/>
3031      </bool>
3032
3033      <antcall target="checkout-gnome-lib"/>
3034      <!--Compilation of gnome-lib happens during ant install, just before configuring (common-src and) build-src-->
3035
3036      <else>
3037    <echo>**** Not preparing gnome-lib:</echo>
3038    <echo>property checkout.gnomelib.ext in build.properties was not set or was set to false</echo>
3039      </else>
3040    </if>
3041  </target>
3042
3043
3044  <target name="checkout-gnome-lib" depends="init" if="collection.building.enabled" unless="nosvn.mode">
3045
3046    <property name="gnomelib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
3047    <condition property="gnome.src.present">
3048      <available file="${gnomelib.src.dir}" type="dir" />
3049    </condition>
3050
3051    <if>
3052      <bool>
3053    <not><istrue value="${gnome.src.present}"/></not>
3054      </bool>
3055
3056      <echo>checking out gnome-lib extension</echo>
3057      <exec executable="svn">
3058    <arg value="checkout"/>
3059    <arg value="${svn.root}/gs2-extensions/gnome-lib/trunk/src"/>
3060    <arg value="${gs2build.home}/ext/gnome-lib"/>
3061      </exec>
3062
3063      <else>
3064    <echo>gnomelib source code already exists at ${gnomelib.src.dir}</echo>
3065      </else>
3066    </if>
3067
3068  </target>
3069
3070  <target name="checkout-winbin" depends="init" if="current.os.iswindows"
3071    unless="nosvn.mode">
3072
3073    <exec executable="svn">
3074      <arg value="checkout"/>
3075      <arg value="${svn.root}/main/${branch.path}/binaries/windows"/>
3076      <arg value="-r"/><arg value="${branch.revision}"/>
3077      <arg value="winbin"/>
3078    </exec>
3079
3080  </target>
3081
3082  <target name="update-winbin" depends="init" if="current.os.iswindows" unless="nosvn.mode">
3083    <exec executable="svn">
3084      <arg value="update"/>
3085      <arg value="winbin"/>
3086      <arg value="-r"/><arg value="${branch.revision}"/>
3087    </exec>
3088
3089  </target>
3090 
3091  <target name="get-windows-binaries" depends="init" if="collection.building.enabled.windows">
3092    <move todir="${gs2build.home}/bin/windows" failonerror="false">
3093      <fileset dir="${basedir}/winbin/bin"/>
3094    </move>
3095  </target>
3096
3097  <target name="delete-winbin" depends="init" if="collection.building.enabled.windows">
3098    <delete dir="${basedir}/winbin"/>
3099  </target>
3100 
3101  <target name="unzip-windows-packages" depends="init" if="current.os.iswindows"> 
3102    <unzip src="${common.src.home}/packages/windows/crypt/crypt.zip"
3103      dest="${common.src.home}/packages/windows/crypt"/>
3104    <untar compression="gzip"
3105      src="${common.src.home}/packages/sqlite/${sqlite.targz.version}"
3106      dest="${common.src.home}/packages/sqlite"/>
3107    <unzip src="${common.src.home}/indexers/packages/windows/iconv/iconv.zip"
3108      dest="${common.src.home}/indexers/packages/windows/iconv"/>
3109  </target>
3110   
3111  <target name="gs2build-edit-setup-bat" if="collection.building.enabled.windows">
3112    <!-- we want a windows path in the setup.bat file -->
3113    <pathconvert targetos="windows" property="gs2build.home.windows">
3114      <path path="${gs2build.home}"/>
3115    </pathconvert>
3116    <move file="${gs2build.home}/setup.bat" tofile="${gs2build.home}/setup-tmp.bat">
3117      <filterset>
3118        <filter token="gsdlhome" value="${gs2build.home.windows}"/>
3119      </filterset>
3120    </move> 
3121    <move file="${gs2build.home}/setup-tmp.bat" tofile="${gs2build.home}/setup.bat" />
3122  </target>
3123 
3124 
3125  <target name="clean-build-src" depends="init" if="collection.building.enabled">
3126    <!-- unix:  -->
3127    <if><bool><available file="${build.src.home}/Makefile"/></bool>
3128    <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
3129      <arg value="clean"/>
3130    </exec>
3131    </if>
3132    <!-- windows: -->   
3133    <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
3134      <arg value="/f"/>
3135      <arg value="win32.mak"/>
3136      <arg value="clean"/>
3137      <arg value="GSDLHOME=${gs2build.home}"/>
3138    </exec>
3139  </target>
3140 
3141 
3142  <target name="distclean-build-src" depends="init,clean-build-src" if="collection.building.enabled">
3143    <!-- unix:  -->
3144    <if><bool><available file="${build.src.home}/Makefile"/></bool>
3145    <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
3146      <arg value="distclean"/>
3147    </exec>
3148    </if>
3149    <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->   
3150    <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
3151      <arg value="/f"/>
3152      <arg value="win32.mak"/>
3153      <arg value="clean"/>
3154      <arg value="GSDLHOME=${gs2build.home}"/>
3155    </exec>
3156  </target>
3157 
3158  <target name="configure-build-src" depends="init" if="collection.building.enabled"
3159    description="Configure the build-src component">
3160    <exec executable="${build.src.home}/configure" os="${os.unix}"
3161      dir="${build.src.home}" failonerror="true">
3162      <arg value="--prefix=${gs2build.home}"/>
3163      <arg line="${gs2.opt.args} ${static.arg} ${cross.configure.args} ${allargs}"/>
3164    </exec>
3165  </target>
3166
3167  <!-- common-src is done separately and needs to be compiled first -->
3168  <target name="compile-build-src" depends="init" if="collection.building.enabled">
3169   
3170    <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
3171        <arg line="${ldlpath.arg}"/>
3172    </exec>
3173   
3174    <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
3175      <arg value="install"/>
3176    </exec>
3177
3178    <!-- run the setup script -->
3179    <!-- <exec executable="${compile.windows.c++.setup}" osfamily="windows" failonerror="true"/>-->
3180      <!--Above does not work: even though vcvars.bat executes, the env changes it makes don't get saved. Need user to run vcvars.bat first before calling ant-->
3181      <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
3182        <arg value="/f"/>
3183        <arg value="win32.mak"/>
3184    <arg value="GSDLHOME=${gs2build.home}"/>
3185      </exec>
3186      <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
3187        <arg value="/f"/>
3188        <arg value="win32.mak"/>
3189        <arg value="install"/>
3190    <arg value="GSDLHOME=${gs2build.home}"/>
3191      </exec>
3192  </target>
3193 
3194
3195  <!-- ======================== TESTING Targets ========================= -->
3196 
3197  <target name="test" description="Run the (incomplete) JUnit test suite "
3198    depends="init">
3199    <mkdir dir="${basedir}/test"/>
3200    <junit printsummary="withOutAndErr"
3201      errorproperty="test.failed"
3202      failureproperty="test.failed"
3203      fork="${junit.fork}">
3204      <formatter type="plain"/>
3205      <classpath>
3206        <pathelement location="${build.home}/gsdl3test.jar"/>
3207        <path refid="compile.classpath"/>
3208      </classpath>
3209      <test name="${testcase}" if="testcase"/>
3210      <batchtest todir="${basedir}/test" unless="testcase">
3211        <fileset dir="${build.home}" includes="**/*Test.class" />
3212      </batchtest>
3213    </junit>
3214    <echo>
3215      *********************************************
3216      Test output can be found in directory 'test'
3217      *********************************************
3218    </echo>
3219  </target>
3220
3221  <!-- ======================== FLAX Targets ========================= -->
3222  <target name="prepare-flax" description="check out flax source code from another repository" if="install.flax">
3223    <echo>checking out flax ...</echo>
3224    <mkdir dir="${basedir}/src/java/org/flax"/>
3225    <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/flax"/>
3226    <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/action/flax"/>
3227    <mkdir dir="${web.home}/WEB-INF/classes/flax"/>
3228    <mkdir dir="${web.home}/interfaces/flax"/>
3229    <mkdir dir="${web.home}/sites/flax"/>
3230    <mkdir dir="${basedir}/flax-resources"/>
3231    <mkdir dir="${basedir}/flax-lib"/>
3232    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/flax"/>
3233      <arg value="src/java/org/flax"/></exec>
3234    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/flax"/>
3235      <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
3236    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/action/flax"/>
3237      <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
3238     <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/WEB-INF/classes/flax"/>
3239      <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
3240    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/interfaces/flax"/>
3241      <arg value="${web.home}/interfaces/flax"/></exec>
3242    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/sites/flax"/>
3243      <arg value="${web.home}/sites/flax"/></exec>
3244    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/flax-resources"/>
3245      <arg value="flax-resources"/></exec>
3246    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/lib"/>
3247      <arg value="flax-lib"/></exec>
3248    <antcall target="flax-copy-del-files" />
3249  </target>
3250 
3251  <target name="flax-copy-del-files" description="copy some flax files into the appropriate greenstone3 directories and delete some unwanted greenstone stuff">
3252    <copy file="${web.home}/WEB-INF/classes/flax/web.xml" todir="${web.home}/WEB-INF" overwrite="true" />
3253    <copy todir="${web.home}/WEB-INF/lib">
3254            <fileset dir="${basedir}/flax-lib">
3255               <include name="*.jar"/>
3256            </fileset> 
3257    </copy>
3258    <!--<delete dir="${web.home}/sites/gateway"/>
3259    <delete dir="${web.home}/sites/localsite"/>-->
3260  </target>
3261
3262  <target name="update-flax" description="update flax from repository">
3263    <echo>updating flax ...</echo>
3264    <exec executable="svn"><arg value="update"/>
3265      <arg value="src/java/org/flax"/></exec>
3266    <exec executable="svn"><arg value="update"/>
3267      <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
3268    <exec executable="svn"><arg value="update"/>
3269      <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
3270    <exec executable="svn"><arg value="update"/>
3271      <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
3272    <exec executable="svn"><arg value="update"/>
3273      <arg value="${web.home}/interfaces/flax"/></exec>
3274    <exec executable="svn"><arg value="update"/>
3275      <arg value="${web.home}/web/sites/flax"/></exec>
3276    <exec executable="svn"><arg value="update"/>
3277      <arg value="flax-resources"/></exec>
3278    <exec executable="svn"><arg value="update"/>
3279      <arg value="flax-lib"/></exec>
3280    <antcall target="compile-core" />
3281  </target>
3282
3283  <!-- ========================End of FLAX Targets ========================= -->
3284
3285  <target name="compile-javadocs">
3286    <javadoc packagenames="org.greenstone.*"
3287           sourcepath="src/java"
3288           defaultexcludes="yes"
3289           destdir="docs/javadoc"
3290           author="true"
3291           version="true"
3292           use="true"
3293           windowtitle="Greenstone3 API">
3294    <doctitle><![CDATA[<h1>Greenstone3 API</h1>]]></doctitle>
3295    </javadoc>
3296  </target>
3297
3298<!-- ========== Some distribution targets ======================== -->
3299  <target name="remove-source">
3300    <if><bool><isset property="with.gli.and.gems"/></bool>
3301    <delete includeEmptyDirs="true">
3302      <fileset dir="." defaultexcludes="false">
3303        <patternset refid="greenstone3.source.component"/>
3304     </fileset>
3305    </delete>
3306   
3307    <else>
3308    <delete includeEmptyDirs="true">
3309      <fileset dir="." defaultexcludes="false">
3310        <patternset refid="greenstone3.source.no.gli.component"/>
3311     </fileset>
3312    </delete>
3313    </else>
3314    </if>
3315  </target>
3316
3317  <target name="dist-tidy"
3318    description="'tidies-up' a greenstone3 installation for distribution."
3319    unless="${properties.keep.src}">
3320
3321    <!-- delete unneeded things -->
3322    <delete dir="${packages.home}/axis"/>
3323    <delete><fileset dir="${packages.home}" includes="*.zip"/></delete>
3324    <delete file="README-SVN.txt"/>
3325    <delete file="build.properties.in"/>
3326
3327    <!-- delete source files -->
3328    <antcall target="remove-source"/>
3329
3330    <!-- create empty directories -->
3331    <mkdir dir="${web.writablehome}/applet"/>
3332    <mkdir dir="${web.writablehome}/logs"/>
3333    <mkdir dir="${web.writablehome}/logs/tmp"/>
3334
3335    <!-- Lines with ***** are commented out because these files are useful if we want hybrid installations -->
3336   
3337    <!-- os specific tidy-ups -->
3338    <!-- linux, mac -->
3339    <if><bool><istrue value="${current.os.isunix}"/></bool>
3340      <!--*****<delete><fileset dir="." includes="*.bat"/></delete>-->
3341      <if><bool><isset property="with.gli.and.gems"/></bool>
3342        <!--*****<delete><fileset dir="gli" includes="*.bat"/></delete>-->
3343      </if>
3344      <!--*****<delete><fileset dir="gs2build" includes="*.bat"/></delete>-->
3345      <!--*****<delete><fileset dir="bin/script" includes="*.bat"/></delete>-->
3346      <delete file="${basedir}/gs2build/win32cfg.h"/>
3347      <delete file="${basedir}/gs2build/win32.mak"/>
3348      <delete dir="${basedir}/winutil"/>
3349      <delete failonerror="false"><fileset dir="${lib.jni}" includes="*.dll"/></delete>
3350
3351    <!-- windows -->
3352    <else><if><bool><istrue value="${current.os.iswindows}"/></bool>
3353      <!--*****<delete><fileset dir="." includes="*.sh,*.bash,*.csh"/></delete>-->
3354      <if><bool><isset property="with.gli.and.gems"/></bool>
3355    <!--*****<delete><fileset dir="gli" includes="*.sh,*.bash,*.csh"/></delete>-->
3356      </if>
3357      <!--*****<delete><fileset dir="gs2build" includes="*.sh,*.bash,*.csh"/></delete>-->
3358      <!--*****<delete><fileset dir="bin/script" includes="*.sh,*.bash,*.csh"/></delete>-->
3359    </if></else></if>
3360
3361  </target>
3362
3363  <!-- fix up executable permissions for binary release -->
3364  <target name="fix-execute-permissions">
3365    <echo>Setting binaries to executable</echo>
3366    <chmod perm="775">
3367      <fileset dir="."><patternset refid="greenstone3.executables"/></fileset>
3368    </chmod>
3369  </target>
3370 
3371  <!-- fix up executable permissions for source code release -->
3372  <target name="fix-execute-permissions-source">
3373    <chmod perm="775">
3374      <fileset dir="."><patternset refid="greenstone3.source.executables"/></fileset>
3375    </chmod>
3376  </target>
3377
3378  <!-- for macs, set up the .app shortcuts to gsi, gli, client-gli and gems -->
3379  <target name="gen-mac-shortcuts">   
3380    <if><bool><istrue value="${current.os.ismac}"/></bool>
3381      <filter token="gsdl3srchome" value="${basedir}"/>
3382      <copy file="${basedir}/gs3-server.app/Contents/document.wflow.in" tofile="${basedir}/gs3-server.app/Contents/document.wflow" filtering="true" overwrite="true"/>
3383      <copy file="${basedir}/gli.app/Contents/document.wflow.in" tofile="${basedir}/gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
3384      <copy file="${basedir}/client-gli.app/Contents/document.wflow.in" tofile="${basedir}/client-gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
3385      <copy file="${basedir}/gems.app/Contents/document.wflow.in" tofile="${basedir}/gems.app/Contents/document.wflow" filtering="true" overwrite="true"/>
3386    </if>
3387  </target>
3388
3389  <!-- ============= tweaks for making compilation static ========== --> 
3390  <target name="tweak-makefiles" depends="init" if="compile.static">
3391    <antcall target="rtftohtml-add-static" />
3392  </target>
3393   
3394  <target name="rtftohtml-add-static" depends="init" if="collection.building.enabled">
3395    <rsr verbosity="1" file="${gs2build.home}/build-src/packages/rtftohtml/rtftohtml_src/Makefile" pattern="-o rtftohtml(.{2})EXEEXT(.{1})" replacement="-o rtftohtml$1EXEEXT$2 -static" />
3396  </target>
3397   
3398    <target name="run-collection-tests">
3399        <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
3400            <fail>The testing extension is not available. This is required to perform the tests. It can be acquired from SVN by running the command "svn co http://svn.greenstone.org/gs3-extensions/testing/trunk/src testing" in the ext directory of your Greenstone 3 installation. </fail>
3401        </if>
3402        <for param="testjar">
3403            <path>
3404                <fileset dir="${basedir}" includes="web/sites/*/collect/*/tests/tests.jar"/>
3405            </path>
3406            <sequential>
3407                <echo>Testing @{testjar}</echo>
3408                <java classname="org.junit.runner.JUnitCore" fork="true">
3409                    <arg value="gstests.TestClass"/>
3410                    <jvmarg value="-DSERVERURL=${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet} "/>
3411                    <classpath>
3412                        <fileset dir="${basedir}/ext/testing/lib/java">
3413                            <include name="*.jar"/>
3414                        </fileset>
3415                        <files includes="@{testjar}"/>
3416                    </classpath>
3417                </java>
3418            </sequential>
3419        </for>
3420    </target>
3421   
3422    <target name="build-collection-tests">
3423        <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
3424            <fail>The testing extension is not available. This is required to perform the tests. It can be acquired from SVN by running the command "svn co http://svn.greenstone.org/gs3-extensions/testing/trunk/src testing" in the ext directory of your Greenstone 3 installation. </fail>
3425        </if>
3426        <for param="compiledir">
3427            <path>
3428                <dirset dir="${basedir}" includes="web/sites/*/collect/*/tests/src"/>
3429            </path>
3430            <sequential>
3431                <echo>Compiling @{compiledir}</echo>
3432                <if><bool><not><available file="@{compiledir}/../build" type="dir"/></not></bool>
3433                    <mkdir dir="@{compiledir}/../build"/>
3434                </if>
3435                <javac
3436                    srcdir="@{compiledir}"
3437                    destdir="@{compiledir}/../build"
3438                        includeantruntime="${compile.includeantruntime}"
3439                    debug="${compile.debug}"
3440                    deprecation="${compile.deprecation}"
3441                    optimize="${compile.optimize}"
3442                    encoding="${compile.encoding}">
3443                    <classpath>
3444                        <fileset dir="${basedir}/ext/testing/lib/java">
3445                            <include name="*.jar"/>
3446                        </fileset>
3447                    </classpath>
3448                    <include name="gstests/*.java"/>
3449                </javac>
3450                <jar destfile="@{compiledir}/../tests.jar">
3451                    <fileset dir="@{compiledir}/../build">
3452                        <include name="gstests/**"/>
3453                    </fileset>
3454                    <manifest>
3455                        <attribute name="Built-By" value="${user.name}" />
3456                    </manifest>
3457                </jar>
3458            </sequential>
3459        </for>
3460    </target>
3461</project>
Note: See TracBrowser for help on using the browser.