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

Revision 32312, 148.4 KB (checked in by kjdon, 14 months ago)

fixed a spelling mistake

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.svn" 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-svn-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.in" 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.in" 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-svn-files" depends="init"
1087      description="Copies all resources .svn files to .in versions - which are used during configure to generate the runtime versions." >
1088    <if><bool><available file="${basedir}/resources/tomcat/greenstone3.xml.in"/></bool>
1089      <copy file="${basedir}/resources/tomcat/greenstone3.xml.in" tofile="${basedir}/resources/tomcat/greenstone3.xml.in.backup"  overwrite="true"/>
1090    </if>
1091   
1092    <copy file="${basedir}/resources/tomcat/greenstone3.xml.svn" tofile="${basedir}/resources/tomcat/greenstone3.xml.in"  overwrite="true"/>
1093    <if><bool><available file="${basedir}/resources/tomcat/server_tomcat5.xml.in"/></bool>
1094      <copy file="${basedir}/resources/tomcat/server_tomcat5.xml.in" tofile="${basedir}/resources/tomcat/server_tomcat5.xml.in.backup"  overwrite="true"/>
1095    </if>
1096    <copy file="${basedir}/resources/tomcat/server_tomcat5.xml.svn" tofile="${basedir}/resources/tomcat/server_tomcat5.xml.in"  overwrite="true"/>
1097    <if><bool><available file="${basedir}/resources/tomcat/server_tomcat7.xml.in"/></bool>
1098      <copy file="${basedir}/resources/tomcat/server_tomcat7.xml.in" tofile="${basedir}/resources/tomcat/server_tomcat7.xml.in.backup"  overwrite="true"/>
1099    </if>
1100    <copy file="${basedir}/resources/tomcat/server_tomcat7.xml.svn" tofile="${basedir}/resources/tomcat/server_tomcat7.xml.in" overwrite="true"/>
1101    <if><bool><available file="${basedir}/resources/tomcat/web.xml.in"/></bool>
1102      <copy file="${basedir}/resources/tomcat/web.xml.in" tofile="${basedir}/resources/tomcat/web.xml.in.backup"  overwrite="true"/>
1103    </if>
1104    <copy file="${basedir}/resources/tomcat/web.xml.svn" tofile="${basedir}/resources/tomcat/web.xml.in"  overwrite="true"/>
1105    <if><bool><available file="${basedir}/resources/oai/OAIConfig.xml.in"/></bool>
1106    <copy file="${basedir}/resources/oai/OAIConfig.xml.in" tofile="${basedir}/resources/oai/OAIConfig.xml.in.backup"  overwrite="true"/>
1107    </if>
1108    <copy file="${basedir}/resources/oai/OAIConfig.xml.svn" tofile="${basedir}/resources/oai/OAIConfig.xml.in"  overwrite="true"/>
1109    <if><bool><available file="${basedir}/resources/cgi/gsdl3site.cfg.in"/></bool>
1110      <copy file="${basedir}/resources/cgi/gsdl3site.cfg.in" tofile="${basedir}/resources/cgi/gsdl3site.cfg.in.backup" overwrite="true"/>
1111    </if>
1112    <copy file="${basedir}/resources/cgi/gsdl3site.cfg.svn" tofile="${basedir}/resources/cgi/gsdl3site.cfg.in" overwrite="true"/>
1113    <if><bool><available file="${basedir}/resources/web/global.properties.in"/></bool>
1114    <copy file="${basedir}/resources/web/global.properties.in" tofile="${basedir}/resources/web/global.properties.in.backup" overwrite="true"/>
1115    </if>
1116    <copy file="${basedir}/resources/web/global.properties.svn" tofile="${basedir}/resources/web/global.properties.in" overwrite="true"/>
1117    <if><bool><available file="${basedir}/resources/web/log4j.properties.in"/></bool>
1118    <copy file="${basedir}/resources/web/log4j.properties.in" tofile="${basedir}/resources/web/log4j.properties.in.backup" overwrite="true"/>
1119    </if>
1120    <copy file="${basedir}/resources/web/log4j.properties.svn" tofile="${basedir}/resources/web/log4j.properties.in" overwrite="true"/>
1121  </target>
1122   
1123  <!-- ========== Web app Targets ================================ -->
1124 
1125  <target name="prepare-web" depends="init">
1126    <mkdir dir="${web.writablehome}/applet"/>
1127    <mkdir dir="${web.writablehome}/logs"/>
1128    <mkdir dir="${web.writablehome}/logs/tmp"/>
1129  </target>
1130 
1131  <!-- 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.
1132       The test for whether we need it assumes we won't be trying to compile GS3 against Java versions less than 1.4. -->
1133  <target name="configure-java-version" depends="init"
1134    description="Activates or deactivates some jar libraries as needed depending on your java version">
1135
1136    <available property="have.xalan.jar" file="${web.lib}/xalan.jar"/>
1137    <condition property="need.xalan.jar">
1138      <or>
1139        <not><equals arg1="1.4" arg2="${ant.java.version}"/></not>
1140      </or>
1141    </condition>
1142
1143    <!-- if they have xalan.jar but dont need it -->
1144    <if>
1145      <bool>
1146        <and>
1147          <isset property="have.xalan.jar"/>
1148          <not><isset property="need.xalan.jar"/></not>
1149        </and>
1150      </bool>
1151      <antcall target="deactivate-xalan-jar"/>
1152    </if>
1153
1154    <!-- if they need xalan.jar but dont have it -->
1155    <if>
1156      <bool>
1157        <and>
1158          <not><isset property="have.xalan.jar"/></not>
1159          <isset property="need.xalan.jar"/>
1160        </and>
1161      </bool>
1162      <antcall target="activate-xalan-jar"/>
1163    </if>
1164
1165  </target>
1166 
1167  <target name="activate-xalan-jar">
1168    <echo>activating xalan.jar</echo>
1169    <copy file="${web.lib}/xalan.jar.tmp" tofile="${web.lib}/xalan.jar"/>
1170    <if>
1171      <bool>
1172    <and>
1173      <isset property="current.os.ismac"/>
1174      <available file="${catalina.home}/common/endorsed" type="dir"/>
1175    </and>
1176      </bool>
1177      <copy file="${web.lib}/xalan.jar.tmp" tofile="${catalina.home}/common/endorsed/xalan.jar"/>
1178    </if>
1179  </target>
1180
1181  <target name="deactivate-xalan-jar">
1182    <echo>deactivating xalan.jar</echo>
1183    <delete file="${web.lib}/xalan.jar"/>
1184    <!-- should we be deleting common/endorsed/xalan.jar on mac?? -->
1185  </target>
1186
1187
1188  <target name="prepare-collections" depends="init"
1189    description="Unpack all the collections from their svn zipped versions">
1190    <property name="collect.dir" value="${web.home}/sites/localsite/collect"/>
1191    <property name="index.zip" value="index.zip"/>
1192
1193    <echo message="installing collections..."/>
1194    <antcall target="gs2mgdemo-install"/>
1195    <antcall target="gs2mgppdemo-install"/>
1196    <antcall target="gberg-install"/>
1197    <antcall target="lucene-jdbm-demo-install"/>
1198  </target>
1199
1200  <target name="gs2mgdemo-prepare" if="collect.dir">
1201    <property name="gs2mgdemo.dir" value="${collect.dir}/gs2mgdemo"/>
1202
1203    <condition property="gs2mgdemo.present">
1204      <and>
1205        <available file="${gs2mgdemo.dir}/${index.zip}"/>
1206      </and>
1207    </condition>
1208  </target>
1209
1210  <target name="gs2mgdemo-install" if="gs2mgdemo.present" depends="gs2mgdemo-prepare">
1211    <unzip dest="${gs2mgdemo.dir}" src="${gs2mgdemo.dir}/${index.zip}" />
1212    <echo>collection gs2mgdemo installed</echo>
1213  </target>
1214
1215  <target name="gs2mgppdemo-prepare" if="collect.dir">
1216    <property name="gs2mgppdemo.dir" value="${collect.dir}/gs2mgppdemo"/>
1217 
1218    <condition property="gs2mgppdemo.present">
1219      <and>
1220        <available file="${gs2mgppdemo.dir}/${index.zip}"/>
1221      </and>
1222    </condition>
1223  </target>
1224
1225  <target name="gs2mgppdemo-install" if="gs2mgppdemo.present" depends="gs2mgppdemo-prepare">
1226    <unzip dest="${gs2mgppdemo.dir}" src="${gs2mgppdemo.dir}/${index.zip}" />
1227    <echo>collection gs2mgppdemo installed</echo>
1228  </target>   
1229
1230  <target name="gberg-prepare" if="collect.dir">
1231    <property name="gberg.dir" value="${collect.dir}/gberg"/>
1232    <available file="${gberg.dir}/index/${index.zip}" property="gberg.present"/>
1233  </target>
1234
1235  <target name="gberg-install" if="gberg.present" depends="gberg-prepare">
1236    <unzip dest="${gberg.dir}/index" src="${gberg.dir}/index/${index.zip}"/>
1237    <echo>collection gberg installed</echo>
1238  </target>
1239
1240  <target name="lucene-jdbm-demo-prepare" if="collect.dir">
1241    <property name="lucene-jdbm-demo.dir" value="${collect.dir}/lucene-jdbm-demo"/>
1242    <available file="${lucene-jdbm-demo.dir}/${index.zip}" property="lucene-jdbm-demo.present"/>
1243  </target>
1244
1245  <target name="lucene-jdbm-demo-install" if="lucene-jdbm-demo.present" depends="lucene-jdbm-demo-prepare">
1246    <unzip dest="${lucene-jdbm-demo.dir}" src="${lucene-jdbm-demo.dir}/${index.zip}"/>
1247    <echo>collection lucene-jdbm-demo installed</echo>
1248  </target>
1249
1250 
1251  <target name="install-solr-ext" depends="init" >
1252    <exec executable="ant.bat" osfamily="windows" dir="${solr-ext.home}" spawn="false">
1253      <arg value="add-service"/>
1254    </exec>
1255    <exec executable="ant" os="${os.unix}" dir="${solr-ext.home}" spawn="false">
1256      <arg value="add-service"/>
1257    </exec>
1258    <antcall target="solr-jdbm-demo-install"/>
1259  </target>
1260
1261  <target name="solr-jdbm-demo-prepare" if="collect.dir">
1262    <property name="solr-jdbm-demo.dir" value="${collect.dir}/solr-jdbm-demo"/>
1263    <available file="${solr-jdbm-demo.dir}/${index.zip}" property="solr-jdbm-demo.present"/>
1264  </target>
1265
1266  <target name="solr-jdbm-demo-install" if="solr-jdbm-demo.present" depends="solr-jdbm-demo-prepare">
1267    <unzip dest="${solr-jdbm-demo.dir}" src="${solr-jdbm-demo.dir}/${index.zip}"/>
1268    <echo>collection solr-jdbm-demo installed</echo>
1269  </target>
1270
1271  <!-- Until 64 bit Linux and Mac (Lion) machines can generate a working IsisGdl,
1272       use the ones generated on a 32 bit Linux and Mac (Leopard), respectively -->
1273  <target name="get-isisgdl" if="${current.os.isunix}">
1274    <exec executable="uname" dir="${basedir}" failonerror="false"
1275      outputproperty="uname.val">
1276      <arg value="-m"/>
1277    </exec>
1278   
1279    <if><bool><equals arg1="${uname.val}" arg2="x86_64"/></bool>
1280      <echo>Bitness: ${uname.val}</echo>
1281      <if><bool><contains string="${os.bin.dir}" substring="darwin" casesensitive="false"/></bool>
1282    <get src="http://www.greenstone.org/caveat-emptor/IsisGdl.macleopard"
1283             dest="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl"/>   
1284      </if>
1285      <if><bool><contains string="${os.bin.dir}" substring="linux" casesensitive="false"/></bool>
1286    <get src="http://www.greenstone.org/caveat-emptor/IsisGdl.bin32"
1287             dest="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl"/>
1288      </if>
1289      <chmod file="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl" perm="755"/>
1290    </if>
1291  </target>
1292
1293  <target name="set-perl-shebangs" depends="perl-for-building">
1294    <if>
1295      <bool>
1296        <and><isset property="perl.path"/>
1297          <not><equals arg1="${perl.path}" arg2=""/></not>
1298        </and>
1299      </bool>
1300
1301      <if><bool><istrue value="${current.os.iswindows}"/></bool>
1302    <property name="perl.exec" value="${perl.path}perl.exe"/>
1303    <else>
1304      <property name="perl.exec" value="${perl.path}perl"/>   
1305    </else>
1306      </if>
1307
1308      <!--<echo>**** PERLPATH: ${perl.path}</echo>-->
1309      <echo>Setting perl shebangs to Perl Exec: ${perl.exec}</echo>
1310
1311      <!-- set the shebangs in the cgi files to point to the correct perlpath -->
1312      <if>
1313    <bool><not><equals arg1="${web.home}" arg2="${web.writablehome}"></equals></not></bool>
1314    <mkdir dir="${web.writablehome}"/>
1315    <copy file="${full.web.dir}/WEB-INF/cgi/gliserver.pl"       tofile="${web.writablehome}/WEB-INF/cgi/gliserver.pl"       overwrite="true"/>
1316    <copy file="${full.web.dir}/WEB-INF/cgi/metadata-server.pl" tofile="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" overwrite="true"/>
1317    <copy file="${full.web.dir}/WEB-INF/cgi/checksum.pl"        tofile="${web.writablehome}/WEB-INF/cgi/checksum.pl"        overwrite="true"/>
1318      </if>
1319
1320      <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/gliserver.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1321      <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1322      <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/checksum.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>     
1323      <else>
1324    <echo>WARNING: perl.path is empty. Unable to set the shebangs in the perl files in ${web.writablehome}/WEB-INF/cgi</echo>
1325      </else>
1326    </if>
1327  </target>
1328
1329  <target name="configure-web" depends="init,perl-for-building"
1330    description="Configure only the web app config files">
1331    <!-- we want a unix path in the global.properties file -->
1332    <pathconvert targetos="unix" property="src.gsdl3.home.unix">
1333      <path path="${web.home}"/>
1334    </pathconvert>
1335    <pathconvert targetos="unix" property="src.gsdl3.writablehome.unix">
1336      <path path="${web.writablehome}"/>
1337    </pathconvert>
1338
1339    <antcall target="set-perl-shebangs" inheritAll="true" />
1340   
1341    <filter token="gsdlhome" value="${gs2build.home}"/>
1342    <filter token="gsdlhomequoted" value="&quot;${gs2build.home}&quot;"/>
1343    <filter token="gsdl3srchome" value="${basedir}"/>
1344    <filter token="gsdl3srchomequoted" value="&quot;${basedir}&quot;"/>
1345    <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
1346    <filter token="gsdl3homequoted" value="&quot;${src.gsdl3.home.unix}&quot;"/>
1347    <filter token="gsdl3writablehome" value="${src.gsdl3.writablehome.unix}"/>
1348    <filter token="gsdl3version" value="${app.version}"/>
1349    <filter token="tomcat.server" value="${tomcat.server}"/>
1350    <filter token="tomcat.port" value="${tomcat.port}"/>
1351    <filter token="greenstone.context" value="${greenstone.context}"/>
1352    <filter token="derbyserver" value="${derby.server}"/>
1353    <filter token="derbyserver.port" value="${derby.server.port}"/>
1354    <filter token="perlpath" value="${escaped.perl.path}"/>
1355    <filter token="disable.collection.building" value="${disable.collection.building}"/>
1356    <copy file="${basedir}/resources/cgi/gsdl3site.cfg.in" tofile="${web.writablehome}/WEB-INF/cgi/gsdl3site.cfg" filtering="true" overwrite="true"/>
1357    <copy file="${basedir}/resources/web/global.properties.in" tofile="${web.writableclasses}/global.properties" filtering="true" overwrite="true"/>
1358    <copy file="${basedir}/resources/web/log4j.properties.in" tofile="${web.writableclasses}/log4j.properties" filtering="true" overwrite="true"/>
1359    <if><bool><istrue value="${gsdl3home.isreadonly}"/></bool>
1360      <!-- uncomment the writablehome properties -->
1361      <rsr verbosity="1" file="${web.writableclasses}/global.properties" pattern="^#gsdl3\.(writable{1})?home" replacement="gsdl3.$1home" />
1362    </if>
1363    <chmod file="${web.writableclasses}/global.properties" perm="644"/>
1364    <chmod file="${web.writableclasses}/log4j.properties" perm="644"/>
1365  </target>
1366
1367  <target name="compile-web" depends="init">
1368    <javac srcdir="${web.classes}"
1369      destdir="${web.classes}"
1370      includeantruntime="${compile.includeantruntime}"
1371      debug="${compile.debug}"
1372      deprecation="${compile.deprecation}"
1373      optimize="${compile.optimize}"
1374      encoding="${compile.encoding}">
1375      <classpath><path refid="compile.classpath"/></classpath>
1376    </javac>
1377  </target>
1378
1379  <target name="compile-classpath-jars" depends="init">
1380    <if><bool><available file="admin/cp.mf"/></bool>
1381      <jar destfile="admin/cp.jar" manifest="admin/cp.mf"/>
1382    </if>
1383    <if><bool><available file="${lib.java}/cp.mf"/></bool>
1384      <jar destfile="${lib.java}/cp.jar" manifest="${lib.java}/cp.mf"/>
1385    </if>
1386    <if><bool><available file="${lib.jni}/cp.mf"/></bool>
1387      <jar destfile="${lib.jni}/cp.jar" manifest="${lib.jni}/cp.mf"/>
1388    </if>
1389    <if><bool><available file="${web.lib}/cp.mf"/></bool>
1390      <jar destfile="${web.lib}/cp.jar" manifest="${web.lib}/cp.mf"/>
1391    </if>
1392    <jar destfile="cp.jar">
1393      <manifest>
1394        <attribute name="Class-Path" value="server.jar admin/cp.jar lib/java/cp.jar lib/jni/cp.jar web/WEB-INF/lib/cp.jar"/>
1395      </manifest>
1396    </jar>
1397  </target>
1398
1399  <target name="clean-classpath-jars" depends="init">
1400    <delete file="admin/cp.jar"/>
1401    <delete file="${lib.java}/cp.jar"/>
1402    <delete file="${lib.jni}/cp.jar"/>
1403    <delete file="${web.lib}/cp.jar"/>
1404    <delete file="cp.jar"/>
1405  </target>
1406
1407
1408  <target name="svnupdate-web" unless="nosvn.mode">
1409    <exec executable="svn">
1410      <arg value="update"/>
1411      <arg value="${web.writablehome}"/>
1412      <arg value="-r"/><arg value="${branch.revision}"/>
1413    </exec>
1414  </target>
1415
1416  <target name="update-web" depends="init,svnupdate-web,configure-web"
1417    description="update only the web stuff (config files)"/>
1418
1419  <!-- ======================= Tomcat Targets ========================== -->
1420 
1421  <!-- this target downloads and installs Tomcat -->
1422  <!-- we download tomcat (version 7 for Java 1.5 and later, version 5 for Java 1.4 plus the 1.4 compatibility package). -->
1423  <target name="prepare-tomcat" depends="init,setup-proxy" if="tomcat.islocal"
1424    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">
1425  <if>
1426      <bool>
1427        <not><available file="${packages.home}/tomcat/.flagfile"/></not>
1428      </bool>
1429
1430      <!-- check that packages dir is there -->
1431      <mkdir dir="${packages.home}"/>
1432      <get src="http://www.greenstone.org/gs3files/${tomcat.version}.zip"
1433        dest="${packages.home}/${tomcat.version}.zip"
1434        usetimestamp="true"/>
1435      <unzip src="${packages.home}/${tomcat.version}.zip"
1436        dest="${packages.home}"/>
1437     
1438      <!-- If we are using Java 1.4, we'd be using tomcat 5.5 in which case
1439      we would need to have the tomcat compat package to work with Java 1.4-->
1440      <if>
1441    <bool><equals arg1="1.4" arg2="${ant.java.version}"/></bool>
1442    <get src="http://www.greenstone.org/gs3files/${tomcat.version}-compat.zip"
1443      dest="${packages.home}/${tomcat.version}-compat.zip"
1444      usetimestamp="true"/>
1445    <unzip src="${packages.home}/${tomcat.version}-compat.zip"
1446      dest="${packages.home}"/>
1447      </if>
1448     
1449      <!-- delete any existing tomcat -->
1450      <delete dir="${packages.home}/tomcat"/>
1451      <move todir="${packages.home}/tomcat">
1452        <fileset dir="${packages.home}/${tomcat.version}"/>
1453      </move>
1454     
1455      <!-- To avoid the CGI permissions error appearing continuously in the (localhost) log,
1456        need privileged=true set in the root context.xml file too, not just greenstone context file.
1457        See http://stackoverflow.com/questions/9845936/tomcat-v7-0-load-exception-marking-servlet-ssi-as-unavailable/10305471#10305471
1458        For usage of IfTask IsLessThan: http://antelope.stage.tigris.org/nonav/docs/manual/bk03ch05s02.html -->
1459      <if><bool><not><islessthan arg1="${tomcat.version.major}" arg2="7"/></not></bool>     
1460        <copy file="${basedir}/resources/tomcat/root_context.xml" tofile="${packages.home}/tomcat/conf/context.xml" overwrite="true" />     
1461      </if>
1462       
1463     
1464      <!--
1465      <copy file="${basedir}/resources/tomcat/setclasspath.bat"
1466        tofile="${packages.home}/tomcat/bin/setclasspath.bat"
1467        overwrite="true"/>
1468      <copy file="${basedir}/resources/tomcat/setclasspath.sh"
1469        tofile="${packages.home}/tomcat/bin/setclasspath.sh"
1470        overwrite="true"/>
1471      -->
1472      <!-- make sure we have execute permission for the .sh files -->
1473      <chmod dir="${packages.home}/tomcat/bin" perm="ugo+rx"
1474        includes="*.sh"/>   
1475
1476      <echo file="${packages.home}/tomcat/.flagfile">
1477        the timestamp of this file is the time that tomcat was extracted from the zip files.
1478        it is used to figure out whether the files need to be refreshed or not in `ant prepare-tomcat`
1479      </echo>
1480
1481      <!-- this is not strictly a prepare tomcat thing, but if one changes
1482      Java, then they need to change tomcat as well, so might as well call
1483      it here -->
1484      <antcall target="configure-java-version"/>
1485      <else>
1486        <echo>Tomcat has been prepared, will not prepare</echo>
1487        <echo>Delete ${packages.home}/tomcat/.flagfile to force refresh</echo>
1488      </else>
1489
1490    </if>
1491
1492  </target> 
1493 
1494  <target name="configure-tomcat" depends="init,configure-tomcat-local,configure-tomcat-external"/>
1495 
1496  <target name="configure-tomcat-local" depends="init,perl-for-building" if="tomcat.islocal">
1497    <!-- re-setup the server.xml file -->
1498    <copy file="${basedir}/resources/tomcat/server_tomcat${tomcat.version.major}.xml.in"
1499        tofile="${packages.home}/tomcat/conf/server.xml" overwrite="true">
1500      <filterset>
1501        <filter token="port" value="${tomcat.port}"/>
1502        <filter token="shutdown-port" value="${tomcat.shutdown.port}"/>
1503      </filterset>
1504    </copy>
1505
1506    <!-- set up the solr context -->
1507
1508    <!-- First work out the IPv4 address for this machine -->
1509    <exec executable="${basedir}/bin/script/IPv4.sh" os="${os.unix}" failonerror="false" outputproperty="ipv4.val">
1510      <arg value="-format-for-tomcat-context"/>
1511    </exec>
1512    <exec executable="${basedir}/bin/script/IPv4.bat" osfamily="windows" failonerror="false" outputproperty="ipv4.val">
1513      <arg value="-format-for-tomcat-context"/>
1514    </exec>
1515
1516    <copy file="${basedir}/ext/solr/solr-tomcat-context.xml.in" tofile="${packages.home}/tomcat/conf/Catalina/localhost/solr.xml" overwrite="true">
1517      <filterset>
1518        <filter token="gsdl3webhome" value="${web.writablehome}"/>
1519    <filter token="tomcathome" value="${basedir}/packages/tomcat"/>
1520    <filter token="IPv4" value="${ipv4.val}"/>
1521      </filterset>
1522    </copy>
1523
1524    <!-- set up the greenstone3 context, it may have a custom name specified in build.properties -->
1525    <if><bool><not><equals arg1="greenstone3" arg2="${greenstone.context}"></equals></not></bool>
1526        <copy file="${basedir}/resources/tomcat/greenstone3.xml.in" tofile="${basedir}/resources/tomcat/${greenstone.context}.xml.in" overwrite="true"/>
1527    </if>
1528    <copy file="${basedir}/resources/tomcat/${greenstone.context}.xml.in" tofile="${packages.home}/tomcat/conf/Catalina/localhost/${greenstone.context}.xml" overwrite="true">
1529      <filterset>
1530        <filter token="gsdl3webhome" value="${web.home}"/>
1531        <filter token="gsdl3webwritablehome" value="${web.writablehome}"/>
1532    <filter token="privilegedattribute" value="${privileged.attribute}"/>
1533    <filter token="allowedIPs" value="${allowed.IPs}"/>
1534    <filter token="derbyserver" value="${derby.server}"/>
1535    <filter token="derbyserverport" value="${derby.server.port}"/>
1536      </filterset>
1537    </copy>
1538    <if>
1539        <bool>
1540            <and>
1541                <available file="${packages.home}/tomcat/conf/Catalina/localhost/greenstone3.xml"/>
1542                <not><equals arg1="greenstone3" arg2="${greenstone.context}"></equals></not>
1543            </and>
1544        </bool>
1545        <delete file="${packages.home}/tomcat/conf/Catalina/localhost/greenstone3.xml"/>
1546    </if>
1547   
1548    <!-- set up the greenstone3 web.xml file -->
1549    <copy file="${basedir}/resources/tomcat/web.xml.in" tofile="${packages.home}/tomcat/conf/web.xml" overwrite="true">
1550      <filterset>
1551    <filter token="perlpath" value="${perl.path}"/>
1552      </filterset>
1553    </copy>
1554  </target>
1555 
1556  <target name="configure-tomcat-external" depends="init" unless="tomcat.islocal">
1557    <!-- re-setup the server.xml file -->
1558    <!-- need to edit the config file, or do we get the user to do this???-->
1559  </target>
1560
1561  <target name="configure-solr-ext" depends="init" >
1562    <!-- re-setup the web/ext/solr/solr.xml file -->
1563    <copy file="${web.home}/ext/solr/solr.xml.in"
1564      tofile="${gsdl3.writablehome}/ext/solr/solr.xml" filtering="true" overwrite="true">
1565      <filterset>
1566        <filter token="gsdl3.home" value="${src.gsdl3.home.unix}"/>
1567        <filter token="gsdl3.writablehome" value="${src.gsdl3.writablehome.unix}"/>
1568      </filterset>
1569    </copy>
1570  </target>
1571 
1572  <!-- This target runs tomcat's "bin/catalina.bat(.sh) jpda start"
1573       to allow debugging the running GS3 server in Eclipse. See the instructions at
1574       http://www.wikijava.org/wiki/Debugging_a_servlet_with_tomcat_and_Eclipse_tutorial
1575       on how to use this with eclipse
1576    -->
1577  <target name="debug-start-tomcat" description="Startup Tomcat for debugger" depends="init" if="tomcat.islocal">
1578    <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
1579    <property name="tomcat.path" refid="local.tomcat.path"/>
1580
1581    <if><bool>
1582    <isset property="fedora.maxpermsize"/></bool>
1583      <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx800M ${readonly.catalina.opts} ${fedora.maxpermsize}"/>
1584      <else>
1585    <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx800M ${readonly.catalina.opts}"/>
1586      </else>
1587    </if>
1588
1589    <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
1590    <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
1591   
1592    <exec executable="${catalina.home}/bin/catalina.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
1593      <arg value="jpda" />
1594      <arg value="start" />
1595      <env key="JPDA_ADDRESS" value="8000"/> <!-- for debugging Tomcat in Eclipse -->
1596      <env key="JPDA_TRANSPORT" value="dt_socket"/> <!-- for debugging Tomcat in Eclipse -->
1597      <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
1598      <env key="PATH" path="${tomcat.path}"/>
1599      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1600      <env key="CATALINA_HOME" value="${catalina.home}"/>
1601      <env key="CLASSPATH" path="${tomcat.classpath}"/>
1602      <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
1603      <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
1604      <env key="WNHOME" path="${wn.home}"/>
1605      <env key="FEDORA_HOME" path="${fedora.home}"/>
1606    </exec>
1607    <exec executable="${catalina.home}/bin/catalina.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="true">
1608      <arg value="jpda" />
1609      <arg value="start" />
1610      <env key="JPDA_ADDRESS" value="8000"/> <!-- for debugging Tomcat in Eclipse -->
1611      <env key="JPDA_TRANSPORT" value="dt_socket"/> <!-- for debugging Tomcat in Eclipse -->
1612      <env key="GSDLOS" value="windows"/>
1613      <env key="GSDL3HOME" value="${basedir}"/>
1614      <env key="Path" path="${tomcat.path}"/>
1615      <env key="PATH" path="${tomcat.path}"/>
1616      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1617      <env key="CATALINA_HOME" value="${catalina.home}"/>
1618      <env key="CLASSPATH" path="${tomcat.classpath}"/>
1619      <env key="FEDORA_HOME" path="${fedora.home}"/>
1620    </exec>
1621    <!-- wait for the server to startup in case other targets need it running -->
1622    <waitfor maxwait="5" maxwaitunit="second">
1623      <and>
1624        <socket server="${tomcat.server}" port="${tomcat.port}"/>
1625        <http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/index.html"/>
1626      </and>
1627    </waitfor>
1628  </target> 
1629 
1630  <target name="start-tomcat" description="Startup only Tomcat" depends="check-tomcat-started">
1631
1632    <if><bool><istrue value="${tomcat.isstarted}"/></bool>
1633      <echo>**************************************</echo>
1634      <echo>A WEB SERVER IS ALREADY RUNNING ON ${server.protocol}://${tomcat.server}:${tomcat.port}. NOT STARTING.</echo>
1635      <echo>**************************************</echo>
1636      <else>
1637    <antcall target="force-start-tomcat"/>
1638      </else>
1639      </if>
1640  </target>
1641
1642  <!-- Another way: http://ptrthomas.wordpress.com/2006/03/25/how-to-start-and-stop-tomcat-from-ant/ -->
1643  <target name="force-start-tomcat" description="Startup only Tomcat" depends="init" if="tomcat.islocal">
1644
1645    <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
1646    <property name="tomcat.path" refid="local.tomcat.path"/>
1647
1648    <if><bool>
1649    <isset property="fedora.maxpermsize"/></bool>
1650      <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx800M ${readonly.catalina.opts} ${fedora.maxpermsize}"/>
1651      <else>
1652    <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx800M ${readonly.catalina.opts}"/>
1653      </else>
1654    </if>
1655
1656    <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
1657    <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
1658
1659    <!-- using osfamily instead of testing os against os.windows list of recognised windows versions
1660     so that future windows versions are included. See http://simonharrer.wordpress.com/tag/osfamily/
1661    Can't use the osfamily test for linux-type machines as a group since osfamily=unix is separate from osfamily=mac,
1662    see http://ant-contrib.sourceforge.net/tasks/tasks/osfamily.html -->
1663
1664    <exec executable="${catalina.home}/bin/startup.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
1665      <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
1666      <env key="GSDL3HOME" value="${basedir}"/>
1667      <env key="PATH" path="${tomcat.path}"/>
1668      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1669      <env key="CATALINA_HOME" value="${catalina.home}"/>
1670      <env key="CLASSPATH" path="${tomcat.classpath}"/>
1671      <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
1672      <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
1673      <env key="WNHOME" path="${wn.home}"/>
1674      <env key="FEDORA_HOME" path="${fedora.home}"/>
1675    </exec>
1676    <exec executable="${catalina.home}/bin/startup.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="true">
1677      <env key="GSDLOS" value="windows"/>
1678      <env key="GSDL3HOME" value="${basedir}"/>
1679      <env key="Path" path="${tomcat.path}"/>
1680      <env key="PATH" path="${tomcat.path}"/>
1681      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1682      <env key="CATALINA_HOME" value="${catalina.home}"/>
1683      <env key="CLASSPATH" path="${tomcat.classpath}"/>
1684      <env key="FEDORA_HOME" path="${fedora.home}"/>
1685    </exec>
1686    <!-- wait for the server to startup in case other targets need it running -->
1687    <waitfor maxwait="5" maxwaitunit="second">
1688      <and>
1689        <socket server="${tomcat.server}" port="${tomcat.port}"/>
1690        <http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/index.html"/>
1691      </and>
1692    </waitfor>
1693
1694  </target>
1695
1696  <!--ant task http: http://www.jajakarta.org/ant/ant-1.6.1/docs/ja/manual/api/org/apache/tools/ant/taskdefs/condition/Http.html-->
1697  <target name="reconfigure" description="Reconfigure the message router">
1698    <waitfor maxwait="5" maxwaitunit="second">
1699      <http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c"/>
1700    </waitfor>
1701  </target>
1702
1703  <!--Command-line args to Ant: http://www.jguru.com/faq/view.jsp?EID=471794-->
1704  <target name="reconfigure-collection" description="Reconfigure the collection">
1705    <waitfor maxwait="5" maxwaitunit="second">
1706      <http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c&amp;sc=${collection}"/>
1707    </waitfor>
1708  </target>
1709
1710  <!-- windows: do we want to launch a webrowser?? -->
1711  <!-- shouldn't this test whether anything is running first?
1712       It's safer to always attempt to stop tomcat: that way we won't be dependent on the right time
1713       to check whether the server is stopped or still running before attempting to start again.
1714       This target, which was recently called force-stop-tomcat for a while but is back to being
1715       called stop-tomcat, now hides the Java exception output that appears whenever tomcat is already
1716       stopped as happens when stop-tomcat is called consecutively. -->
1717  <target name="force-stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal">
1718    <exec executable="${catalina.home}/bin/shutdown.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
1719      <env key="FEDORA_HOME" path="${fedora.home}"/>
1720      <env key="CATALINA_HOME" value="${catalina.home}"/>
1721      <arg line=">/dev/null 2>&amp;1"/>
1722    </exec>
1723    <exec executable="${catalina.home}/bin/shutdown.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="false">
1724      <env key="FEDORA_HOME" path="${fedora.home}"/>
1725      <env key="CATALINA_HOME" value="${catalina.home}"/>
1726      <arg line=">nul 2>&amp;1"/>
1727    </exec>   
1728  </target>
1729
1730  <!-- Can also try the "socket" condition in place of the "http" condition
1731       And also use a <waitfor> in place of <condition>, such as:
1732       <waitfor maxwait="5" maxwaitunit="second" timeoutproperty="tomcat.isstopped"><http url="..."/></waitfor>
1733       The http URL resolves to host:port/greenstone3
1734       Condition uses <http/> rather than <socket/> for testing, since if the server was stopped, the socket
1735       might still be in use for some moments. We test the URL with the http condition since it's likelier to
1736       fail sooner if the server has indeed been stopped. -->
1737  <target name="check-tomcat-running">
1738    <condition property="tomcat.isrunning">
1739      <!--<http url="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}"/>-->
1740      <http url="${server.protocol}://${tomcat.server}:${tomcat.port}"/>
1741    </condition>
1742  </target>
1743 
1744  <!--
1745      <target name="verbose-check-tomcat-running">
1746      <condition property="tomcat.isrunning" value="true" else="false">
1747      <http url="${server.protocol}://${tomcat.server}:${tomcat.port}"/>
1748      </condition>
1749      <echo>Tomcat is running: ${tomcat.isrunning}</echo>
1750      </target>
1751  -->
1752  <target name="verbose-check-tomcat-running" depends="check-tomcat-running">   
1753    <if>
1754      <bool>
1755    <istrue value="${tomcat.isrunning}"/>
1756      </bool>     
1757      <echo>Tomcat is running: ${tomcat.isrunning}</echo>
1758      <else><echo>Tomcat is running: false</echo></else><!-- tomcat.isrunning not set -->
1759    </if>
1760  </target> 
1761 
1762  <!-- Need a copy of the check-tomcat-running target with a distinct property, because ant restart runs
1763       both stop and start, both of which need to do tomcat checks. Each property can be set only once during
1764       an invocation with ant. So ant restart will need two properties to store each of the tomcat checks -->
1765  <target name="check-tomcat-started">
1766    <condition property="tomcat.isstarted">
1767      <http url="${server.protocol}://${tomcat.server}:${tomcat.port}"/>
1768    </condition>
1769  </target>
1770
1771
1772
1773  <!-- stop-tomcat checks if the tomcat server is already running. If it appears to be running
1774       (regardless of whether tomcat was just starting to shut down), this target calls force-stop-tomcat
1775       to issue the shutdown command to tomcat. Then it waits for at most 15 seconds for the server to
1776       actually stop by checking the socket at which tomcat listens every second, printing a warning
1777       at the end of the max wait time of 15 seconds if tomcat was still running. -->
1778  <target name="stop-tomcat" description="Shutdown only Tomcat if running" depends="check-tomcat-running" if="tomcat.isrunning">
1779     <antcall target="force-stop-tomcat"/>
1780
1781     <property name="wait.numchecks" value="15"/>
1782     <echo>Waiting for the server to shutdown... (${wait.numchecks} seconds max)</echo>
1783     <waitfor maxwait="${wait.numchecks}" maxwaitunit="second" checkevery="1" checkeveryunit="second" timeoutproperty="tomcat.timedout">
1784       <not><socket server="${tomcat.server}" port="${tomcat.port}"/></not>
1785     </waitfor>
1786     
1787     <if>
1788       <bool>
1789     <isset property="${tomcat.timedout}"/>
1790       </bool>
1791       <property name="tomcat.isrunning" value="true"/>
1792       <echo>WARNING: Checked the socket ${wait.numchecks} times, but port ${tomcat.port} is still busy.</echo>
1793       <else>
1794     <echo>Tomcat is stopped.</echo>
1795     <property name="tomcat.isrunning" value="false"/>
1796       </else>
1797     </if>
1798  </target>
1799
1800  <target name="restart-tomcat" description="Shutdown and restart only Tomcat" depends="init,stop-tomcat,force-start-tomcat"/>
1801
1802  <target name="setup-catalina-ant-tasks">
1803    <!-- Configure the custom Ant tasks for the Tomcat Manager application -->
1804    <taskdef name="deploy"    classname="org.apache.catalina.ant.DeployTask"
1805      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1806    <taskdef name="list"      classname="org.apache.catalina.ant.ListTask"
1807      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1808    <taskdef name="reload"    classname="org.apache.catalina.ant.ReloadTask"
1809      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1810    <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"
1811      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1812    <taskdef name="roles"     classname="org.apache.catalina.ant.RolesTask"
1813      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1814    <taskdef name="start"     classname="org.apache.catalina.ant.StartTask"
1815      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1816    <taskdef name="stop"      classname="org.apache.catalina.ant.StopTask"
1817      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1818    <taskdef name="undeploy"  classname="org.apache.catalina.ant.UndeployTask"
1819      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1820  </target>
1821
1822  <!-- http://blog.andrewbeacock.com/2007/11/how-to-truncate-log-file-using-ubuntu.html
1823    Doing "cat </dev/null > packages/tomcat/logs/catalina.out" doesn't work as an ant target.
1824    It seems to have a problem with cat or </dev/null, with or without the < sign. -->
1825  <target name="reset-logs" description="Empties catalina.out, greenstone.log and contents of web/logs/tmp">
1826    <echo>Truncating catalina.out, solr.log, greenstone.log and server.log, and emptying ${web.writablehome}/logs/tmp</echo>   
1827    <exec executable="rm" os="${os.unix}" dir="${catalina.home}/logs" spawn="false">
1828      <arg value="-f"/>
1829      <arg value="catalina.out"/>
1830    </exec>
1831    <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
1832      <arg value="-f"/>
1833      <arg value="greenstone.log"/>
1834    </exec>
1835    <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
1836      <arg value="-f"/>
1837      <arg value="server.log"/>
1838    </exec>
1839
1840    <exec executable="touch" os="${os.unix}" dir="${catalina.home}/logs"
1841    spawn="false">
1842      <arg value="catalina.out"/>
1843    </exec>
1844    <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
1845      spawn="false">
1846      <arg value="greenstone.log"/>
1847    </exec>
1848    <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
1849      spawn="false">
1850      <arg value="server.log"/>
1851    </exec>
1852
1853    <exec executable="cmd" osfamily="windows" dir="${catalina.home}/logs" spawn="false">
1854      <arg line="/c echo. > catalina.out"/>
1855    </exec>
1856    <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
1857      <arg line="/c echo. > greenstone.log"/>
1858    </exec>
1859    <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
1860      <arg line="/c echo. > server.log"/>
1861    </exec>
1862
1863    <!-- if ext/solr/logs/solr.log exists, truncate it -->
1864    <if><bool><available file="${solr-ext.home}/logs/solr.log" type="file"/></bool>     
1865        <exec executable="rm" os="${os.unix}" dir="${solr-ext.home}/logs" spawn="false">
1866          <arg value="-f"/>
1867          <arg value="solr.log"/>
1868        </exec>
1869        <exec executable="touch" os="${os.unix}" dir="${solr-ext.home}/logs" spawn="false">
1870          <arg value="solr.log"/>
1871        </exec>   
1872        <exec executable="cmd" osfamily="windows" dir="${solr-ext.home}/logs" spawn="false">
1873          <arg line="/c echo. > solr.log"/>
1874        </exec>
1875    </if>
1876   
1877    <if>
1878      <bool><available file="${web.writablehome}/logs/tmp" type="dir"/></bool>
1879      <delete>
1880    <fileset dir="${web.writablehome}/logs/tmp" includes="**/*"/>
1881      </delete>
1882    </if>
1883  </target>
1884
1885  <target name="clear-tomcat-sessions" description="Clear the Tomcat Session info." depends="init">
1886    <exec executable="cmd" osfamily="windows" dir="${catalina.home}/work/Catalina/localhost/greenstone3" spawn="false">
1887      <arg line="/c echo. > SESSIONS.ser"/>
1888    </exec>
1889    <exec executable="rm" os="${os.unix}" dir="${catalina.home}/work/Catalina/localhost/greenstone3" spawn="false">
1890      <arg value="-f"/>
1891      <arg value="SESSIONS.ser"/>
1892    </exec>
1893
1894  </target>
1895  <!-- ======================= ant Targets ============================ -->
1896  <target name="prepare-ant" depends="init">
1897    <if>
1898      <bool>
1899        <not><available file="${packages.home}/ant/.flagfile"/></not>
1900      </bool>
1901
1902      <get src="http://www.greenstone.org/gs3files/apache-ant-1.7.0-bin.zip"
1903        dest="${packages.home}/apache-ant-1.7.0-bin.zip"
1904        usetimestamp="true"/>
1905      <unzip src="${packages.home}/apache-ant-1.7.0-bin.zip"
1906        dest="${packages.home}"/>
1907      <move todir="${packages.home}/ant">
1908        <fileset dir="${packages.home}/apache-ant-1.7.0"/>
1909      </move>
1910      <echo file="${packages.home}/ant/.flagfile">
1911        the timestamp of this file is the time that ant was extracted from the zip files.
1912        it is used to figure out whether the files need to be refreshed or not in `ant prepare-ant`
1913      </echo>
1914
1915      <else>
1916        <echo>Ant has been prepared, will not prepare</echo>
1917        <echo>Delete ${packages.home}/ant/.flagfile to force refresh</echo>
1918      </else>
1919
1920    </if>
1921  </target>
1922
1923  <!-- ======================= Admin Targets ============================ --> 
1924
1925  <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
1926    See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
1927    But you can do: echo mypassword | ant config-admin -->
1928  <target name="config-admin" description="Reset admin password">
1929    <input addproperty="admin.password" defaultvalue="admin" message="New admin password (3-20 characters):&gt;">
1930      <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
1931    </input>
1932    <!--<echo>PWD: ${admin.password}</echo>-->
1933    <antcall target="update-userdb">
1934      <param name="user.username" value="admin"/>
1935      <param name="user.password" value="${admin.password}"/>
1936      <param name="user.groups" value=""/>
1937      <param name="user.status" value=""/>
1938      <param name="user.comment" value="Password updated."/>
1939      <param name="user.email" value=""/>
1940    </antcall>
1941  </target>
1942
1943  <target name="config-user" description="Add or modify users" depends="get-user-data,update-userdb"/>
1944
1945  <target name="get-user-data" description="Get user details">
1946    <input addproperty="user.username" message="Username:&gt;"/>
1947    <input addproperty="user.password" defaultvalue="" message="Password (3-20 characters):&gt;">
1948      <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
1949    </input>
1950    <input addproperty="user.groups" defaultvalue="" message="Groups (comma-separated list, e.g. personal-collections-editor):&gt;"/>
1951    <input addproperty="user.status" defaultvalue="true" message="Enabled (true/false):&gt;"/>
1952    <input addproperty="user.comment" defaultvalue="" message="Comment:&gt;"/>
1953    <input addproperty="user.email" defaultvalue="" message="Email:&gt;"/>
1954  </target>
1955
1956  <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
1957       See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
1958       But you can do: echo mypassword | ant config-admin -->
1959  <target name="update-userdb" description="Add or modify users" depends="start-derby">
1960
1961    <!--
1962       We're now using derby networked server, so stopping and starting tomcat is not necessary.
1963       For embedded derby: stop tomcat if running, since derby db is embedded
1964       and only allows connections from one jvm instance at a time
1965     See http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html
1966     The ${tomcat.isrunning} property is set by the depends-target "check-tomcat-running" -->
1967   
1968    <!-- Need the derby networked server to be running in order to modify the usersDB.
1969     The start-derby task will check if derby is already running (if not, ${derby.isstarted} will
1970     be false) and will only start up networked derby if it is not already running.
1971     The ${derby.isstarted} property is set by the depends-target "start-derby", since it won't
1972     set the property if called with antcall (like launching in a subshell). Have to use 'depends'.
1973     We'll check ${derby.isstarted} at the end to stop derby again if we had to start it up now.-->
1974    <!--<antcall target="start-derby"/>-->
1975
1976    <!-- wait a max of 5 seconds for the derbyserver to have started up -->
1977    <waitfor maxwait="5" maxwaitunit="second">
1978      <socket server="${derby.server}" port="${derby.server.port}"/>
1979    </waitfor>
1980
1981    <!--<echo>${admin.password}</echo>--> <!-- for testing -->
1982    <echo>gsdl3.writablehome: ${gsdl3.writablehome}</echo> <!-- for testing -->
1983    <echo>web.home: ${web.home}</echo> <!-- for testing -->
1984    <java classname="org.greenstone.gsdl3.util.ModifyUsersDB">
1985      <classpath refid="compile.classpath"/> <!--for ${web.lib}/gsdl3.jar and supporting files-->
1986      <sysproperty key="gsdl3.writablehome" value="${gsdl3.writablehome}" /> <!-- passes -D<syspropKey=syspropVal> to java class ModifyUsersDB. Available in java code as System.getProperty("syspropKey") -->
1987      <arg file="${web.home}/etc/usersDB"/>
1988      <arg value="${user.username}"/>
1989      <arg value="password=${user.password}"/>
1990      <arg value="groups=${user.groups}"/>
1991      <arg value="status=${user.status}"/>
1992      <arg value="comment=${user.comment}"/>
1993      <arg value="email=${user.email}"/>
1994    </java>
1995
1996    <!-- Need to stop networked derby again if we ran it for this target with the depends=start-derby call.
1997     The test here is for <not>derby.isstarted</not>, as the property would be the same as before
1998     derby was started, since properties are immutable within a single ant command. -->
1999    <if>
2000      <bool>
2001    <not><istrue value="${derby.isstarted}"/></not>
2002      </bool>
2003      <antcall target="force-stop-derby"/>
2004    </if>
2005
2006  </target>
2007
2008
2009  <!-- ======================= Axis Targets ============================ --> 
2010 
2011  <target name="prepare-axis" depends="init">
2012
2013    <if>
2014      <bool>
2015        <not><available file="${packages.home}/axis/.flagfile"/></not>
2016      </bool>
2017
2018      <get src="http://www.greenstone.org/gs3files/${axis.zip.version}"
2019        dest="${packages.home}/${axis.zip.version}"
2020        usetimestamp="true"/>
2021      <unzip src="${packages.home}/${axis.zip.version}"
2022        dest="${packages.home}"/>
2023      <move todir="${packages.home}/axis">
2024        <fileset dir="${packages.home}/${axis.dir.version}"/>
2025      </move>
2026      <!-- install axis into greenstone web app -->
2027      <copy todir="${web.lib}">
2028        <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/lib">
2029          <include name="*.jar"/>
2030        </fileset>
2031      </copy>
2032      <copy todir="${web.home}">
2033        <fileset dir="${packages.home}/axis/webapps/axis/">
2034          <include name="*.jsp"/>
2035          <include name="*.jws"/>
2036        </fileset>
2037      </copy>
2038      <copy tofile="${web.home}/axis.html" file="${packages.home}/axis/webapps/axis/index.html"/>
2039      <copy todir="${web.classes}">
2040        <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/classes">
2041          <include name="*.properties"/>
2042        </fileset>
2043      </copy>
2044      <echo file="${packages.home}/axis/.flagfile">
2045        the timestamp of this file is the time that axis was extracted from the zip files.
2046        it is used to figure out whether the files need to be refreshed or not in `ant prepare-axis`
2047      </echo>
2048
2049      <else>
2050        <echo>Axis has been prepared, will not prepare</echo>
2051        <echo>Delete ${packages.home}/axis/.flagfile to force refresh</echo>
2052      </else>
2053
2054    </if>
2055  </target>
2056
2057  <target name="soap-deploy-site" depends="init,get-sitename,get-siteuri,get-webservices,create-deployment-files,deploy-site"
2058    description="Deploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work."/>
2059   
2060    <target name="deploy-site">
2061    <java classname="org.apache.axis.client.AdminClient">
2062      <classpath refid="compile.classpath"/>
2063      <arg value="-l"/>
2064      <arg value="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/servlet/AxisServlet"/>
2065      <arg file="${basedir}/resources/soap/deploy.wsdd"/>
2066    </java>
2067    <delete file="${basedir}/resources/soap/deploy.wsdd"/> <!--clean up, no longer used-->
2068  </target>
2069 
2070  <target name="soap-undeploy-site" depends="get-undeploy-service-name"
2071    description="Undeploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work.">
2072    <filter token="servicesname" value="${axis.undeploy.servicename}"/>
2073    <copy file="${basedir}/resources/soap/undeploy-site.wsdd.template"
2074      tofile="${basedir}/resources/soap/undeploy.wsdd"
2075      filtering="true"
2076      overwrite="true"/>
2077    <java classname="org.apache.axis.client.AdminClient">
2078      <classpath refid="compile.classpath"/>
2079      <arg value="-l"/>
2080      <arg value="${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}/servlet/AxisServlet"/>
2081      <arg file="${basedir}/resources/soap/undeploy.wsdd"/>
2082    </java>
2083    <delete file="${basedir}/resources/soap/undeploy.wsdd"/> <!--clean up, no longer used-->
2084  </target> 
2085
2086  <!-- this target used to deploy the default web service SOAPServer (base.webservice.name) on the localsite server
2087  with the default servicename of localsite-->
2088  <target name="deploy-localsite" depends="init"
2089    description="Deploy the SOAP server for localsite. Will start and stop Tomcat.">
2090    <antcall target="force-start-tomcat"/>
2091    <echo>Deploying ${base.webservice.name} web services for localsite under service name: localsite</echo>
2092    <antcall target="create-deployment-files">
2093      <param name="axis.sitename" value="localsite"/>
2094      <param name="axis.servicesname" value="${base.webservice.name}"/>
2095      <param name="axis.siteuri" value="localsite"/>
2096    </antcall>
2097    <antcall target="deploy-site">
2098      <param name="axis.sitename" value="localsite"/>
2099      <param name="axis.servicesname" value="${base.webservice.name}"/>
2100      <param name="axis.siteuri" value="localsite"/>
2101    </antcall>
2102    <echo>The Greenstone server has been started up. If you do not want it running, please type: ant stop.</echo>
2103  </target>
2104   
2105  <target name="get-sitename" unless="axis.sitename">
2106    <input addproperty="axis.sitename" defaultvalue="localsite">What site do you want to deploy services for?
2107Press Enter for default:localsite</input>
2108  </target>
2109
2110  <target name="get-undeploy-service-name" unless="axis.undeploy.servicename">
2111    <input addproperty="axis.undeploy.servicename" defaultvalue="localsite">Please enter the full name of the service you wish to undeploy.
2112To find out which web services you've got deployed, point your browser to ${server.protocol}://${tomcat.server}:${tomcat.port}/greenstone3/services
2113Or press Enter for undeploying the default:localsite /&gt;</input>
2114     <echo>Name of service to undeploy: ${axis.undeploy.servicename}</echo>
2115  </target>
2116
2117  <target name="get-webservices" unless="axis.servicesname">
2118    <input addproperty="axis.servicesname" defaultvalue="${base.webservice.name}">Which set of web services do you want to deploy?
2119Choose from: ${web.services.list}
2120Or press Enter for default:${base.webservice.name} /&gt;</input>
2121    <echo>${axis.servicesname}</echo>
2122  </target>
2123
2124  <target name="get-siteuri" depends="get-sitename,get-webservices" unless="axis.siteuri">
2125    <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>
2126    <echo>Site: ${axis.sitename}, services: ${axis.servicesname}, servicesname: ${axis.siteuri}</echo>
2127  </target>
2128
2129  <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">
2130   <condition property="soap.method" value="provider='java:MSG' style='message' use='literal'">
2131      <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
2132    </condition>
2133   
2134   <!--everything else defaults to java:RPC at present-->
2135   <condition property="soap.method" value="provider='java:RPC'">
2136     <not>
2137      <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
2138    </not>
2139    </condition>
2140  </target>
2141   
2142  <target name="create-deployment-files" depends="set-soapmethod" if="axis.sitename">
2143    <filter token="sitename" value="${axis.sitename}"/>
2144    <filter token="siteuri" value="${axis.siteuri}"/>
2145    <filter token="servicesname" value="${axis.servicesname}"/>
2146    <filter token="soapmethod" value="${soap.method}"/>
2147    <copy file="${basedir}/resources/soap/site.wsdd.template"
2148      tofile="${basedir}/resources/soap/deploy.wsdd"
2149      filtering="true"
2150      overwrite="true"/>
2151    <!-- create the java files and compile them -->
2152    <copy file="${basedir}/resources/java/${axis.servicesname}.java.in"
2153      tofile="${src.gsdl3.home}/${axis.servicesname}${axis.sitename}.java"
2154      filtering="true"
2155      overwrite="true"/>
2156    <mkdir dir="${build.home}"/>
2157    <javac srcdir="${src.home}"
2158      destdir="${build.home}"
2159      includeantruntime="${compile.includeantruntime}"
2160      debug="${compile.debug}"
2161      deprecation="${compile.deprecation}"
2162      optimize="${compile.optimize}"
2163      encoding="${compile.encoding}">
2164      <classpath refid="compile.classpath"/>
2165      <include name="org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.java" />
2166    </javac>
2167    <mkdir dir="${web.classes}/org/greenstone/gsdl3"/>
2168    <copy file="${build.home}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
2169      tofile="${web.classes}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
2170      overwrite="true" />
2171  </target>
2172 
2173
2174  <!-- ====================== Core targets ============================== -->
2175  <!-- core targets refer to the core gsdl3 java src -->
2176 
2177  <target name="prepare-core"/>
2178 
2179  <target name="configure-core"/>
2180
2181  <target name="update-core" depends="init,svnupdate-core,clean-core,compile-core"
2182    description="Update only the Greenstone core" />
2183 
2184  <target name="svnupdate-core" unless="nosvn.mode">
2185    <exec executable="svn">
2186      <arg value="update"/>
2187      <arg value="${basedir}"/>
2188      <arg value="-r"/><arg value="${branch.revision}"/>
2189    </exec>
2190  </target>
2191
2192  <target name="clean-core"
2193    description="Clean only the Greenstone core">
2194    <!-- should this delete the gsdl3.jar from web/WEB-INF?? -->
2195    <delete dir="${build.home}"/>
2196  </target>
2197
2198  <target name="compile-core" depends="init"
2199    description="Compile only the Greenstone core">
2200    <mkdir dir="${build.home}"/>
2201   
2202    <if><bool><isset property="with.jni"/></bool>
2203    <javac srcdir="${src.home}"
2204           destdir="${build.home}"
2205           includeantruntime="${compile.includeantruntime}"
2206           debug="${compile.debug}"
2207           deprecation="${compile.deprecation}"
2208           optimize="${compile.optimize}"
2209           encoding="${compile.encoding}">
2210      <classpath>
2211            <path refid="compile.classpath"/>
2212      </classpath>
2213    </javac>
2214    <else>
2215      <property name="gsprefix" value=""/>   
2216      <javac srcdir="${src.home}"
2217         destdir="${build.home}"
2218         includeantruntime="${compile.includeantruntime}"
2219         debug="${compile.debug}"
2220         deprecation="${compile.deprecation}"
2221         optimize="${compile.optimize}"
2222         encoding="${compile.encoding}">
2223        <classpath>
2224              <path refid="compile.classpath"/>
2225        </classpath>
2226        <exclude name="org/greenstone/gsdl3/service/GS2MGPPRetrieve.java"/>
2227        <exclude name="org/greenstone/gsdl3/service/GS2MGPPSearch.java"/>
2228        <exclude name="org/greenstone/gsdl3/service/GS2MGSearch.java"/>
2229        <exclude name="org/greenstone/gsdl3/service/GS2MGRetrieve.java"/>
2230        <exclude name="org/greenstone/gsdl3/service/GoogleNgramMGPPSearch.java"/>
2231        <exclude name="org/greenstone/gsdl3/service/PhindPhraseBrowse.java"/>
2232        <exclude name="org/greenstone/gsdl3/util/GDBMWrapper.java"/>
2233      </javac>
2234    </else>
2235    </if>
2236    <jar destfile="${build.home}/gsdl3.jar">
2237      <fileset dir="${build.home}">
2238        <include name="org/greenstone/gsdl3/**"/>
2239        <include name="org/flax/**"/>
2240        <exclude name="**/Test.class"/>
2241      </fileset>
2242      <manifest>
2243        <attribute name="Built-By" value="${user.name}" />
2244      </manifest>
2245    </jar>
2246    <copy file="${build.home}/gsdl3.jar" todir="${web.lib}"/>
2247
2248    <jar destfile="${build.home}/gutil.jar">
2249      <fileset dir="${build.home}">
2250        <include name="org/greenstone/util/**"/>
2251      </fileset>
2252      <manifest>
2253        <attribute name="Built-By" value="${user.name}" />
2254      </manifest>
2255    </jar>
2256    <copy file="${build.home}/gutil.jar" todir="${web.lib}"/>
2257
2258    <!-- copy the localsite server in case we need it -->
2259    <copy file="${build.home}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" tofile="${web.classes}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" />
2260
2261    <!-- Greenstone Administrator Interface -->
2262    <jar destfile="${build.home}/GAI.jar">
2263      <fileset dir="${build.home}">
2264        <include name="org/greenstone/admin/**"/>
2265      </fileset>
2266      <manifest>
2267        <attribute name="Built-By" value="${user.name}" />
2268      </manifest>
2269    </jar>
2270    <copy file="${build.home}/GAI.jar" todir="${web.lib}"/>
2271    <copy file="${build.home}/GAI.jar" todir="${admin.dir}"/>
2272    <jar destfile="${build.home}/phind.jar">
2273      <fileset dir="${build.home}">
2274        <include name="org/greenstone/applet/phind/**"/>
2275      </fileset>
2276      <manifest>
2277        <attribute name="Built-By" value="${user.name}" />
2278      </manifest>
2279    </jar>
2280    <mkdir dir="${web.applet}"/>
2281    <copy file="${build.home}/phind.jar" todir="${web.applet}"/>
2282    <!-- phind also needs xercesImpl.jar and xml-apis.jar to be in web/applet -->
2283    <if>
2284      <bool><istrue value="${tomcat.islocal}"/></bool>
2285      <if><bool><available file="${catalina.home}/lib/xercesImpl.jar"/></bool><!-- moved for solr -->
2286    <copy file="${catalina.home}/lib/xercesImpl.jar" todir="${web.applet}"/>
2287    <copy file="${catalina.home}/lib/xml-apis.jar" todir="${web.applet}"/>
2288   
2289    <else><!-- get from default GS3 web lib location-->
2290      <copy file="${web.lib}/xercesImpl.jar" todir="${web.applet}"/>
2291      <copy file="${web.lib}/xml-apis.jar" todir="${web.applet}"/>
2292    </else>
2293      </if>
2294    </if>
2295
2296
2297    <!-- skip anttasks for now
2298    <jar destfile="${build.home}/anttasks.jar">
2299      <fileset dir="${build.home}">
2300        <include name="org/greenstone/anttasks/**"/>
2301      </fileset>
2302      <manifest>
2303        <attribute name="Built-By" value="${user.name}" />
2304      </manifest>
2305    </jar>
2306    <copy file="${build.home}/anttasks.jar" todir="${basedir}/lib/java"/>-->
2307    <jar destfile="${build.home}/gsdl3test.jar">
2308      <fileset dir="${build.home}">
2309        <include name="org/greenstone/gsdl3/**/*Test.class"/>
2310        <include name="org/greenstone/testing/**"/>
2311      </fileset>
2312      <manifest>
2313        <attribute name="Built-By" value="${user.name}" />
2314      </manifest>
2315    </jar>
2316    <jar destfile="${build.home}/server.jar">
2317      <fileset dir="${build.home}">
2318        <include name="org/greenstone/server/**"/>
2319        <include name="org/greenstone/util/**"/>
2320      </fileset>
2321      <fileset file="${basedir}/resources/java/server.properties"/>
2322      <manifest>
2323        <attribute name="Built-By" value="${user.name}"/>
2324      </manifest>
2325    </jar>
2326    <copy file="${build.home}/server.jar" todir="${basedir}"/>
2327  </target>
2328
2329  <!-- === Eclipse targets == -->
2330  <target name="setup-for-eclipse">
2331
2332    <filter token="gsdlhome" value="${gs2build.home}"/>
2333    <filter token="gsdl3srchome" value="${basedir}"/>
2334    <filter token="gsdl3home" value="${basedir}/web"/>
2335
2336    <if>
2337      <bool><not><available file="${basedir}/TransformingLibrary.launch"/></not></bool>         
2338      <copy file="${basedir}/TransformingLibrary.launch.in" tofile="${basedir}/TransformingLibrary.launch" filtering="true" overwrite="true"/>
2339    </if>
2340<!--
2341    <if>
2342      <bool><not><available file="${basedir}/LibraryCommandline.launch"/></not></bool>         
2343      <copy file="${basedir}/LibraryCommandline.launch.in" tofile="${basedir}/LibraryCommandline.launch" filtering="true" overwrite="true"/>
2344    </if>
2345-->
2346  </target>
2347 
2348  <!-- ================== Packages targets ================================ -->
2349  <!-- these targets refer to the greenstone source packages - these need
2350  updating less often, so are in  separate targets to the core -->
2351  <target name="prepare-packages" depends="init"/>
2352 
2353  <target name="update-packages" depends="init,svnupdate-packages,configure-packages,clean-packages,compile-packages"
2354    description="Update only the source packages"/>
2355
2356  <target name="svnupdate-packages" unless="nosvn.mode">
2357    <exec executable="svn">
2358      <arg value="update"/>
2359      <arg value="${src.packages.home}"/>
2360      <arg value="-r"/><arg value="${branch.revision}"/>
2361    </exec>
2362  </target>
2363
2364 
2365  <target name="configure-packages" depends="init,configure-javagdbm"
2366    description="Configure only the packages."/>
2367 
2368  <target name="configure-javagdbm" if="with.jni">
2369    <echo>
2370      Configuring JavaGDBM
2371    </echo>
2372   
2373    <exec executable="${javagdbm.home}/configure" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
2374      <arg value="--prefix=${basedir}"/>
2375      <arg value="--libdir=${lib.jni}"/>
2376      <arg value="--with-gdbm=${gdbm.home}"/>
2377      <arg line="${cross.configure.args}"/>
2378    </exec>   
2379  </target>
2380
2381  <target name="clean-packages" depends="init,clean-javagdbm" description="Clean only the packages"/>
2382
2383  <target name="clean-javagdbm" depends="init">
2384    <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
2385    <exec executable="make" os="${os.unix}"
2386      dir="${javagdbm.home}" failonerror="true">
2387      <arg value="clean"/>
2388    </exec>
2389    </if>
2390  </target>
2391 
2392  <target name="distclean-packages" depends="init,distclean-javagdbm" description="Distclean only the packages"/>
2393
2394  <target name="distclean-javagdbm" depends="init">
2395    <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
2396    <exec executable="make" os="${os.unix}"
2397      dir="${javagdbm.home}" failonerror="true">
2398      <arg value="distclean"/>
2399    </exec>
2400    </if>
2401  </target>
2402 
2403  <target name="compile-packages" description="Compile only the source packages">
2404    <!-- javagdbm -->
2405    <antcall target="compile-javagdbm"/>
2406    <!-- Search4j -->
2407    <antcall target="compile-search4j"/>
2408  </target>
2409
2410  <target name="compile-javagdbm" description="Compile JavaGDBM" if="with.jni">
2411   
2412    <!-- unix: -->
2413    <echo>compile javagdbm</echo>
2414    <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
2415      <arg value="JAVACOPTIONS=-encoding UTF8"/>
2416    </exec>
2417    <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
2418      <arg value="install"/>
2419    </exec>
2420
2421    <!-- windows: Calling without the "compile" argument first will run winMake.bat with
2422         "all" which will then perform both the compile AND link targets in jni/win32.mak
2423         (thereby also generating gdbmjava.dll). Then we run the same command with
2424         the "install" argument to copy the gdbmjava.dll into the correct location. -->
2425    <echo>Windows: compile javagdbm</echo>
2426    <exec executable="${javagdbm.home}/winMake.bat" osfamily="windows" dir="${javagdbm.home}" failonerror="true">     
2427      <env key="GSDL3SRCHOME" path="${basedir}"/>
2428    </exec>
2429    <exec executable="${javagdbm.home}/winMake.bat" osfamily="windows" dir="${javagdbm.home}" failonerror="true">
2430      <env key="GSDL3SRCHOME" path="${basedir}"/>
2431      <arg value="install"/>
2432    </exec>
2433
2434    <!-- install the jar file -->
2435    <echo>Install the javagdbm jar file ${javagdbm.home}/javagdbm.jar ${lib.jni}</echo>
2436    <copy file="${javagdbm.home}/javagdbm.jar" todir="${lib.jni}"/>
2437  </target>
2438
2439  <target name="compile-search4j">
2440
2441    <!-- windows -->
2442    <if><bool><istrue value="${current.os.iswindows}"/></bool>
2443      <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
2444        <arg value="/f"/>
2445        <arg value="win32.mak"/>
2446        <arg value='BINDIR="${basedir}\bin"'/>
2447      </exec>
2448      <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
2449        <arg value="/f"/>
2450        <arg value="win32.mak"/>
2451        <arg value="install"/>
2452        <arg value='BINDIR="${basedir}\bin"'/>
2453      </exec>
2454
2455    <!-- unix -->
2456    <else><if><bool><istrue value="${current.os.isunix}"/></bool>
2457      <exec executable="${src.packages.home}/search4j/configure" dir="${src.packages.home}/search4j" failonerror="true">
2458        <arg value="--bindir=${basedir}/bin"/>
2459        <arg value="${static.arg}"/>
2460        <arg line="${cross.configure.args}"/>
2461      </exec>
2462      <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true"/>
2463      <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true">
2464        <arg value="install"/>
2465      </exec>
2466
2467    <!-- else warn -->
2468    <else>
2469      <fail>this target does not support the current os</fail>
2470
2471    </else></if></else></if>
2472
2473  </target>
2474
2475  <target name="install-auxiliary-jar-files" depends="init">
2476
2477    <if>
2478      <bool><available file="${mg.home}/mg.jar"/></bool>
2479      <copy file="${mg.home}/mg.jar" todir="${lib.jni}"/>
2480    </if>
2481
2482    <if>
2483      <bool><available file="${mgpp.home}/mgpp.jar"/></bool>
2484      <copy file="${mgpp.home}/mgpp.jar" todir="${lib.jni}"/>
2485    </if>
2486
2487    <copy file="${lucene.home}/LuceneWrapper4.jar" todir="${web.lib}"/>   
2488  </target>
2489 
2490  <target name="install-jni-files" depends="init" if="with.jni">
2491    <antcall target="install-jni-files-linux"/>
2492    <antcall target="install-jni-files-windows"/>
2493    <antcall target="install-jni-files-macos"/>
2494  </target>
2495
2496  <target name="install-jni-files-linux" depends="init" if="current.os.isunixnotmac">
2497
2498    <if>
2499
2500      <bool><equals arg1="${os.bin.dir}" arg2="windows"/></bool>
2501      <!-- cross compiling to windows -->
2502      <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
2503      <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
2504      <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
2505      <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
2506      <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
2507      <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
2508     
2509      <else>
2510    <!-- otherwise do the usual Unix copies -->
2511    <copy file="${mg.home}/jni/libmgretrievejni.so" todir="${lib.jni}"/>
2512    <copy file="${mg.home}/jni/libmgsearchjni.so" todir="${lib.jni}"/>
2513    <copy file="${mg.home}/jni/libmgpassjni.so" todir="${lib.jni}"/>
2514    <copy file="${mgpp.home}/jni/libmgppretrievejni.so" todir="${lib.jni}"/>
2515    <copy file="${mgpp.home}/jni/libmgppsearchjni.so" todir="${lib.jni}"/>
2516    <copy file="${mgpp.home}/jni/libmgpppassjni.so" todir="${lib.jni}"/>
2517      </else>
2518    </if>
2519
2520
2521  </target>
2522  <target name="install-jni-files-windows" depends="init" if="current.os.iswindows">
2523    <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
2524    <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
2525    <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
2526    <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
2527    <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
2528    <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
2529  </target>
2530  <target name="install-jni-files-macos" depends="init" if="current.os.ismac">
2531    <copy file="${mg.home}/jni/libmgretrievejni.jnilib" todir="${lib.jni}"/>
2532    <copy file="${mg.home}/jni/libmgsearchjni.jnilib" todir="${lib.jni}"/>
2533    <copy file="${mg.home}/jni/libmgpassjni.jnilib" todir="${lib.jni}"/>
2534    <copy file="${mgpp.home}/jni/libmgppretrievejni.jnilib" todir="${lib.jni}"/>
2535    <copy file="${mgpp.home}/jni/libmgppsearchjni.jnilib" todir="${lib.jni}"/>
2536    <copy file="${mgpp.home}/jni/libmgpppassjni.jnilib" todir="${lib.jni}"/>
2537  </target>
2538 
2539  <!-- ========common-src targets =================================-->
2540  <!-- these are used to get common-src (for indexers, gdbm, sqlite etc) when
2541  collection building is not enabled -->
2542
2543  <target name="update-common-src" depends="init" if="collection.building.disabled">
2544  </target>
2545
2546  <target name="svnupdate-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
2547    <exec executable="svn">
2548      <arg value="update"/>
2549      <arg value="${common.src.home}"/>
2550      <arg value="-r"/><arg value="${branch.revision}"/>
2551    </exec>
2552  </target>
2553
2554  <target name="prepare-common-src" depends="init" if="collection.building.disabled" unless="common.src.present">
2555    <antcall target="checkout-common-src"/>
2556    <antcall target="unzip-windows-packages"/>
2557  </target>
2558
2559  <target name="checkout-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
2560    <echo>checking out common-src</echo>
2561    <exec executable="svn">
2562      <arg value="checkout"/>
2563      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src"/>
2564            <arg value="common-src"/>
2565      <arg value="-r"/><arg value="${branch.revision}"/>
2566    </exec>
2567  </target>
2568   
2569  <target name="configure-common-src" depends="init">
2570<!--
2571    <echo>cross configure args: ${cross.configure.args}</echo>
2572-->
2573    <exec executable="${common.src.home}/configure" os="${os.unix}"
2574      dir="${common.src.home}" failonerror="true">
2575      <arg value="--prefix=${gs2build.home}"/> <!-- what value to use?? -->
2576      <arg value="--bindir=${gs2build.home}/bin/${os.bin.dir}"/> <!-- what value to use?? -->
2577      <arg line="${gs2.opt.args}"/>
2578      <arg line="${static.arg}"/>
2579      <arg line="${cross.configure.args}"/>
2580      <arg line="${allargs}"/>
2581    </exec>
2582  </target>
2583
2584  <target name="clean-common-src" depends="init">
2585    <!-- unix:  -->
2586    <if><bool><available file="${common.src.home}/Makefile"/></bool>
2587    <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2588      <arg value="clean"/>
2589    </exec>
2590    </if>
2591    <!-- windows: -->   
2592    <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
2593      <arg value="/f"/>
2594      <arg value="win32.mak"/>
2595      <arg value="clean"/>
2596      <arg value="GSDLHOME=${gs2build.home}"/>
2597    </exec>
2598  </target>
2599  <target name="distclean-common-src" depends="init">
2600    <!-- unix:  -->
2601    <if><bool><available file="${common.src.home}/Makefile"/></bool>
2602    <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2603      <arg value="distclean"/>
2604    </exec>
2605    </if>
2606    <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->   
2607    <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
2608      <arg value="/f"/>
2609      <arg value="win32.mak"/>
2610      <arg value="clean"/>
2611      <arg value="GSDLHOME=${gs2build.home}"/>
2612    </exec>
2613  </target>
2614  <target name="compile-common-src" depends="init">
2615    <!-- unix: -->
2616    <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2617      <arg value="${gs2.compile.target}"/>
2618    </exec>
2619    <!-- windows: -->
2620    <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
2621      <arg value="/f"/>
2622      <arg value="win32.mak"/>
2623      <arg value="GSDLHOME=${gs2build.home}"/>
2624      <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
2625      <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
2626      <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
2627      <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
2628      <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
2629    </exec>
2630  </target>
2631 
2632  <!-- ======= collection-building targets ===========================-->
2633
2634  <target name="update-collection-building" if="collection.building.enabled"
2635    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"
2636    description="Update (SVN update, configure, compile etc) only the collection building components"/>
2637
2638  <target name="svnupdate-collection-building" if="collection.building.enabled" depends="init,svnupdate-gs2build,svnupdate-cgi,svnupdate-gli" unless="nosvn.mode"
2639    description="SVN update the collection building components">
2640  </target>
2641
2642  <target name="prepare-collection-building" depends="init,prepare-gs2build,svnupdate-cgi,prepare-gli" if="collection.building.enabled">
2643  </target>
2644
2645  <target name="configure-collection-building" depends="init,configure-build-src" if="collection.building.enabled"
2646    description="Configure the collection building components">
2647  </target>
2648
2649  <target name="clean-collection-building" depends="init,clean-gli,clean-build-src"
2650    description="Clean only the collection building components"
2651    if="collection.building.enabled"/>
2652
2653  <target name="distclean-collection-building" depends="init,clean-build-src,distclean-build-src"
2654    description="Distclean only the collection building components"
2655    if="collection.building.enabled"/>
2656
2657  <target name="compile-collection-building" depends="init,compile-build-src,compile-gli" if="collection.building.enabled"
2658    description="Compile only the collection building components">
2659    <!-- make install for common-src -->
2660    <!-- unix: -->
2661    <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2662      <arg value="${gs2.install.target}"/>
2663    </exec>
2664     
2665    <!-- windows: -->
2666    <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
2667      <arg value="/f"/>
2668      <arg value="win32.mak"/>
2669      <arg value="install"/>
2670      <arg value="GSDLHOME=${gs2build.home}"/>
2671      <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
2672      <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
2673      <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
2674      <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
2675      <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
2676      <!--
2677      <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
2678      <arg value="USE_SQLITE=0"/>--> <!-- why is this not on by default? -->
2679    </exec>
2680
2681    <!-- install gs2build indexers for windows -->
2682      <if>
2683    <bool><istrue value="${current.os.iswindows}"/></bool>
2684    <copy todir="${gs2build.home}/bin/windows">
2685      <fileset dir="${gs2build.home}/common-src/indexers/bin">
2686        <include name="*.*"/>
2687      </fileset>
2688    </copy>
2689      </if>
2690
2691    <!-- LuceneWrapper jar file not installed by default -->
2692    <mkdir dir="${gs2build.home}/bin/java"/>
2693    <copy file="${lucene.home}/LuceneWrapper4.jar" todir="${gs2build.home}/bin/java"/>
2694
2695  </target>
2696
2697  <!-- ============== gli targets ================================= -->
2698 
2699  <!-- gliserver.pl, gsdlCGI.pm, metadata-server.pl and checksum.pl are updated alongside
2700       this in target svnupdate-collection-building -->
2701  <target name="svnupdate-gli" if="collection.building.enabled" depends="init" unless="nosvn.mode">
2702
2703    <exec executable="svn">
2704      <arg value="update"/>
2705      <arg value="${gli.home}"/>
2706      <arg value="-r"/><arg value="${branch.revision}"/>
2707    </exec>
2708
2709  </target>
2710
2711  <!-- gliserver.pl, gsdlCGI.pm, metadata-server.pl and checksum.pl are updated
2712       alongside this prepare-gli target in target prepare-collection-building -->
2713  <target name="prepare-gli" depends="init" if="collection.building.enabled" unless="gli.present">
2714    <!-- checkout -->
2715    <if><bool><and><not><istrue value="${nosvn.mode}"/></not><isset property="with.gli.and.gems"/></and></bool>
2716
2717    <exec executable="svn">
2718      <arg value="checkout"/>
2719      <arg value="${svn.root}/main/${branch.path}/gli"/>
2720      <arg value="-r"/><arg value="${branch.revision}"/>
2721    </exec>
2722
2723    </if>
2724  </target>
2725
2726  <!-- svn checkout gliserver.pl, gsdlCGI.pm for gli applet, as well as gsdlCGI.pm-dependent metadata-server.pl
2727       (checksum.pl is used by GS2 for depositdspace.dm and may eventually be used by GS3 too) -->
2728  <target name="svnupdate-cgi">
2729
2730    <exec executable="svn" dir="web/WEB-INF/cgi">
2731      <arg value="export"/>
2732      <arg value="-r"/><arg value="${branch.revision}"/>
2733      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/gliserver.pl"/>
2734    </exec>
2735    <exec executable="svn" dir="web/WEB-INF/cgi">
2736      <arg value="export"/>
2737      <arg value="-r"/><arg value="${branch.revision}"/>
2738      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/gsdlCGI.pm"/>
2739    </exec>
2740    <exec executable="svn" dir="web/WEB-INF/cgi">
2741      <arg value="export"/>
2742      <arg value="-r"/><arg value="${branch.revision}"/>
2743      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/metadata-server.pl"/>
2744    </exec>
2745    <exec executable="svn" dir="web/WEB-INF/cgi">
2746      <arg value="export"/>
2747      <arg value="-r"/><arg value="${branch.revision}"/>
2748      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/checksum.pl"/>
2749    </exec>
2750  </target>
2751
2752 
2753  <target name="clean-gli" depends="init" if="collection.building.enabled">
2754    <!-- gli -->
2755    <property name="gli.home" value="${basedir}/gli"/>
2756    <!-- linux -->
2757    <exec executable="clean.sh" os="${os.unix}" dir="${gli.home}"
2758      resolveExecutable="true" failonerror="true"/>
2759    <!-- windows -->
2760    <exec executable="clean.bat" osfamily="windows" dir="${gli.home}"
2761      resolveExecutable="true" failonerror="true"/>
2762  </target>
2763 
2764  <target name="compile-gli" depends="init" if="collection.building.enabled">
2765    <if><bool><isset property="with.gli.and.gems"/></bool>
2766      <!-- gli -->
2767      <property name="gli.home" value="${basedir}/gli"/>
2768
2769      <!-- linux -->
2770      <exec executable="makegli.sh" os="${os.unix}" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
2771      <!--remote gli-->
2772      <exec executable="makejar.sh" os="${os.unix}" dir="${gli.home}"
2773        resolveExecutable="true" failonerror="true"/>
2774      <!-- windows -->
2775      <exec executable="makegli.bat" osfamily="windows" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
2776      <!--remote gli-->
2777      <exec executable="makejar.bat" osfamily="windows" dir="${gli.home}"
2778        resolveExecutable="true" failonerror="true"/>
2779      <copy file="${gli.home}/GLIServer.jar" todir="${gs2build.home}/bin/java" />
2780    </if>
2781  </target>
2782
2783  <target name="gli" description="Run the Greenstone Librarian Interface" depends="init" if="collection.building.enabled">
2784    <exec executable="${basedir}/gli/gli.sh" os="${os.linux},${os.solaris}" dir="${basedir}/gli" spawn="true">
2785      <env key="gsdl3path" path="${basedir}"/>
2786      <env key="gsdlpath" path="${gs2build.home}"/>
2787    </exec>
2788    <exec executable="${basedir}/gli/gli.sh" os="${os.mac}" dir="${basedir}/gli" spawn="true">
2789      <env key="gsdl3path" path="${basedir}"/>
2790      <env key="gsdlpath" path="${gs2build.home}"/>
2791      <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${gdbm.home}/lib"/>
2792    </exec>
2793    <exec executable="${basedir}/gli/gli.bat" osfamily="windows" dir="${basedir}/gli" spawn="true">
2794      <env key="GSDL3PATH" path="${basedir}"/>
2795      <env key="GSDLPATH" path="${gs2build.home}"/>
2796    </exec>
2797    <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.
2798    </echo>
2799  </target>
2800
2801  <!-- ================ gs2build targets =========================== -->
2802
2803  <target name="svnupdate-gs2build" if="collection.building.enabled" depends="init" unless="nosvn.mode">
2804    <echo>svn updating gs2build</echo>
2805    <exec executable="svn">
2806      <arg value="update"/>
2807      <arg value="${gs2build.home}"/>
2808      <arg value="-r"/><arg value="${branch.revision}"/>
2809    </exec>
2810  </target>
2811   
2812  <target name="prepare-gs2build" depends="init" if="collection.building.enabled" unless="gs2build.present">
2813    <antcall target="checkout-gs2build"/>
2814    <antcall target="prepare-pdfbox"/>
2815    <antcall target="prepare-imagemagick"/> <!-- has to be done before calling prepare-gnome-lib -->
2816    <antcall target="prepare-gnome-lib"/>
2817    <antcall target="unzip-windows-packages"/>
2818    <antcall target="checkout-winbin"/>
2819    <antcall target="get-windows-binaries"/>
2820    <antcall target="delete-winbin"/>
2821  </target>
2822
2823  <target name="checkout-gs2build" depends="init" if="collection.building.enabled" unless="nosvn.mode">
2824    <echo>checking out gs2build</echo>
2825    <exec executable="svn">
2826      <arg value="checkout"/>
2827      <arg value="${svn.root}/main/${branch.path}/gs2build"/>
2828      <arg value="-r"/><arg value="${branch.revision}"/>
2829    </exec>
2830  </target>
2831
2832  <!-- Gets the PDFBox extension into gs2build/ext if checkout.pdfbox.ext is set to true in build.properties
2833       (which it is by default) -->
2834  <target name="prepare-pdfbox" depends="init" if="collection.building.enabled">
2835    <if>
2836      <bool>
2837    <istrue value="${checkout.pdfbox.ext}"/>
2838      </bool>
2839     
2840      <property name="pdfbox.ext.dir" value="${gs2build.home}/ext/pdf-box"/>
2841      <condition property="pdfbox.ext.present">
2842    <available file="${pdfbox.ext.dir}" type="dir" />
2843      </condition>
2844     
2845      <!-- 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-->
2846      <if>
2847    <bool>
2848      <not><istrue value="${pdfbox.ext.present}"/></not>
2849    </bool>
2850
2851    <if>
2852      <bool>
2853        <not><istrue value="${gs2build.home}/ext/pdf-box-java.tar.gz"/></not>
2854      </bool>
2855
2856      <echo>Checking out the PDFBox extension into the GSDLHOME extension area</echo>
2857      <exec executable="svn">
2858        <arg value="export"/>
2859        <arg value="${svn.root}/gs2-extensions/pdf-box/trunk/pdf-box-java.tar.gz"/>
2860        <arg value="${gs2build.home}/ext/pdf-box-java.tar.gz"/>
2861      </exec>
2862    </if>   
2863
2864    <echo>Extacting the PDFBox extension into the GSDLHOME extension area</echo>
2865    <untar compression="gzip"
2866           src="${gs2build.home}/ext/pdf-box-java.tar.gz"
2867           dest="${gs2build.home}/ext"/>
2868
2869    <delete file="${gs2build.home}/ext/pdf-box-java.tar.gz"/>
2870
2871    <else>
2872      <echo>The PDFBox extension already exists at ${pdfbox.ext.dir}</echo>
2873    </else>
2874      </if>
2875
2876      <else>
2877    <echo>**** Not preparing the PDFBox extension:</echo>
2878    <echo>The property checkout.pdfbox.ext in build.properties was not set or was set to false</echo>
2879      </else>
2880    </if>
2881  </target>
2882
2883  <target name="prepare-imagemagick" depends="init" if="collection.building.enabled">
2884    <if>
2885      <bool>
2886    <istrue value="${checkout.imagemagick.ext}"/>
2887      </bool>
2888
2889      <antcall target="checkout-imagemagick"/>
2890      <!--Compilation of imagemagick now happens during ant install, still before configuring the src code, as before -->
2891
2892      <else>
2893    <echo>**** Not preparing imagemagick:</echo>
2894    <echo>property checkout.imagemagick.ext in build.properties was not set or was set to false</echo>
2895      </else>
2896    </if>
2897  </target>
2898
2899  <target name="checkout-imagemagick" depends="init" if="collection.building.enabled" unless="nosvn.mode">
2900   
2901    <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
2902    <condition property="imagemagick.src.present">
2903      <available file="${imagemagick.src.dir}" type="dir" />
2904    </condition>
2905
2906    <if>
2907      <bool>
2908    <not><istrue value="${imagemagick.src.present}"/></not>
2909      </bool>
2910     
2911      <echo>checking out imagemagick source into the extension area</echo>
2912
2913      <exec executable="svn">
2914    <arg value="checkout"/>
2915    <arg value="${svn.root}/gs2-extensions/imagemagick/trunk/src"/>
2916    <arg value="${imagemagick.src.dir}"/>
2917      </exec>
2918
2919      <else>
2920    <echo>imagemagick source code already exists at ${imagemagick.src.dir}</echo>
2921      </else>
2922    </if>
2923  </target>
2924
2925 <!-- 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. -->
2926  <target name="compile-imagemagick" if="checkout.imagemagick.ext">
2927   
2928    <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
2929    <property name="imagemagick.compiled.dir" value="${gs2build.home}/ext/imagemagick/${os.bin.dir}"/>
2930
2931    <condition property="imagemagick.src.present.firstcheck">
2932      <available file="${imagemagick.src.dir}" type="dir" />
2933    </condition>
2934    <condition property="imagemagick.compiled.present">
2935      <available file="${imagemagick.compiled.dir}" type="dir"/>
2936    </condition>
2937    <!--<condition property="imagemagick.bin.present">
2938      <available file="${basedir}/wherever/the/imgmagick/binary/is/to/be/found" type="dir" />
2939    </condition>-->
2940
2941    <!-- imagemagick will only be checked out if the user set the checkout.imagemagick.ext in build.properties -->
2942    <if>
2943      <bool>
2944    <isfalse value="${imagemagick.src.present.firstcheck}"/>
2945      </bool>
2946      <antcall target="checkout-imagemagick"/>
2947    </if>
2948
2949    <!-- keep track of whether the imagemagick src is now indeed present. Need to know this for a subsequent test -->
2950    <condition property="imagemagick.src.present">
2951      <available file="${imagemagick.src.dir}" type="dir" />
2952    </condition>
2953
2954    <if>
2955      <bool>
2956    <and>
2957      <istrue value="${imagemagick.src.present}"/> <!-- imagemagick src code is present -->
2958      <isfalse value="${imagemagick.compiled.present}"/> <!-- imagemagick src not compiled yet, so no imagemagick/os subfolder yet -->
2959    </and>
2960      </bool>
2961      <!-- then compile it. Only necessary for mac/linux, since windows has a stable working binary of imagemagick -->
2962      <exec executable="/bin/bash" dir="${imagemagick.src.dir}" failonerror="true">
2963        <arg value="CASCADE-MAKE.sh"/>
2964      </exec> 
2965    </if>
2966  </target>
2967
2968
2969  <!-- Compile up gnome-lib src folder if: checkout.gnomelib.ext is turned on, and if not using the binary
2970       version (gnome-lib-minimal), and if the gnome-lib src folder is not already compiled up. -->
2971  <target name="compile-gnome-lib" if="checkout.gnomelib.ext">
2972
2973    <!-- http://stackoverflow.com/questions/3290307/sourcing-a-shell-profile-in-an-ant-build-file
2974     TODO: CASCADE-MAKE already sources devel.bash, but we still want to source it more globally,
2975     so that the rest of the GS3 compilation process also has access to those env variables -->
2976   
2977    <property name="gnome.lib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
2978    <property name="gnome.lib.compiled.dir" value="${basedir}/gs2build/ext/gnome-lib/${os.bin.dir}"/>
2979
2980    <condition property="gnome.src.lib.present.firstcheck" value="true" else="false">
2981      <available file="${gnome.lib.src.dir}" type="dir" />
2982    </condition>
2983    <condition property="gnome.compiled.lib.present" value="true" else="false">
2984      <available file="${gnome.lib.compiled.dir}" type="dir"/>
2985    </condition>
2986    <condition property="gnome.lib.min.present" value="true" else="false">
2987      <available file="${basedir}/gs2build/ext/gnome-lib-minimal" type="dir" />
2988    </condition>
2989
2990    <!-- Make sure to checkout gnome-lib if it was not checked out at this stage
2991     since we're instructed to do so in th pre-condition to this target -->
2992    <if>
2993      <bool>
2994    <and>
2995      <isfalse value="${gnome.lib.min.present}"/>
2996      <isfalse value="${gnome.src.lib.present.firstcheck}"/>
2997    </and>
2998      </bool>
2999      <antcall target="checkout-gnome-lib"/>
3000    </if>
3001
3002    <!-- Keep track of whether we have the gnome-lib src folder now. Need to know this for a subsequent test -->
3003    <condition property="gnome.src.lib.present" value="true" else="false">
3004      <available file="${gnome.lib.src.dir}" type="dir" />
3005    </condition>
3006
3007    <!--<echo>MIN: ${gnome.lib.min.present}
3008      SRC LIB: ${gnome.src.lib.present}
3009      COMPILED: ${gnome.compiled.lib.present}</echo>-->
3010
3011    <if>
3012      <bool>
3013    <and>
3014      <isfalse value="${gnome.lib.min.present}"/> <!-- no gnome-lib-minimal binary present -->
3015      <istrue value="${gnome.src.lib.present}"/> <!-- gnome-lib folder for compilation is present-->
3016      <isfalse value="${gnome.compiled.lib.present}"/> <!-- gnome-lib not yet compiled, so no gnome-lib/os subfolder yet -->
3017    </and>
3018      </bool>
3019
3020      <!-- then compile it. Only necessary for mac/linux, since windows doesn't need gnome lib -->
3021      <exec executable="/bin/bash" dir="${gnome.lib.src.dir}" failonerror="true">
3022        <arg value="CASCADE-MAKE.sh"/>
3023      </exec> 
3024    </if>
3025  </target>
3026
3027
3028  <target name="prepare-gnome-lib" depends="init" if="collection.building.enabled" unless="gnome-lib.present">
3029    <if>
3030      <bool>
3031    <istrue value="${checkout.gnomelib.ext}"/>
3032      </bool>
3033
3034      <antcall target="checkout-gnome-lib"/>
3035      <!--Compilation of gnome-lib happens during ant install, just before configuring (common-src and) build-src-->
3036
3037      <else>
3038    <echo>**** Not preparing gnome-lib:</echo>
3039    <echo>property checkout.gnomelib.ext in build.properties was not set or was set to false</echo>
3040      </else>
3041    </if>
3042  </target>
3043
3044
3045  <target name="checkout-gnome-lib" depends="init" if="collection.building.enabled" unless="nosvn.mode">
3046
3047    <property name="gnomelib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
3048    <condition property="gnome.src.present">
3049      <available file="${gnomelib.src.dir}" type="dir" />
3050    </condition>
3051
3052    <if>
3053      <bool>
3054    <not><istrue value="${gnome.src.present}"/></not>
3055      </bool>
3056
3057      <echo>checking out gnome-lib extension</echo>
3058      <exec executable="svn">
3059    <arg value="checkout"/>
3060    <arg value="${svn.root}/gs2-extensions/gnome-lib/trunk/src"/>
3061    <arg value="${gs2build.home}/ext/gnome-lib"/>
3062      </exec>
3063
3064      <else>
3065    <echo>gnomelib source code already exists at ${gnomelib.src.dir}</echo>
3066      </else>
3067    </if>
3068
3069  </target>
3070
3071  <target name="checkout-winbin" depends="init" if="current.os.iswindows"
3072    unless="nosvn.mode">
3073
3074    <exec executable="svn">
3075      <arg value="checkout"/>
3076      <arg value="${svn.root}/main/${branch.path}/binaries/windows"/>
3077      <arg value="-r"/><arg value="${branch.revision}"/>
3078      <arg value="winbin"/>
3079    </exec>
3080
3081  </target>
3082
3083  <target name="update-winbin" depends="init" if="current.os.iswindows" unless="nosvn.mode">
3084    <exec executable="svn">
3085      <arg value="update"/>
3086      <arg value="winbin"/>
3087      <arg value="-r"/><arg value="${branch.revision}"/>
3088    </exec>
3089
3090  </target>
3091 
3092  <target name="get-windows-binaries" depends="init" if="collection.building.enabled.windows">
3093    <move todir="${gs2build.home}/bin/windows" failonerror="false">
3094      <fileset dir="${basedir}/winbin/bin"/>
3095    </move>
3096  </target>
3097
3098  <target name="delete-winbin" depends="init" if="collection.building.enabled.windows">
3099    <delete dir="${basedir}/winbin"/>
3100  </target>
3101 
3102  <target name="unzip-windows-packages" depends="init" if="current.os.iswindows"> 
3103    <unzip src="${common.src.home}/packages/windows/crypt/crypt.zip"
3104      dest="${common.src.home}/packages/windows/crypt"/>
3105    <untar compression="gzip"
3106      src="${common.src.home}/packages/sqlite/${sqlite.targz.version}"
3107      dest="${common.src.home}/packages/sqlite"/>
3108    <unzip src="${common.src.home}/indexers/packages/windows/iconv/iconv.zip"
3109      dest="${common.src.home}/indexers/packages/windows/iconv"/>
3110  </target>
3111   
3112  <target name="gs2build-edit-setup-bat" if="collection.building.enabled.windows">
3113    <!-- we want a windows path in the setup.bat file -->
3114    <pathconvert targetos="windows" property="gs2build.home.windows">
3115      <path path="${gs2build.home}"/>
3116    </pathconvert>
3117    <move file="${gs2build.home}/setup.bat" tofile="${gs2build.home}/setup-tmp.bat">
3118      <filterset>
3119        <filter token="gsdlhome" value="${gs2build.home.windows}"/>
3120      </filterset>
3121    </move> 
3122    <move file="${gs2build.home}/setup-tmp.bat" tofile="${gs2build.home}/setup.bat" />
3123  </target>
3124 
3125 
3126  <target name="clean-build-src" depends="init" if="collection.building.enabled">
3127    <!-- unix:  -->
3128    <if><bool><available file="${build.src.home}/Makefile"/></bool>
3129    <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
3130      <arg value="clean"/>
3131    </exec>
3132    </if>
3133    <!-- windows: -->   
3134    <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
3135      <arg value="/f"/>
3136      <arg value="win32.mak"/>
3137      <arg value="clean"/>
3138      <arg value="GSDLHOME=${gs2build.home}"/>
3139    </exec>
3140  </target>
3141 
3142 
3143  <target name="distclean-build-src" depends="init,clean-build-src" if="collection.building.enabled">
3144    <!-- unix:  -->
3145    <if><bool><available file="${build.src.home}/Makefile"/></bool>
3146    <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
3147      <arg value="distclean"/>
3148    </exec>
3149    </if>
3150    <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->   
3151    <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
3152      <arg value="/f"/>
3153      <arg value="win32.mak"/>
3154      <arg value="clean"/>
3155      <arg value="GSDLHOME=${gs2build.home}"/>
3156    </exec>
3157  </target>
3158 
3159  <target name="configure-build-src" depends="init" if="collection.building.enabled"
3160    description="Configure the build-src component">
3161    <exec executable="${build.src.home}/configure" os="${os.unix}"
3162      dir="${build.src.home}" failonerror="true">
3163      <arg value="--prefix=${gs2build.home}"/>
3164      <arg line="${gs2.opt.args} ${static.arg} ${cross.configure.args} ${allargs}"/>
3165    </exec>
3166  </target>
3167
3168  <!-- common-src is done separately and needs to be compiled first -->
3169  <target name="compile-build-src" depends="init" if="collection.building.enabled">
3170   
3171    <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
3172        <arg line="${ldlpath.arg}"/>
3173    </exec>
3174   
3175    <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
3176      <arg value="install"/>
3177    </exec>
3178
3179    <!-- run the setup script -->
3180    <!-- <exec executable="${compile.windows.c++.setup}" osfamily="windows" failonerror="true"/>-->
3181      <!--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-->
3182      <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
3183        <arg value="/f"/>
3184        <arg value="win32.mak"/>
3185    <arg value="GSDLHOME=${gs2build.home}"/>
3186      </exec>
3187      <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
3188        <arg value="/f"/>
3189        <arg value="win32.mak"/>
3190        <arg value="install"/>
3191    <arg value="GSDLHOME=${gs2build.home}"/>
3192      </exec>
3193  </target>
3194 
3195
3196  <!-- ======================== TESTING Targets ========================= -->
3197 
3198  <target name="test" description="Run the (incomplete) JUnit test suite "
3199    depends="init">
3200    <mkdir dir="${basedir}/test"/>
3201    <junit printsummary="withOutAndErr"
3202      errorproperty="test.failed"
3203      failureproperty="test.failed"
3204      fork="${junit.fork}">
3205      <formatter type="plain"/>
3206      <classpath>
3207        <pathelement location="${build.home}/gsdl3test.jar"/>
3208        <path refid="compile.classpath"/>
3209      </classpath>
3210      <test name="${testcase}" if="testcase"/>
3211      <batchtest todir="${basedir}/test" unless="testcase">
3212        <fileset dir="${build.home}" includes="**/*Test.class" />
3213      </batchtest>
3214    </junit>
3215    <echo>
3216      *********************************************
3217      Test output can be found in directory 'test'
3218      *********************************************
3219    </echo>
3220  </target>
3221
3222  <!-- ======================== FLAX Targets ========================= -->
3223  <target name="prepare-flax" description="check out flax source code from another repository" if="install.flax">
3224    <echo>checking out flax ...</echo>
3225    <mkdir dir="${basedir}/src/java/org/flax"/>
3226    <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/flax"/>
3227    <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/action/flax"/>
3228    <mkdir dir="${web.home}/WEB-INF/classes/flax"/>
3229    <mkdir dir="${web.home}/interfaces/flax"/>
3230    <mkdir dir="${web.home}/sites/flax"/>
3231    <mkdir dir="${basedir}/flax-resources"/>
3232    <mkdir dir="${basedir}/flax-lib"/>
3233    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/flax"/>
3234      <arg value="src/java/org/flax"/></exec>
3235    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/flax"/>
3236      <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
3237    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/action/flax"/>
3238      <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
3239     <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/WEB-INF/classes/flax"/>
3240      <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
3241    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/interfaces/flax"/>
3242      <arg value="${web.home}/interfaces/flax"/></exec>
3243    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/sites/flax"/>
3244      <arg value="${web.home}/sites/flax"/></exec>
3245    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/flax-resources"/>
3246      <arg value="flax-resources"/></exec>
3247    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/lib"/>
3248      <arg value="flax-lib"/></exec>
3249    <antcall target="flax-copy-del-files" />
3250  </target>
3251 
3252  <target name="flax-copy-del-files" description="copy some flax files into the appropriate greenstone3 directories and delete some unwanted greenstone stuff">
3253    <copy file="${web.home}/WEB-INF/classes/flax/web.xml" todir="${web.home}/WEB-INF" overwrite="true" />
3254    <copy todir="${web.home}/WEB-INF/lib">
3255            <fileset dir="${basedir}/flax-lib">
3256               <include name="*.jar"/>
3257            </fileset> 
3258    </copy>
3259    <!--<delete dir="${web.home}/sites/gateway"/>
3260    <delete dir="${web.home}/sites/localsite"/>-->
3261  </target>
3262
3263  <target name="update-flax" description="update flax from repository">
3264    <echo>updating flax ...</echo>
3265    <exec executable="svn"><arg value="update"/>
3266      <arg value="src/java/org/flax"/></exec>
3267    <exec executable="svn"><arg value="update"/>
3268      <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
3269    <exec executable="svn"><arg value="update"/>
3270      <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
3271    <exec executable="svn"><arg value="update"/>
3272      <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
3273    <exec executable="svn"><arg value="update"/>
3274      <arg value="${web.home}/interfaces/flax"/></exec>
3275    <exec executable="svn"><arg value="update"/>
3276      <arg value="${web.home}/web/sites/flax"/></exec>
3277    <exec executable="svn"><arg value="update"/>
3278      <arg value="flax-resources"/></exec>
3279    <exec executable="svn"><arg value="update"/>
3280      <arg value="flax-lib"/></exec>
3281    <antcall target="compile-core" />
3282  </target>
3283
3284  <!-- ========================End of FLAX Targets ========================= -->
3285
3286  <target name="compile-javadocs">
3287    <javadoc packagenames="org.greenstone.*"
3288           sourcepath="src/java"
3289           defaultexcludes="yes"
3290           destdir="docs/javadoc"
3291           author="true"
3292           version="true"
3293           use="true"
3294           windowtitle="Greenstone3 API">
3295    <doctitle><![CDATA[<h1>Greenstone3 API</h1>]]></doctitle>
3296    </javadoc>
3297  </target>
3298
3299<!-- ========== Some distribution targets ======================== -->
3300  <target name="remove-source">
3301    <if><bool><isset property="with.gli.and.gems"/></bool>
3302    <delete includeEmptyDirs="true">
3303      <fileset dir="." defaultexcludes="false">
3304        <patternset refid="greenstone3.source.component"/>
3305     </fileset>
3306    </delete>
3307   
3308    <else>
3309    <delete includeEmptyDirs="true">
3310      <fileset dir="." defaultexcludes="false">
3311        <patternset refid="greenstone3.source.no.gli.component"/>
3312     </fileset>
3313    </delete>
3314    </else>
3315    </if>
3316  </target>
3317
3318  <target name="dist-tidy"
3319    description="'tidies-up' a greenstone3 installation for distribution."
3320    unless="${properties.keep.src}">
3321
3322    <!-- delete unneeded things -->
3323    <delete dir="${packages.home}/axis"/>
3324    <delete><fileset dir="${packages.home}" includes="*.zip"/></delete>
3325    <delete file="README-SVN.txt"/>
3326    <delete file="build.properties.in"/>
3327
3328    <!-- delete source files -->
3329    <antcall target="remove-source"/>
3330
3331    <!-- create empty directories -->
3332    <mkdir dir="${web.writablehome}/applet"/>
3333    <mkdir dir="${web.writablehome}/logs"/>
3334    <mkdir dir="${web.writablehome}/logs/tmp"/>
3335
3336    <!-- Lines with ***** are commented out because these files are useful if we want hybrid installations -->
3337   
3338    <!-- os specific tidy-ups -->
3339    <!-- linux, mac -->
3340    <if><bool><istrue value="${current.os.isunix}"/></bool>
3341      <!--*****<delete><fileset dir="." includes="*.bat"/></delete>-->
3342      <if><bool><isset property="with.gli.and.gems"/></bool>
3343        <!--*****<delete><fileset dir="gli" includes="*.bat"/></delete>-->
3344      </if>
3345      <!--*****<delete><fileset dir="gs2build" includes="*.bat"/></delete>-->
3346      <!--*****<delete><fileset dir="bin/script" includes="*.bat"/></delete>-->
3347      <delete file="${basedir}/gs2build/win32cfg.h"/>
3348      <delete file="${basedir}/gs2build/win32.mak"/>
3349      <delete dir="${basedir}/winutil"/>
3350      <delete failonerror="false"><fileset dir="${lib.jni}" includes="*.dll"/></delete>
3351
3352    <!-- windows -->
3353    <else><if><bool><istrue value="${current.os.iswindows}"/></bool>
3354      <!--*****<delete><fileset dir="." includes="*.sh,*.bash,*.csh"/></delete>-->
3355      <if><bool><isset property="with.gli.and.gems"/></bool>
3356    <!--*****<delete><fileset dir="gli" includes="*.sh,*.bash,*.csh"/></delete>-->
3357      </if>
3358      <!--*****<delete><fileset dir="gs2build" includes="*.sh,*.bash,*.csh"/></delete>-->
3359      <!--*****<delete><fileset dir="bin/script" includes="*.sh,*.bash,*.csh"/></delete>-->
3360    </if></else></if>
3361
3362  </target>
3363
3364  <!-- fix up executable permissions for binary release -->
3365  <target name="fix-execute-permissions">
3366    <echo>Setting binaries to executable</echo>
3367    <chmod perm="775">
3368      <fileset dir="."><patternset refid="greenstone3.executables"/></fileset>
3369    </chmod>
3370  </target>
3371 
3372  <!-- fix up executable permissions for source code release -->
3373  <target name="fix-execute-permissions-source">
3374    <chmod perm="775">
3375      <fileset dir="."><patternset refid="greenstone3.source.executables"/></fileset>
3376    </chmod>
3377  </target>
3378
3379  <!-- for macs, set up the .app shortcuts to gsi, gli, client-gli and gems -->
3380  <target name="gen-mac-shortcuts">   
3381    <if><bool><istrue value="${current.os.ismac}"/></bool>
3382      <filter token="gsdl3srchome" value="${basedir}"/>
3383      <copy file="${basedir}/gs3-server.app/Contents/document.wflow.in" tofile="${basedir}/gs3-server.app/Contents/document.wflow" filtering="true" overwrite="true"/>
3384      <copy file="${basedir}/gli.app/Contents/document.wflow.in" tofile="${basedir}/gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
3385      <copy file="${basedir}/client-gli.app/Contents/document.wflow.in" tofile="${basedir}/client-gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
3386      <copy file="${basedir}/gems.app/Contents/document.wflow.in" tofile="${basedir}/gems.app/Contents/document.wflow" filtering="true" overwrite="true"/>
3387    </if>
3388  </target>
3389
3390  <!-- ============= tweaks for making compilation static ========== --> 
3391  <target name="tweak-makefiles" depends="init" if="compile.static">
3392    <antcall target="rtftohtml-add-static" />
3393  </target>
3394   
3395  <target name="rtftohtml-add-static" depends="init" if="collection.building.enabled">
3396    <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" />
3397  </target>
3398   
3399    <target name="run-collection-tests">
3400        <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
3401            <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>
3402        </if>
3403        <for param="testjar">
3404            <path>
3405                <fileset dir="${basedir}" includes="web/sites/*/collect/*/tests/tests.jar"/>
3406            </path>
3407            <sequential>
3408                <echo>Testing @{testjar}</echo>
3409                <java classname="org.junit.runner.JUnitCore" fork="true">
3410                    <arg value="gstests.TestClass"/>
3411                    <jvmarg value="-DSERVERURL=${server.protocol}://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet} "/>
3412                    <classpath>
3413                        <fileset dir="${basedir}/ext/testing/lib/java">
3414                            <include name="*.jar"/>
3415                        </fileset>
3416                        <files includes="@{testjar}"/>
3417                    </classpath>
3418                </java>
3419            </sequential>
3420        </for>
3421    </target>
3422   
3423    <target name="build-collection-tests">
3424        <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
3425            <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>
3426        </if>
3427        <for param="compiledir">
3428            <path>
3429                <dirset dir="${basedir}" includes="web/sites/*/collect/*/tests/src"/>
3430            </path>
3431            <sequential>
3432                <echo>Compiling @{compiledir}</echo>
3433                <if><bool><not><available file="@{compiledir}/../build" type="dir"/></not></bool>
3434                    <mkdir dir="@{compiledir}/../build"/>
3435                </if>
3436                <javac
3437                    srcdir="@{compiledir}"
3438                    destdir="@{compiledir}/../build"
3439                        includeantruntime="${compile.includeantruntime}"
3440                    debug="${compile.debug}"
3441                    deprecation="${compile.deprecation}"
3442                    optimize="${compile.optimize}"
3443                    encoding="${compile.encoding}">
3444                    <classpath>
3445                        <fileset dir="${basedir}/ext/testing/lib/java">
3446                            <include name="*.jar"/>
3447                        </fileset>
3448                    </classpath>
3449                    <include name="gstests/*.java"/>
3450                </javac>
3451                <jar destfile="@{compiledir}/../tests.jar">
3452                    <fileset dir="@{compiledir}/../build">
3453                        <include name="gstests/**"/>
3454                    </fileset>
3455                    <manifest>
3456                        <attribute name="Built-By" value="${user.name}" />
3457                    </manifest>
3458                </jar>
3459            </sequential>
3460        </for>
3461    </target>
3462</project>
Note: See TracBrowser for help on using the browser.