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

Revision 32152, 147.5 KB (checked in by ak19, 3 years ago)

Fixing windows command.

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