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

Revision 33003, 190.9 KB (checked in by ak19, 7 months ago)

Recently GS3 tomcat failed to start on windows in a path containing spacse. Kathy discovered the cause was in catalina.opts property being set to contain a catanloup.config filepath that wasn't bookended by quotes. There are some further problems with catalina.opts property line, which I will fix and test incrementally and commit. This commit contains the minimal needed to fix GS3 tomcat server startup on windows.

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  <!-- Developer property. Set value=true if you want test https certificates issued
56       (as there's a limit on how many real certificates you can be issued per week).
57       If not testing can either uncomment this property or set value=false.
58       BEWARE: iff test.mode is true (so https.testing gets set to minus-minus-staging)
59       AND the default protocol is https (server.protocols contains https first), the
60       check-tomcat-running target and any other targets running an ant http condition
61       to test the default GS DL URL (which will be over https) won't work.
62       This is because the testing certificate is not trusted by clients, in this case
63       the ant http condition. (Clients that are browsers can be set to temporarily
64       trust the testing certificate, but don't know how to make ant do that, maybe it
65       needs to be done at Java level.)
66       Ant socket conditions to the URL will work because socket tests don't use
67       the protocol, just the host and port.
68  -->
69  <property name="https.test.mode" value="false"/>
70  <property name="sudo.or.not" value="/bin/bash"/><!-- by default, we don't run even special commands with sudo -->
71
72  <property name="os.linux" value="Linux"/>
73  <property name="os.mac" value="Mac OS X"/>
74  <property name="os.solaris" value="SunOS"/>
75  <property name="os.unix" value="${os.linux},${os.mac},${os.solaris}"/>
76  <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!!!-->
77
78  <!-- this is true for linux and macs -->
79  <condition property="current.os.isunix">
80    <os family="unix"/>
81  </condition>
82 
83  <condition property="current.os.isunixnotmac">
84    <and>
85      <os family="unix"/>
86      <not>
87    <os family="mac"/>
88      </not>
89    </and>
90  </condition>
91 
92  <condition property="current.os.ismac">
93    <os family="mac"/>
94  </condition>
95 
96  <condition property="current.os.iswindows">
97    <os family="windows"/>
98  </condition>
99
100  <!-- create build.properties if it has not been created yet -->
101  <if>
102    <bool><not><available file="build.properties"/></not></bool>
103    <copy file="build.properties.svn" tofile="build.properties"/>
104    <property name="first.run" value="true"/>
105  </if>
106
107  <!-- create the packages dir if it has not been created yet -->
108  <mkdir dir="packages"/>
109 
110  <!--the first three properties have to be put on the top to be used by build.properties-->
111  <property name="gs2build.home" value="${basedir}${file.separator}gs2build"/>
112  <property name="src.packages.home" value="${basedir}/src/packages"/>
113  <property name="flax.svn.root" value="http://svn.greenstone.org/flax"/>
114
115  <property name="solr-ext.home" value="${basedir}/ext/solr"/>
116
117  <property file="build.properties"/>
118  <if><bool><available file="${user.home}/build.properties"/></bool>
119    <property file="${user.home}/build.properties"/>
120  </if>
121
122  <if>
123    <bool><not><matches string="${server.protocols}" pattern="^\s*(https?|http\s*,\s*https|https\s*,\s*http)\s*$"/></not></bool>
124    <fail>@@@@
125      In file build.properties: invalid value for server.protocols.
126      It must contain http or https, or both (in order of preference) separated by commas.
127    </fail>
128  </if>
129
130  <!--
131       * "valid ports range from 1024–49151" is probably about user assignable ports.
132       But 80 is a valid port for running web servers including GS
133       and in future the range may become greater, so don't restrict the port range to 1024-49151.
134       https://stackoverflow.com/questions/113224/what-is-the-largest-tcp-ip-network-port-number-allowable-for-ipv4
135  -->
136    <if>
137      <bool>
138    <not><matches string="${localhost.port.http}" pattern="^\d{2,}\s*$"/></not>
139      </bool>
140      <fail>...
141    ********* ERROR: localhost.port.http in file build.properties is set to an invalid port number.
142    If port 80 is not possible, user assignable ports range from 1024–49151.
143    But don't choose any port already in use by another application.
144    Try setting to localhost.port.http=8383
145      </fail>
146    </if>
147
148    <!-- if server.protocols contains https, ensure its port number is valid -->
149    <if>
150      <bool>
151      <and>
152        <matches string="${server.protocols}" pattern="https"/>
153        <not><matches string="${tomcat.port.https}" pattern="^\d{2,}\s*$"/></not>
154      </and>
155      </bool>
156      <fail>...
157    ********* ERROR: in file build.properties, server.protocols includes https but
158    tomcat.port.https is set to an invalid port number.
159    If port 443 is not possible, user assignable ports range from 1024–49151.
160    But don't choose any port already in use by another application.
161    Try setting tomcat.port.https=8443
162      </fail>
163    </if>
164
165    <!--
166     Bail if https is enabled but the keystore password (keystore.pass property) is not set.
167     However, keystore.pass has no default value and is therefore not set as a rule.
168     So don't bail when 'ant' is run for the first time to create build.props from build.props.svn.
169     But do bail if running ant.prepare and https enabled and password not set.
170     (Maybe put this entire section before the first target: so we only bail after all non-targets
171     are executed so that any other first ever initialisation is completed?)
172    -->
173    <if>
174      <bool>
175    <and>
176      <matches string="${server.protocols}" pattern="https"/>
177      <or>
178        <not><isset property="keystore.pass"/></not>
179        <matches string="${keystore.pass}" pattern="^\s*$"/>
180      </or>
181    </and>
182      </bool>
183      <if>
184    <bool><isset property="first.run"/></bool>
185    <echo>IMPORTANT: In file build.properties, when property server.protocols includes https,
186    as now, the keystore.pass property must be set to a non-empty value.
187    Either set server.protocols to http by itself, if you don't want support for https,
188    or set keystore.pass if you do want https support.</echo>
189    <else>
190      <fail>...
191      ********* ERROR: server.protocols contains https in file build.properties, but the keystore.pass
192      property required for obtaining/renewing the https certificate is not set or is set to the empty
193      string. Choose a password for keystore.pass and set it in build.properties before proceeding.
194      </fail>
195    </else>
196      </if>
197    </if>
198
199    <!-- Set the keystore file name for linux versus windows. Ultimately unused/inactive if HTTPS
200     isn't enabled and no certificate obtained. We don't yet have https certification on mac -->
201    <condition property="keystore.file" value="fullchain_and_prvtkey.pfx" else="fullchain_and_prvtkey.p12">
202      <istrue value="${current.os.iswindows}"/>
203    </condition>   
204
205    <!-- Originally, https redirectPort when using regular http port 8383
206     was always fixed at 8443. Now we use redirectPort=tomcat.port.https.
207    -->
208    <property name="https.redirect.port" value="${tomcat.port.https}"/>
209
210    <!-- The default protocol to be used is the FIRST in the comma separated list for server.protocols
211    The default public tomcat port depends on the default server protocol
212    -->
213    <if>
214      <bool><matches string="${server.protocols}" pattern="^https"/></bool>
215      <property name="default.server.protocol" value="https"/>
216      <property name="default.tomcat.port" value="${tomcat.port.https}"/>     
217      <else>
218    <property name="default.server.protocol" value="http"/>
219    <property name="default.tomcat.port" value="${localhost.port.http}"/>   
220      </else>
221    </if>
222   
223
224    <!-- For setting filter tokens.
225     Used to set up server.xml when configuring tomcat -->
226    <property name="comment.start" value="&lt;!--" />
227    <property name="comment.end" value="--&gt;" />
228
229    <!--
230     If https is enabled, regardless of whether it is the default protocol,
231     there's some more work to do:
232     -
233     - if https is not enabled, comment out its Connecter element in server.xml
234    -->   
235    <if>
236      <bool><matches string="${server.protocols}" pattern="https"/></bool>     
237      <property name="https.comment.out.start" value=""/>
238      <property name="https.comment.out.end" value=""/>
239
240      <else>   
241    <property name="https.comment.out.start" value="${comment.start}"/>
242    <property name="https.comment.out.end" value="${comment.end}"/>
243      </else>
244    </if>
245
246    <!-- if server.protocols doesn't contain http, then http is only to be locally available,
247     e.g. for solr servlet on 127.0.0.1
248     In that case, see https://serverfault.com/questions/218666/how-to-configure-tomcat-to-only-listen-to-127-0-0-1
249    -->
250    <condition property="restrict.http.to.local" value="false" else="true">
251      <matches string="${server.protocols}" pattern="http($|\s+|,)"/>
252    </condition>
253   
254    <condition property="http.address.restriction" value="address=&quot;127.0.0.1&quot;" else="">
255      <istrue value="${restrict.http.to.local}"/>
256    </condition>
257
258    <!-- No certificates for localhost: https://letsencrypt.org/docs/certificates-for-localhost/
259    But 'localhost' (or actually, 127.0.0.1) needed for solr: solr servlet not accessible to outside world
260    -->
261    <condition property="local.http.url" value="http://${localhost.server.http}" else="http://${localhost.server.http}:${localhost.port.http}">
262      <equals arg1="${localhost.port.http}" arg2="80" trim="true"/>
263    </condition>
264
265    <!-- On linux, if testing https certification, pass in minus-minus-staging. If not testing on linux, nothing extra to pass in.
266         On windows or mac, if testing https certification, nothing extra to pass in. If not testing on windows or mac, pass in minus-minus-live.
267    -->
268    <if><bool><istrue value="${current.os.isunixnotmac}"/></bool>   
269        <condition property="https.testing" value="" else="--staging">
270            <isfalse value="${https.test.mode}"/>
271        </condition>
272    </if>
273    <if><bool><or><istrue value="${current.os.iswindows}"/><istrue value="${current.os.ismac}"/></or></bool>
274        <condition property="https.testing" value="--live" else="">
275            <isfalse value="${https.test.mode}"/>
276        </condition>
277        <!-- Set bitness of windows OS, so we can use it for the zeroSSL executable.
278            The Java system property os.arch will return x86 for 32 bit and AMD64 (or x64) for 64 bit OS.
279            See https://stackoverflow.com/questions/20856694/how-to-find-the-os-bit-type -->
280        <condition property="os.bitness" value="64" else="32">
281            <matches string="${os.arch}" pattern="64"/>
282        </condition>         
283    </if>
284
285  <!-- now we've read in properties, apply defaults -->
286  <property name="disable.collection.building" value="false"/>
287
288  <!-- get properties from the environment -->
289  <property environment="env"/>
290
291  <!-- get the filesets defining components and executables -->
292  <import file="resources/xml/components.xml"/>
293  <import file="resources/xml/executables.xml"/>
294   
295  <!-- version properties for external packages -->
296  <!-- for Java versions < 1.4, we print out the message that Java is too old.
297    For Java 1.4, we use Tomcat 5.5, for Java5 and higher, we use Tomcat 8.x-->
298  <condition property="tomcat.version" value="apache-tomcat-5.5.25" else="apache-tomcat-8.5.35">
299    <equals arg1="1.4" arg2="${ant.java.version}"/>
300  </condition>
301  <condition property="tomcat.version.major" value="5" else="8">
302    <equals arg1="1.4" arg2="${ant.java.version}"/>
303  </condition>
304  <condition property="privileged.attribute" value="privileged='true'" else="">
305    <equals arg1="8" arg2="${tomcat.version.major}"/>
306  </condition>
307
308  <!-- external access to the GS3 pages or not
309       https://tomcat.apache.org/tomcat-7.0-doc/config/valve.html -->
310  <condition property="allowed.IPs"
311         value=".*"
312         else="(127\.0\.0\.1|::1|0:0:0:0:0:0:0:1)">
313    <matches pattern="^(1|true|yes)$" string="${server.external.access}"/>
314  </condition>
315
316  <property name="axis.zip.version" value="axis-bin-1_4.zip"/>
317  <property name="axis.dir.version" value="axis-1_4"/>
318  <property name="sqlite.targz.version" value="sqlite-autoconf-3070602.tar.gz"/>
319
320  <property name="build.home" value="${basedir}/build"/>
321  <property name="src.home" value="${basedir}/src/java"/>
322
323  <if><bool><istrue value="${gsdl3home.isreadonly}"/></bool>
324    <property name="readonly-packages.home" value="${basedir}/packages"/>
325    <property name="packages.home" value="${gsdl3.writablehome}/packages"/>
326    <!--
327     To run solr from a read-only location (like a DVD-ROM), its locktype needs to be "single",
328     else solr tries to write out a lock file to the collection's index folder which is read-only.
329
330     https://cwiki.apache.org/confluence/display/solr/IndexConfig+in+SolrConfig
331     says that the "single" locktype is "for special situations of a read-only index directory, or ...."
332     
333     See also http://wiki.apache.org/lucene-java/AvailableLockFactories
334     And look for the documentation on "locktype" in solr collection's etc/conf/solrconfig.xml
335     for further information on the different locktypes.
336
337     To set the locktype property from the commandline (it's a property to the server web), pass in
338     "-Dsolr.lock.type=..." to the web server, as explained in
339     http://lucene.472066.n3.nabble.com/Where-can-we-set-the-parameters-in-Solr-Config-td4183706.html
340      -->
341    <property name="readonly.catalina.opts" value="-Dsolr.lock.type=single"/>
342  <else>
343    <property name="packages.home" value="${basedir}/packages"/>
344    <property name="readonly.catalina.opts" value=""/>
345  </else>
346  </if>
347
348  <!-- this may be set in build.properties, e.g. if you move the web dir to
349       tomcats webapps directory -->
350  <property name="web.home" value="${basedir}/web"/>
351  <property name="web.writablehome" value="${gsdl3.writablehome}"/>
352  <!-- If using a dispersed GS3 web folder, then the user web would not contain everything in the
353       default GS3 web (it won't contain a CGI or lib folder inside WEB-INF, for instance) -->
354  <if>
355    <bool><available file="${web.home}/WEB-INF/cgi" type="dir"/></bool>
356    <property name="full.web.dir" value="${web.home}"/>
357    <else>
358        <property name="full.web.dir" value="${basedir}/web"/>
359    </else>
360  </if> 
361 
362  <!-- jar files needed by applets go here -->
363  <property name="web.applet" value="${web.home}/applet"/>
364 
365  <!-- jar files needed by the servlet (and extra ones) go here -->
366  <property name="web.lib" value="${web.home}/WEB-INF/lib"/>
367  <property name="web.writablelib" value="${web.writablehome}/WEB-INF/lib"/>
368  <!-- other files needed by the servlet go here -->
369  <property name="web.classes" value="${web.home}/WEB-INF/classes"/>
370  <property name="web.writableclasses" value="${web.writablehome}/WEB-INF/classes"/>
371
372  <if>
373    <bool><istrue value="${gsdl3home.isreadonly}"/></bool>
374    <echo>Greenstone3 home directory is read-only</echo>
375    <echo>  => Writable area is: ${gsdl3.writablehome}</echo>
376
377    <condition property="gsdl3.writablehome.already-exists">
378      <available file="${gsdl3.writablehome}" type="dir"/>
379    </condition>
380
381    <if>
382      <bool><not><istrue value="${gsdl3.writablehome.already-exists}"/></not></bool>
383
384      <!-- set up writable area -->
385      <echo>No previous Greenstone home writable area detected</echo>
386      <echo>  => Setting up area</echo>
387      <mkdir dir="${gsdl3.writablehome}"/>
388      <mkdir dir="${gsdl3.writablehome}/packages"/>
389      <mkdir dir="${gsdl3.writablehome}/logs"/>
390      <mkdir dir="${gsdl3.writablehome}/ext/solr"/>
391
392      <chmod perm="a+rwx" dir="${gsdl3.writablehome}"/>
393      <chmod perm="a+rwx" dir="${gsdl3.writablehome}/packages"/>
394      <chmod perm="a+rwx" dir="${gsdl3.writablehome}/logs"/>
395      <chmod perm="a+rwx" dir="${gsdl3.writablehome}/ext/solr"/>
396
397      <!-- copy over packages tomcat folder -->
398
399      <if>
400    <bool><istrue value="${current.os.iswindows}"/></bool>
401    <copy todir="${gsdl3.writablehome}/packages/tomcat"
402          preservelastmodified="true"
403          failonerror="true" > 
404      <fileset dir="${readonly-packages.home}/tomcat" includes="**"/> 
405    </copy>
406     
407    <else>
408      <!-- else assume Unix -->
409      <!-- Can't go through the OS-independent <copy> task as it fails to preserve exec permissions -->
410      <echo>Copying to ${gsdl3.writablehome}/packages/tomcat</echo>
411      <exec executable="cp" output="/dev/null" spawn="false">
412            <arg value="-r"/>
413            <arg value="${readonly-packages.home}/tomcat"/>
414            <arg value="${gsdl3.writablehome}/packages/."/>
415      </exec>
416
417      <!-- the packages folder in tmp only has read permissions at this stage, it needs more permissions to work when running GS3 off a disc -->
418      <chmod perm="a+rwx" file="${gsdl3.writablehome}/packages/**" />
419
420    </else>
421      </if>
422     
423      <echo>  => Copying Greenstone's web/WEB-INF to writable area</echo>
424      <copy todir="${gsdl3.writablehome}/WEB-INF"
425        preservelastmodified="true"
426        failonerror="true" > 
427    <fileset dir="${full.web.dir}/WEB-INF" includes="**"/> 
428      </copy>
429
430      <copy todir="${gsdl3.writablehome}"
431        preservelastmodified="true"
432        failonerror="true" > 
433    <fileset dir="${web.home}" includes="index.html"/> 
434      </copy>
435
436    </if>
437  </if>
438
439
440  <!--- flax: the WordNet home -->
441  <property name="wn.home" value="${web.home}/WEB-INF/classes/flax/WordNet"/>
442
443  <!-- jni libraries and java wrappers go here -->
444  <property name="lib.jni" value="${basedir}/lib/jni"/>
445
446  <!-- other jar files needed for installation (but not runtime) go here -->
447  <property name="lib.java" value="${basedir}/lib/java"/>
448 
449  <property name="javadocs" value="${basedir}/docs/javadoc"/>
450
451  <property name="app.name"      value="greenstone3"/>
452  <property name="app.path"      value="/${greenstone.context}"/>
453
454   <property name="admin.dir"      value="${basedir}/admin"/>
455
456  <!-- defaults - set these on the command line or in build.properties or
457       they will take these default values-->
458  <property name="app.version" value="trunk"/>
459  <property name="branch.path" value="trunk"/>
460  <property name="branch.revision" value="HEAD"/>
461
462  <!--constants -->
463  <property name="svn.root" value="http://svn.greenstone.org"/>
464
465  <!-- catalina home is set to tomcat basedir if already installed, otherwise
466       use greenstone's tomcat -->
467  <condition property="catalina.home" value="${tomcat.installed.path}" else="${packages.home}/tomcat">
468    <and>
469      <isset property="tomcat.installed.path"/>
470      <not>
471    <equals arg1="" arg2="${tomcat.installed.path}"/>
472      </not>
473    </and>
474  </condition>
475 
476
477  <!-- is there a better way to do this?? what about solaris?? -->
478  <condition property="os.bin.dir" value="${cross.os}">
479      <istrue value="${compile.cross}"/>
480  </condition>
481  <condition property="os.bin.dir" value="windows">
482    <os family="windows"/>
483  </condition>
484  <condition property="os.bin.dir" value="darwin">
485    <os family="mac"/>
486  </condition>
487  <condition property="os.bin.dir" value="linux">
488    <and>
489      <os family="unix"/>
490      <not>
491    <os family="mac"/>
492      </not>
493    </and>
494  </condition>
495
496 
497  <condition property="collection.building.disabled">
498    <and>
499      <isset property="disable.collection.building"/>
500      <istrue value="${disable.collection.building}"/>
501    </and>
502  </condition>
503
504  <condition property="collection.building.enabled">
505    <not>
506      <istrue value="${disable.collection.building}"/>
507    </not>
508  </condition>
509 
510  <condition property="collection.building.enabled.windows">
511    <and>
512      <istrue value="${collection.building.enabled}"/>
513      <isset property="current.os.iswindows"/>
514    </and>
515  </condition>
516 
517  <condition property="collection.building.enabled.unix">
518    <and>
519      <istrue value="${collection.building.enabled}"/>
520      <isset property="current.os.isunix"/>
521    </and>
522  </condition>
523
524  <condition property="static.arg" value="LDFLAGS=-static" else=" ">
525    <isset property="compile.static"/>
526  </condition>
527
528  <!-- If building a release then we want to adjust environment variables so that the support library can be seen during compilation -->
529  <if><bool><isset property="use.gnomelib.ext"/></bool>
530    <property name="gnome-lib-dir" value="${basedir}/ext/gnome-lib-minimal/${os.bin.dir}"/>
531
532    <if><bool><isset property="env.CFLAGS"/></bool>
533        <property name="cflags.arg" value="CFLAGS=&quot;-I${gnome-lib-dir}/include -I${gnome-lib-dir}/include/libxml2 ${env.CFLAGS}&quot;"/>
534    <else>
535        <property name="cflags.arg" value="CFLAGS=&quot;-I${gnome-lib-dir}/include -I${gnome-lib-dir}/include/libxml2&quot;"/>
536    </else>
537    </if>
538
539    <if><bool><isset property="env.CPPFLAGS"/></bool>
540        <property name="cppflags.arg" value="CPPFLAGS=&quot;-I${gnome-lib-dir}/include -I${gnome-lib-dir}/include/libxml2 ${env.CPPFLAGS}&quot;"/>
541    <else>
542        <property name="cppflags.arg" value="CPPFLAGS=&quot;-I${gnome-lib-dir}/include -I${gnome-lib-dir}/include/libxml2&quot;"/>
543    </else>
544    </if>
545
546    <if><bool><isset property="env.CXXFLAGS"/></bool>
547        <property name="cxxflags.arg" value="CXXFLAGS=&quot;-I${gnome-lib-dir}/include -I${gnome-lib-dir}/include/libxml2 ${env.CXXFLAGS}&quot;"/>
548    <else>
549            <property name="cxxflags.arg" value="CXXFLAGS=&quot;-I${gnome-lib-dir}/include -I${gnome-lib-dir}/include/libxml2&quot;"/>
550    </else>
551    </if>
552
553    <!--https://groups.google.com/forum/#!topic/openkinect/m-hfXeYwKtU
554      compiling up libwv on ElCapitan needs -framework CoreFoundation -->
555    <if><bool><isset property="env.LDFLAGS"/></bool>
556        <property name="ldflags.arg" value="LDFLAGS=&quot;-L${gnome-lib-dir}/lib ${env.LDFLAGS}&quot;"/>
557    <else>
558            <property name="ldflags.arg" value="LDFLAGS=&quot;-L${gnome-lib-dir}/lib&quot;"/>
559    </else>
560    </if>
561
562    <if><bool><isset property="env.PATH"/></bool>
563        <property name="path.arg" value="PATH=&quot;${gnome-lib-dir}/bin:${env.PATH}&quot;"/>
564    <else>
565            <property name="path.arg" value="PATH=&quot;${gnome-lib-dir}/bin&quot;"/>
566    </else>
567    </if>
568
569    <if><bool><isset property="env.PKG_CONFIG_PATH"/></bool>
570        <property name="pcpath.arg" value="PKG_CONFIG_PATH=&quot;${gnome-lib-dir}/lib/pkgconfig:${env.PKG_CONFIG_PATH}&quot;"/>
571    <else>
572            <property name="pcpath.arg" value="PKG_CONFIG_PATH=&quot;${gnome-lib-dir}/lib/pkgconfig&quot;"/>
573    </else>
574    </if>
575
576    <if><bool><equals arg1="${os.bin.dir}" arg2="darwin"/></bool>
577      <!--<if><bool><isset property="env.DYLD_LIBRARY_PATH"/></bool>
578          <property name="ldlpath.arg" value="DYLD_LIBRARY_PATH=&quot;${gnome-lib-dir}/lib:${env.DYLD_LIBRARY_PATH}&quot;"/>
579          <else>
580        <property name="ldlpath.arg" value="DYLD_LIBRARY_PATH=&quot;${gnome-lib-dir}/lib&quot;"/>
581              </else>
582          </if>
583            -->
584      <property name="ldlpath.arg" value="DYLD_LIBRARY_PATH=&quot;${env.DYLD_LIBRARY_PATH}&quot;"/>
585    <else>
586        <if><bool><isset property="env.LD_LIBRARY_PATH"/></bool>
587            <property name="ldlpath.arg" value="LD_LIBRARY_PATH=&quot;${gnome-lib-dir}/lib:${env.LD_LIBRARY_PATH}&quot;"/>
588        <else>
589            <property name="ldlpath.arg" value="LD_LIBRARY_PATH=&quot;${gnome-lib-dir}/lib&quot;"/>
590        </else>
591        </if>
592    </else>
593    </if>
594
595
596    <else>
597        <if><bool><isset property="env.CFLAGS"/></bool>
598            <property name="cflags.arg" value="CFLAGS=&quot;${env.CFLAGS}&quot;"/>
599            <else>
600            <property name="cflags.arg" value=" "/>
601        </else>
602        </if>
603
604        <if><bool><isset property="env.CPPFLAGS"/></bool>
605                <property name="cppflags.arg" value="CPPFLAGS=&quot;${env.CPPFLAGS}&quot;"/>
606            <else>
607            <property name="cppflags.arg" value=" "/>
608        </else>
609        </if>
610
611        <if><bool><isset property="env.CXXFLAGS"/></bool>
612            <property name="cxxflags.arg" value="CXXFLAGS=&quot;${env.CXXFLAGS}&quot;"/>
613        <else>
614            <property name="cxxflags.arg" value=" "/>
615        </else>
616        </if>
617
618        <if><bool><isset property="env.LDFLAGS"/></bool>
619            <property name="ldflags.arg" value="LDFLAGS=&quot;${env.LDFLAGS}&quot;"/>
620        <else>
621            <property name="ldflags.arg" value=" "/>
622        </else>
623        </if>
624
625        <if><bool><isset property="env.PATH"/></bool>
626            <property name="path.arg" value="PATH=&quot;${env.PATH}&quot;"/>
627        <else>
628            <property name="path.arg" value=" "/>
629        </else>
630        </if>
631
632        <if><bool><isset property="env.PKG_CONFIG_PATH"/></bool>
633            <property name="pcpath.arg" value="PKG_CONFIG_PATH=&quot;${env.PKG_CONFIG_PATH}&quot;"/>
634        <else>
635            <property name="pcpath.arg" value=" "/>
636        </else>
637        </if>
638
639        <if><bool><equals arg1="${os.bin.dir}" arg2="darwin"/></bool>
640            <if><bool><isset property="env.DYLD_LIBRARY_PATH"/></bool>
641                <property name="ldlpath.arg" value="DYLD_LIBRARY_PATH=&quot;${env.DYLD_LIBRARY_PATH}&quot;"/>
642            <else>
643                <property name="ldlpath.arg" value=" "/>
644            </else>
645            </if>
646        <else>
647            <if><bool><isset property="env.LD_LIBRARY_PATH"/></bool>
648                <property name="ldlpath.arg" value="LD_LIBRARY_PATH=&quot;${env.LD_LIBRARY_PATH}&quot;"/>
649            <else>
650                <property name="ldlpath.arg" value=" "/>
651            </else>
652            </if>
653        </else> 
654        </if>
655    </else>
656  </if>
657  <property name="allargs" value="${cflags.arg} ${cxxflags.arg} ${cppflags.arg} ${ldflags.arg} ${path.arg} ${ldlpath.arg} ${pcpath.arg}"/>
658
659  <condition property="opt.cross.build"
660         value="--build=${cross.build}" else=" ">
661    <isset property="cross.build"/>
662  </condition>
663
664
665  <condition property="cross.configure.args"
666         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=" ">
667    <istrue value="${compile.cross}"/>
668  </condition>
669
670  <!-- if we're told to work with gnome-lib, or if there's a gnome-lib-minimal that the user
671       has placed in gs2build/ext, then compile gs2build after sourcing gnome-lib environment -->
672  <condition property="opt.gnomelibext.arg"
673         value="--enable-gnome-lib-ext" else=" ">
674    <or>
675      <available file="${gs2build.home}/ext/gnome-lib-minimal" type="dir"/>
676      <istrue value="${use.gnomelib.ext}"/>
677      <istrue value="${checkout.gnomelib.ext}"/>
678    </or>
679   </condition>
680
681<!-- if you want to disable wvware, do so here: set the value (not else) field to contain minus-minus-disable-wvware -->
682  <condition property="gs2.opt.args" value="${opt.gnomelibext.arg} " else="--disable-mg --disable-mgpp --disable-accentfold --disable-gdbm --disable-sqlite">
683    <istrue value="${with.jni}"/>
684  </condition>
685  <condition property="gs2.compile.target" value="with-jni" else="without-jni">
686    <istrue value="${with.jni}"/>
687  </condition>
688  <condition property="gs2.install.target" value="install-with-jni" else="install-without-jni">
689    <istrue value="${with.jni}"/>
690  </condition>
691  <condition property="gs2.windows.enablejni" value="1" else="0">
692    <istrue value="${with.jni}"/>
693  </condition>
694  <condition property="gs2.windows.enablemg" value="1" else="0">
695    <istrue value="${with.jni}"/>
696  </condition>
697  <condition property="gs2.windows.enablemgpp" value="1" else="0">
698    <istrue value="${with.jni}"/>
699  </condition>
700  <!-- Should accent folding not also be set here ?? -->
701  <condition property="gs2.windows.usegdbm" value="1" else="0">
702    <istrue value="${with.jni}"/>
703  </condition>
704  <condition property="gs2.windows.usesqlite" value="1" else="0">
705    <istrue value="${with.jni}"/>
706  </condition>
707 
708  <!-- where is search4j tool -->
709  <condition property="search4j.exec" value="bin/search4j.exe" else="bin/search4j">
710    <isset property="current.os.iswindows"/>
711  </condition>
712
713 
714  <!-- ============= Base dirs for each package and component ============ -->
715  <property name="src.gsdl3.home" value="${src.home}/org/greenstone/gsdl3"/>
716  <property name="anttasks.home" value="${src.home}/org/greenstone/anttasks"/>
717  <property name="gli.home" value="${basedir}/gli"/>
718  <property name="javagdbm.home" value="${src.packages.home}/javagdbm"/>
719
720  <condition property="common.src.home" value="${basedir}/common-src" else="${gs2build.home}${file.separator}common-src">
721    <istrue value="${disable.collection.building}"/>
722  </condition>
723 
724  <property name="build.src.home" value="${gs2build.home}/build-src"/>
725  <property name="gdbm.home" value="${common.src.home}/packages/gdbm"/>
726  <property name="mg.home" value="${common.src.home}/indexers/mg"/>
727  <property name="mgpp.home" value="${common.src.home}/indexers/mgpp"/>
728  <property name="lucene.home" value="${common.src.home}/indexers/lucene-gs"/>
729
730  <!--  ==================== Compilation Control Options ==================== -->
731
732  <!--
733
734  These properties control option settings on the Javac compiler when it
735  is invoked using the <javac> task.
736
737  compile.debug        Should compilation include the debug option?
738
739  compile.deprecation  Should compilation include the deprecation option?
740
741  compile.optimize     Should compilation include the optimize option?
742
743  -->
744
745  <property name="compile.debug"       value="true"/>
746  <property name="compile.deprecation" value="true"/>
747  <property name="compile.optimize"    value="true"/>
748  <property name="compile.encoding"    value="UTF8"/>
749  <property name="compile.includeantruntime" value="false"/> <!-- to get rid of annoying 'ant' warning -->
750
751  <!--
752
753  Rather than relying on the CLASSPATH environment variable, Ant includes
754  features that makes it easy to dynamically construct the classpath you
755  need for each compilation.  The example below constructs the compile
756  classpath to include the servlet.jar file, as well as the other components
757  that Tomcat makes available to web applications automatically, plus anything
758  that you explicitly added.
759
760  -->
761 
762  <!-- All elements that Tomcat 5 exposes to applications -->
763  <path id="tomcat5">
764    <pathelement location="${catalina.home}/common/classes"/>
765    <fileset dir="${catalina.home}/common/endorsed">
766      <include name="*.jar"/>
767    </fileset>
768    <fileset dir="${catalina.home}/common/lib">
769      <include name="*.jar"/>
770    </fileset>
771    <!-- seems to be empty, but will leave in just in case some people make use of this to customise their install: -->
772    <pathelement location="${catalina.home}/shared/classes"/>
773    <fileset dir="${catalina.home}/shared/lib">
774      <include name="*.jar"/>
775    </fileset>
776  </path>
777 
778  <!-- All elements that Tomcat 7 exposes to applications -->
779  <path id="tomcat8">
780    <fileset dir="${catalina.home}/lib">
781      <include name="*.jar"/>
782    </fileset>
783  </path>
784 
785  <path id="compile.classpath">
786    <!-- Include all jar files and libraries in our jni lib directory -->
787    <pathelement location="${lib.jni}"/>
788    <fileset dir="${lib.jni}">
789      <include name="*.jar"/>
790    </fileset>
791    <!-- Include all jar files in our web lib directory -->
792    <pathelement location="${web.lib}"/>
793    <fileset dir="${web.lib}">
794      <include name="*.jar"/>
795    </fileset>
796   
797    <pathelement location="${lib.java}"/>
798    <fileset dir="${lib.java}">
799      <include name="*.jar"/>
800    </fileset>
801   
802    <!-- include the jar files from the source packages -->
803    <!-- mg and mgpp get installed into lib/jni but they may not be there yet
804    so we add them in by name -->
805    <!-- *** is there any way to make this optional, based on ${with.jni}? -->
806    <pathelement location="${lib.jni}/mg.jar"/>
807    <pathelement location="${lib.jni}/mgpp.jar"/>
808   
809    <!-- Include all elements that Tomcat exposes to applications -->
810    <path refid="tomcat${tomcat.version.major}"/>
811   
812  </path>
813
814  <path id="local.tomcat.classpath">
815    <!-- explicitly include the jni java wrappers in the classpath -->
816    <pathelement location="${lib.jni}"/>
817    <fileset dir="${lib.jni}">
818      <include name="*.jar"/>
819    </fileset>
820   
821    <pathelement location="${web.writablelib}"/>
822    <fileset dir="${web.writablelib}">
823      <include name="derbyclient.jar"/> <!--<include name="derby.jar"/>-->
824    </fileset>
825  </path>
826 
827  <path id="derby.server.classpath">
828    <pathelement location="${web.writablelib}/derbynet.jar"/>
829    <pathelement location="${web.writablelib}/derby.jar"/>
830  </path>
831
832 
833    <if><bool><isset property="env.PATH"/></bool>
834      <path id="local.tomcat.path">
835        <pathelement location="${basedir}/bin/script"/>
836        <pathelement location="${basedir}/bin"/>
837        <pathelement location="${lib.jni}"/>   
838        <pathelement path="${env.PATH}"/>
839        <pathelement path="${wn.home}/bin"/>
840      </path>
841      <!-- Windows can be case sensitive about env.PATH, preferring env.Path. See https://ant.apache.org/manual/Tasks/property.html  -->
842      <else><if><bool><isset property="env.Path"/></bool>
843        <path id="local.tomcat.path">
844          <pathelement location="${basedir}/bin/script"/>
845          <pathelement location="${basedir}/bin"/>
846          <pathelement location="${lib.jni}"/>
847          <pathelement path="${env.Path}"/>
848          <pathelement path="${wn.home}/bin"/>
849        </path>
850      <!-- else print error about no path set -->
851      <else>
852        <echo>No env.PATH (or env.Path) set. Unable to set local.tomcat.path property</echo>
853      </else></if></else>   
854    </if>   
855
856  <target name="test-setup">
857    <echo>ant java version=${ant.java.version}</echo>
858    <echo>is unix : ${current.os.isunix}</echo>
859    <echo>is mac : ${current.os.ismac}</echo>
860    <echo>is unixnotmac : ${current.os.isunixnotmac}</echo>
861    <echo>is windows : ${current.os.iswindows}</echo>
862    <echo>os.unix: ${os.unix}</echo>
863    <echo>env.PATH: ${env.PATH}</echo>
864    <echo>env.Path: ${env.Path}</echo> 
865  </target>
866
867  <target name="needs-gs3-setup">
868    <!-- has the gs3-setup script been run?? -->
869    <condition property="gs3-setup-not-done">
870      <not>
871    <isset property="env.GSDL3HOME"/>
872      </not>
873    </condition>
874
875    <fail if="gs3-setup-not-done" message="Please run 'gs3-setup' (Windows) or 'source gs3-setup.sh' (Linux/Mac) before starting the Greenstone server."/>
876  </target>
877
878  <!-- Appends the current env to the file environment.txt. For debugging env vars used by the release-kit. -->
879  <target name="write-env" description="Writes out the environment that this build.xml is executed in to file environment.txt. For debugging.">
880    <echo message="*****************ENVIRONMENT OUTPUT:****************${line.separator}" file="environment.txt" append="true" />
881
882    <if><bool><istrue value="${current.os.iswindows}"/></bool>
883      <exec executable="cmd" dir="${basedir}" failonerror="false" output="environment.txt" append="true">     
884    <arg value="/c" />
885    <arg value="set" />
886      </exec>
887      <else>
888    <exec executable="env" dir="${basedir}" failonerror="false" output="environment.txt" append="true" />
889      </else>
890    </if>
891
892    <echo message="${line.separator}" file="environment.txt" append="true" />
893  </target>
894
895 
896  <!-- ==================== Primary and Global Targets ============================= -->
897
898  <target name="prepare" depends="accept-properties,init,copy-dot-svn-files,prepare-core,prepare-packages,prepare-common-src,prepare-collection-building,prepare-tomcat,prepare-axis,prepare-web,prepare-collections, prepare-flax"
899    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.">
900
901    <!-- make sure .sh files are executable -->
902    <chmod dir="${basedir}" perm="ugo+rx"
903      includes="*.sh"/>
904    <chmod dir="${basedir}/bin/script" perm="ugo+rx"
905      includes="*.sh,*.pl"/>
906  </target>
907
908  <!-- 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 -->
909  <!--before configuring build-src, make sure that gnome-lib is compiled up-->
910  <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"
911    description="Install Greenstone 3. Use this when you first checkout the code: 'ant prepare new-install'.">
912    <echo>
913        After successful compilation, you can turn on https support on Windows and Linux (requires sudo/admin permissions)
914        by editing build.properties and running 'ant setup-https-cert'.
915    </echo>
916  </target>
917
918  <target name="install-common-src" depends="init"
919    description="Install (configure, compile, install) only the common-src package (shared code from Greenstone 2). " >
920    <antcall target="configure-common-src">
921      <param name="set.ld.path" value="true"/>
922    </antcall>
923    <antcall target="compile-common-src">
924      <param name="set.ld.path" value="true"/>
925    </antcall>
926    <antcall target="install-auxiliary-jar-files"/>
927    <antcall target="install-jni-files"/>
928  </target>
929
930  <target name="install-collection-building" depends="init" if="collection.building.enabled"
931    description="Install (configure, compile, install) the Greenstone 2 collection building package." >
932    <antcall target="configure-collection-building"/>
933    <antcall target="tweak-makefiles" />
934    <antcall target="compile-collection-building"/>
935  </target>
936   
937
938  <target name="install-runtime" depends="init,configure,configure-packages,configure-core,compile-web,compile-packages,compile-core,compile-classpath-jars"
939    description="Install (configure, compile, install) the runtime system. Needs either common-src or collection-building to have been installed first." />
940   
941  <target name="svnupdate" depends="init,svnupdate-packages,svnupdate-core,svnupdate-common-src,svnupdate-collection-building,svnupdate-web"
942    description="Do a `svn update` for all sources. Doesn't recompile the code. You need to be online to run this."/>
943 
944  <target name="configure" depends="init,configure-tomcat,configure-web"
945    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."/>
946
947  <target name="clean" depends="init,clean-packages,clean-core,clean-common-src,clean-collection-building,clean-classpath-jars"
948    description="Remove all old compiled code. Includes runtime and collection-building if necessary"/>
949 
950  <target name="distclean" depends="init,distclean-packages,clean-core,distclean-common-src,distclean-collection-building,clean-classpath-jars"
951    description="Remove all compiled code and also any Makefiles etc generated during configure-c++. Includes runtime and collection-building as necessary"/>
952 
953  <target name="update" depends="init,svnupdate,clean,install"
954    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'"/>
955
956
957  <target name="perl-for-building" depends="init">
958    <!-- uses perl.path if set in build.properties, otherwise try for
959         environment variable PERLPATH, and failing that assumes 'perl'
960         is on environment PATH -->
961    <!-- 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 -->
962    <if><bool><available file="${gs2build.home}"/></bool>
963
964      <if><bool><not><isset property="perl.path"/></not></bool>
965
966        <if>
967          <bool>
968            <and>
969              <isset property="env.PERLPATH"/>
970              <not><equals arg1="${env.PERLPATH}" arg2=""/></not>
971            </and>
972          </bool>
973          <!-- set perlpath to env.PERLPATH.
974            This is the path to perl\bin that's found by findperl.bat when the server is launched
975            through GLI instead of the console.
976            For windows, this env.PERLPATH is the bin folder and needs a backslash at end, since it
977            will appear suffixed with "perl.exe" in the perl setting in packages\tomcat\config\web.xml.
978            This web.xml's path to perl is then used to find perl when running the perl scripts in the
979            cgi folder, so without a slash appended at this point it becomes "binperl" in web.xml, and
980            things will break when GLI launches the server on Windows and the online GS3 metadata editor
981            is used to save user-edited metadata. -->
982          <if><bool><istrue value="${current.os.iswindows}"/></bool>
983            <property name="perl.path" value="${env.PERLPATH}\"/>
984          <else>
985            <property name="perl.path" value="${env.PERLPATH}"/>
986          </else>   
987          </if>
988         
989          <else>
990            <echo>
991  Using PATH environment variable to locate Perl.
992            </echo>
993            <exec executable="which" os="${os.unix}" spawn="false" outputproperty="full.perl.path">
994              <arg value="perl" />
995            </exec>
996
997        <exec executable="${gs2build.home}/bin/windows/which" osfamily="windows" spawn="false" outputproperty="full.perl.path">
998              <arg value="perl" />
999            </exec>
1000
1001            <stringutil string="${full.perl.path}" property="partial.perl.path">
1002                <replace regex="\/[^\/]*$" replacement="/" />
1003            </stringutil>
1004        <stringutil string="${partial.perl.path}" property="perl.path">
1005                <replace regex="\\[^\\]*$" replacement="\\" />
1006            </stringutil>
1007            <if><bool><istrue value="${current.os.isunix}"/></bool>
1008              <if><bool><not><equals arg1="${full.perl.path}" arg2="/usr/bin/perl"/></not></bool>
1009                <echo>
1010    Non-standard location of Perl found: ${full.perl.path}
1011    Set the environment variable PERLPATH or the perl.path property in
1012    build.properties to explicitly control the version of Perl used.
1013                </echo>
1014              </if>
1015            </if>
1016          </else>
1017        </if>
1018      </if>
1019
1020      <!-- full.perl.path is for pretty-printing only, e.g. used in target "start" -->
1021      <if><bool><isset property="perl.path"/></bool>
1022        <property name="full.perl.path" value="${perl.path}${file.separator}perl"/>
1023        <else>
1024          <property name="full.perl.path" value="perl (will use the enviroment variable PATH to find this executable)"/>
1025        </else>
1026      </if>
1027
1028      <!-- gs2build not available, perl.path -->
1029      <else>
1030    <property name="perl.path" value=""/>
1031      </else>
1032    </if>
1033    <stringutil string="${perl.path}" property="escaped.perl.path">
1034      <replace regex="\\" replacement="\\\\" />
1035    </stringutil>
1036  </target>
1037
1038  <target name="get-default-servlet-url">
1039    <echo>${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}${server.default.servlet}</echo>
1040  </target>
1041
1042  <!-- returns the base local URL, something like HTTP://127.0.0.1:<HTTPport>
1043       or some sane equivalent for 127.0.0.1 -->
1044  <target name="get-local-base-http-url">
1045    <echo>${local.http.url}</echo>
1046  </target>
1047  <!-- Returns something like HTTP://127.0.0.1:<HTTPport>/greenstone3/library -->
1048  <target name="get-local-http-servlet-url">
1049    <echo>${local.http.url}${app.path}${server.default.servlet}</echo>
1050  </target>
1051
1052  <!-- solr should only be accessible locally, which therefore also means only over http.
1053  Note that for http, 127.0.0.1 is safer than localhost (as localhost can be mapped to something
1054  other than 127.0.0.1). See also https://letsencrypt.org/docs/certificates-for-localhost/ -->
1055  <target name="get-solr-servlet-url">
1056    <!--<echo>${default.server.protocol}://${tomcat.server}:${default.tomcat.port}/${solr.context}</echo>-->
1057    <echo>${local.http.url}/${solr.context}</echo>
1058  </target>
1059
1060  <target name="check-derbyserver-running">
1061    <condition property="derby.isrunning" value="true" else="false">
1062      <!--<socket server="jdbc:derby://${derby.server}" port="${derby.server.port}"/>-->
1063      <socket server="${derby.server}" port="${derby.server.port}"/><!-- like telnet machine port -->
1064    </condition>
1065    <echo>Derby is running: ${derby.isrunning}</echo>
1066  </target>
1067
1068  <!-- Need a copy of the check-derby-running target with a distinct property, because ant restart runs
1069       both stop and start, which stop and start derby respectively. Both  need check the derby socket.
1070       Because each property can be set only once during an invocation with ant, ant restart will need
1071       two check-derbyserver properties, one for each derby check. -->
1072  <target name="check-derbyserver-started">
1073    <condition property="derby.isstarted" value="true" else="false">
1074      <socket server="${derby.server}" port="${derby.server.port}"/>
1075    </condition>
1076    <echo>Derby is running: ${derby.isstarted}</echo>
1077  </target>
1078
1079
1080  <!-- Unused -->
1081  <target name="start-derby-java" depends="check-derbyserver-running">
1082    <if><bool><not><istrue value="${derby.isrunning}"/></not></bool>
1083      <echo>Launching derby on ${derby.server}:${derby.server.port}...</echo>
1084      <java classname="org.apache.derby.drda.NetworkServerControl" fork="true" spawn="true" clonevm="true">     
1085    <arg value="start"/>
1086    <classpath refid="derby.server.classpath"/>
1087      </java>
1088      <else>
1089    <echo>Derby server ALREADY RUNNING on ${derby.server}:${derby.server.port}</echo>
1090      </else>
1091    </if>
1092  </target>
1093 
1094  <target name="start-derby" depends="check-derbyserver-started">
1095    <if><bool><not><istrue value="${derby.isstarted}"/></not></bool>
1096      <echo>About to launch derby on ${derby.server}:${derby.server.port}</echo>
1097      <antcall target="force-start-derby"/>
1098      <else>
1099    <echo>Derby networked server ALREADY RUNNING on ${derby.server}:${derby.server.port}</echo>
1100      </else>
1101    </if>
1102  </target>
1103
1104  <!-- Using derby 10.1.2.1
1105       See db-derby-10.1.2.1-bin/docs/html/adminguide/index.html -->
1106  <target name="force-start-derby">
1107      <property name="derby.server.classpath.prop" refid="derby.server.classpath" />
1108      <!-- During the installer, launching java directly fails on systems that don't have java installed.
1109       Forcing force-start-derby to always use packages/jre/bin/java is wrong too: as gs3-setup does
1110       a lot of work of determining the correct JRE_HOME/JAVA_HOME (not necessarily the GS3 bundled JRE)
1111       and we want to be consistent in using the same java throughout. Solution:
1112       Refer to the JRE used in executing this ant file, which for installers will always be the bundled one.
1113       https://stackoverflow.com/questions/17571595/env-java-home-not-found-ant -->
1114      <exec executable="${java.home}/bin/java" spawn="true"><!-- failonerror="true"-->
1115    <env key="CLASSPATH" path="${derby.server.classpath.prop}"/>
1116    <arg value="org.apache.derby.drda.NetworkServerControl"/>
1117    <arg value="start"/>
1118    <arg value="-p"/>
1119    <arg value="${derby.server.port}"/>
1120      </exec>
1121
1122  </target>
1123
1124  <target name="force-stop-derby">
1125    <java classname="org.apache.derby.drda.NetworkServerControl">
1126      <arg value="shutdown"/>
1127      <arg value="-p"/>
1128      <arg value="${derby.server.port}"/>
1129      <classpath refid="derby.server.classpath"/>
1130    </java>
1131  </target>
1132
1133  <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 -->
1134    <if><bool><istrue value="${derby.isrunning}"/></bool>
1135      <!--<echo>Derby is |${derby.isrunning}| running</echo>-->
1136      <antcall target="force-stop-derby"/>
1137      <else>
1138    <echo>Derby is not running</echo>
1139      </else>
1140    </if>
1141  </target>
1142
1143  <target name="start" depends="needs-gs3-setup,init,configure-tomcat,configure-web,configure-solr-ext,start-derby,start-tomcat"
1144    description="Startup the Tomcat server." >
1145    <echo>${app.name} (${app.version}) server running using Apache Tomcat and Java</echo>
1146    <echo>Tomcat: ${catalina.home}</echo>
1147    <echo>Java  : ${java.home}</echo>
1148    <if><bool><available file="${build.src.home}"/></bool>
1149      <echo>Perl  : ${full.perl.path}</echo>
1150    </if>
1151    <if><bool><isset property="install.flax"/></bool>
1152        <property name="url" value="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/flax"/>
1153    <else>
1154        <property name="url" value="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/"/>
1155    </else>
1156    </if>
1157    <echo>URL   : ${url}</echo>
1158    <!-- assuming that index.html is not needed here -->   
1159
1160    <!--Now write out the url with /oaiserver suffix as the baseURL property in OAIConfig.xml-->
1161    <available file="${basedir}/resources/oai/OAIConfig.xml.in" property="oaiconfig.present"/>
1162    <antcall target="init-oaiconfig">
1163      <param name="url" value="${url}"/>
1164    </antcall>
1165
1166    <!--Now write out the url with /gs-cantaloupe suffix as the baseURL property in IIIFConfig.xml-->
1167    <available file="${basedir}/resources/iiif/IIIFConfig.xml.in" property="iiifconfig.present"/>
1168    <antcall target="init-iiifconfig">
1169      <param name="url" value="${url}"/>
1170    </antcall>
1171
1172  </target>
1173
1174  <target name="init-oaiconfig" if="oaiconfig.present">
1175    <echo>Writing out baseURL ${url}oaiserver to ${web.writableclasses}/OAIConfig.xml</echo>
1176    <copy file="${basedir}/resources/oai/OAIConfig.xml.in" tofile="${web.writableclasses}/OAIConfig.xml"/>
1177    <rsr verbosity="1" file="${web.writableclasses}/OAIConfig.xml" pattern="&lt;baseURL&gt;.*&lt;/baseURL&gt;" replacement="&lt;baseURL&gt;${url}oaiserver&lt;/baseURL&gt;" />   
1178  </target>
1179
1180  <target name="init-iiifconfig" if="iiifconfig.present">
1181    <echo>Writing out baseURL ${url}gs-cantaloupe to ${web.writableclasses}/IIIFConfig.xml</echo>
1182    <copy file="${basedir}/resources/iiif/IIIFConfig.xml.in" tofile="${web.writableclasses}/IIIFConfig.xml"/>
1183    <rsr verbosity="1" file="${web.writableclasses}/IIIFConfig.xml" pattern="&lt;baseURL&gt;.*&lt;/baseURL&gt;" replacement="&lt;baseURL&gt;${url}gs-cantaloupe&lt;/baseURL&gt;" />   
1184  </target>
1185 
1186  <target name="stop" depends="init,stop-tomcat,stop-derby"
1187    description="Shutdown the Tomcat server."/>
1188 
1189  <target name="restart" description="Shutdown and restart Tomcat"  depends="init,stop,start"/>
1190
1191  <!-- =========== Help targets ===================================  -->
1192 
1193  <property name="install-command" value="ant [options] prepare install"/>
1194 
1195  <target name="usage" description="Print a help message">
1196    <echo message="  Execute 'ant -projecthelp' for a list of targets."/>
1197    <echo message="  Execute 'ant -help' for Ant help."/>
1198    <echo>
1199  To install Greenstone3, run '${install-command}'.
1200    There are properties defined in build.properties. The install
1201      process will ask you if these properties are set correctly.
1202      To avoid this prompt, use the '-Dproperties.accepted=yes'
1203      option.
1204    To log the output, use the '-logfile build.log' option.
1205  The README.txt file has more information about the ant targets
1206    and install process.
1207    </echo>
1208  </target>
1209 
1210  <target name="help" depends="usage" description="Print a help message"/>
1211 
1212  <target name="debug" depends="init" description="Display all the currently used properties">
1213    <echoproperties/>
1214  </target>
1215
1216  <!-- ====== initialization and setup targets ================== -->
1217
1218  <target name="accept-properties" unless="properties.accepted">
1219    <input addproperty="properties.ok" validargs="y,n">The following properties (among others) are being used from a build.properties file found in this directory:
1220      server.protocols=${server.protocols}     
1221      tomcat.server=${tomcat.server}
1222      tomcat.port.https=${tomcat.port.https}
1223      localhost.port.http=${localhost.port.http}
1224
1225         default.server.protocol=${default.server.protocol}
1226         default.tomcat.port=${default.tomcat.port}
1227         Local base HTTP URL used by Greenstone: ${local.http.url}
1228
1229      tomcat.installed.path=${tomcat.installed.path} (this is the location of Tomcat's base dir if it is already installed)
1230      proxy.host=${proxy.host}
1231      proxy.port=${proxy.port}
1232      disable.collection.building=${disable.collection.building}
1233      If these are not acceptable, please change them and rerun this target. Continue [y/n]?
1234    </input>
1235    <condition property="do.abort">
1236      <equals arg1="n" arg2="${properties.ok}"/>
1237    </condition>
1238    <fail if="do.abort">Build aborted by user. Please change your properties settings and re-run the target</fail>
1239  </target>
1240
1241  <!-- this sets up some initial properties -->
1242  <target name="init">
1243   
1244    <condition property="java.too.old">
1245      <or>
1246        <equals arg1="1.1" arg2="${ant.java.version}"/>
1247        <equals arg1="1.2" arg2="${ant.java.version}"/>
1248        <equals arg1="1.3" arg2="${ant.java.version}"/>
1249      </or>
1250    </condition>
1251    <fail if="java.too.old" message="You need Java 1.4 or greater to run Greenstone 3"/>
1252   
1253    <available file="${basedir}/gli" property="gli.present"/>
1254    <available file="${basedir}/common-src" property="common.src.present"/>
1255    <available file="${basedir}/gs2build" property="gs2build.present"/>
1256    <available file="${gnome-lib-dir}" property="gnome-lib.present"/>
1257
1258    <condition property="tomcat.islocal">
1259      <or>
1260        <not><isset property="tomcat.installed.path"/></not>
1261        <equals arg1="" arg2="${tomcat.installed.path}"/>
1262      </or>
1263    </condition>
1264
1265    <condition property="proxy.present">
1266      <and>
1267        <isset property="proxy.host"/>
1268        <not><equals arg1="" arg2="${proxy.host}"/></not>
1269      </and>
1270    </condition>
1271
1272    <!--
1273    the next block checks if the bundled tomcat is present in the 'packages' directory,
1274    and checks for the lethal combination of tomcat 8 and java 1.4. Test for
1275    tomcat6 is based on the presence of a file inserted by greenstone into the tomcat6
1276    download, as there is no other surefire way to check tomcat version under java 1.4
1277    -->
1278    <condition property="packages.tomcat.ispresent" value="true" else="false">
1279      <available file="packages/tomcat"/>
1280    </condition>
1281    <condition property="packages.tomcat.istomcat8" value="true" else="false">
1282      <available file="packages/tomcat/tomcat8.txt"/>
1283    </condition>
1284    <if>
1285      <bool>
1286        <and>
1287          <istrue value="${packages.tomcat.ispresent}"/>
1288          <istrue value="${packages.tomcat.istomcat8}"/>
1289          <equals arg1="1.4" arg2="${ant.java.version}"/>
1290        </and>
1291      </bool>
1292      <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>
1293    </if>
1294
1295  </target>
1296
1297  <target name="setup-proxy" depends="init" if="proxy.present">
1298    <condition property="ask.user">
1299      <or>
1300        <equals arg1="" arg2="${proxy.user}"/>
1301        <equals arg1="" arg2="${proxy.password}"/>
1302      </or>
1303    </condition>
1304   
1305    <getuserandpassword message="Using proxy: ${proxy.host}:${proxy.port}" if="ask.user" username="${proxy.user}" userproperty="proxy.username" pwordproperty="proxy.password"/>
1306    <mysetproxy proxyhost="${proxy.host}" proxyport="${proxy.port}" proxyuser="${proxy.username}" proxypassword="${proxy.password}"/>
1307  </target>
1308
1309  <target name="copy-dot-svn-files" depends="init"
1310      description="Copies all resources .svn files to .in versions - which are used during configure to generate the runtime versions." >
1311    <if>
1312      <bool><available file="${basedir}/resources/tomcat/greenstone3.xml.in"/></bool>
1313      <copy file="${basedir}/resources/tomcat/greenstone3.xml.in" tofile="${basedir}/resources/tomcat/greenstone3.xml.in.backup"  overwrite="true"/>
1314    </if>
1315    <copy file="${basedir}/resources/tomcat/greenstone3.xml.svn" tofile="${basedir}/resources/tomcat/greenstone3.xml.in"  overwrite="true"/>
1316
1317    <if>
1318      <bool><available file="${basedir}/resources/tomcat/server_tomcat5.xml.in"/></bool>
1319      <copy file="${basedir}/resources/tomcat/server_tomcat5.xml.in" tofile="${basedir}/resources/tomcat/server_tomcat5.xml.in.backup"  overwrite="true"/>
1320    </if>
1321    <copy file="${basedir}/resources/tomcat/server_tomcat5.xml.svn" tofile="${basedir}/resources/tomcat/server_tomcat5.xml.in"  overwrite="true"/>
1322
1323    <if>
1324      <bool><available file="${basedir}/resources/tomcat/server_tomcat7.xml.in"/></bool>
1325      <copy file="${basedir}/resources/tomcat/server_tomcat7.xml.in" tofile="${basedir}/resources/tomcat/server_tomcat7.xml.in.backup"  overwrite="true"/>
1326    </if>
1327    <copy file="${basedir}/resources/tomcat/server_tomcat8.xml.svn" tofile="${basedir}/resources/tomcat/server_tomcat8.xml.in" overwrite="true"/>
1328
1329    <if>
1330      <bool><available file="${basedir}/resources/tomcat/server_tomcat8.xml.in"/></bool>
1331      <copy file="${basedir}/resources/tomcat/server_tomcat8.xml.in" tofile="${basedir}/resources/tomcat/server_tomcat8.xml.in.backup"  overwrite="true"/>
1332    </if>
1333    <copy file="${basedir}/resources/tomcat/server_tomcat8.xml.svn" tofile="${basedir}/resources/tomcat/server_tomcat8.xml.in" overwrite="true"/>
1334
1335    <if>
1336      <bool><available file="${basedir}/resources/tomcat/web8.xml.in"/></bool>
1337      <copy file="${basedir}/resources/tomcat/web8.xml.in" tofile="${basedir}/resources/tomcat/web8.xml.in.backup"  overwrite="true"/>
1338    </if>
1339    <copy file="${basedir}/resources/tomcat/web8.xml.svn" tofile="${basedir}/resources/tomcat/web8.xml.in"  overwrite="true"/>
1340
1341    <if>
1342      <bool><available file="${basedir}/resources/oai/OAIConfig.xml.in"/></bool>
1343      <copy file="${basedir}/resources/oai/OAIConfig.xml.in" tofile="${basedir}/resources/oai/OAIConfig.xml.in.backup"  overwrite="true"/>
1344    </if>
1345    <copy file="${basedir}/resources/oai/OAIConfig.xml.svn" tofile="${basedir}/resources/oai/OAIConfig.xml.in"  overwrite="true"/>
1346
1347    <if>
1348      <bool><available file="${basedir}/resources/iiif/IIIFConfig.xml.in"/></bool>
1349      <copy file="${basedir}/resources/iiif/IIIFConfig.xml.in" tofile="${basedir}/resources/iiif/IIIFConfig.xml.in.backup"  overwrite="true"/>
1350    </if>
1351    <copy file="${basedir}/resources/iiif/IIIFConfig.xml.svn" tofile="${basedir}/resources/iiif/IIIFConfig.xml.in"  overwrite="true"/>
1352
1353    <if>
1354      <bool><available file="${basedir}/resources/iiif/cantaloupe.properties.in"/></bool>
1355      <copy file="${basedir}/resources/iiif/cantaloupe.properties.in" tofile="${basedir}/resources/iiif/cantaloupe.properties.in.backup" overwrite="true"/>
1356    </if>
1357    <copy file="${basedir}/resources/iiif/cantaloupe.properties.svn" tofile="${basedir}/resources/iiif/cantaloupe.properties.in" overwrite="true"/>
1358
1359    <if>
1360      <bool><available file="${basedir}/resources/cgi/gsdl3site.cfg.in"/></bool>
1361      <copy file="${basedir}/resources/cgi/gsdl3site.cfg.in" tofile="${basedir}/resources/cgi/gsdl3site.cfg.in.backup" overwrite="true"/>
1362    </if>
1363    <copy file="${basedir}/resources/cgi/gsdl3site.cfg.svn" tofile="${basedir}/resources/cgi/gsdl3site.cfg.in" overwrite="true"/>
1364
1365    <if>
1366      <bool><available file="${basedir}/resources/web/global.properties.in"/></bool>
1367      <copy file="${basedir}/resources/web/global.properties.in" tofile="${basedir}/resources/web/global.properties.in.backup" overwrite="true"/>
1368    </if>
1369    <copy file="${basedir}/resources/web/global.properties.svn" tofile="${basedir}/resources/web/global.properties.in" overwrite="true"/>
1370
1371    <if>
1372      <bool><available file="${basedir}/resources/web/log4j.properties.in"/></bool>
1373      <copy file="${basedir}/resources/web/log4j.properties.in" tofile="${basedir}/resources/web/log4j.properties.in.backup" overwrite="true"/>
1374    </if>
1375    <copy file="${basedir}/resources/web/log4j.properties.svn" tofile="${basedir}/resources/web/log4j.properties.in" overwrite="true"/>
1376   
1377</target>
1378   
1379  <!-- ========== Web app Targets ================================ -->
1380 
1381  <target name="prepare-web" depends="init">
1382    <mkdir dir="${web.writablehome}/applet"/>
1383    <mkdir dir="${web.writablehome}/logs"/>
1384    <mkdir dir="${web.writablehome}/logs/tmp"/>
1385  </target>
1386 
1387  <!-- 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.
1388       The test for whether we need it assumes we won't be trying to compile GS3 against Java versions less than 1.4. -->
1389  <target name="configure-java-version" depends="init"
1390    description="Activates or deactivates some jar libraries as needed depending on your java version">
1391
1392    <available property="have.xalan.jar" file="${web.lib}/xalan.jar"/>
1393    <condition property="need.xalan.jar">
1394      <or>
1395        <not><equals arg1="1.4" arg2="${ant.java.version}"/></not>
1396      </or>
1397    </condition>
1398
1399    <!-- if they have xalan.jar but dont need it -->
1400    <if>
1401      <bool>
1402        <and>
1403          <isset property="have.xalan.jar"/>
1404          <not><isset property="need.xalan.jar"/></not>
1405        </and>
1406      </bool>
1407      <antcall target="deactivate-xalan-jar"/>
1408    </if>
1409
1410    <!-- if they need xalan.jar but dont have it -->
1411    <if>
1412      <bool>
1413        <and>
1414          <not><isset property="have.xalan.jar"/></not>
1415          <isset property="need.xalan.jar"/>
1416        </and>
1417      </bool>
1418      <antcall target="activate-xalan-jar"/>
1419    </if>
1420
1421  </target>
1422 
1423  <target name="activate-xalan-jar">
1424    <echo>activating xalan.jar</echo>
1425    <copy file="${web.lib}/xalan.jar.tmp" tofile="${web.lib}/xalan.jar"/>
1426    <if>
1427      <bool>
1428    <and>
1429      <isset property="current.os.ismac"/>
1430      <available file="${catalina.home}/common/endorsed" type="dir"/>
1431    </and>
1432      </bool>
1433      <copy file="${web.lib}/xalan.jar.tmp" tofile="${catalina.home}/common/endorsed/xalan.jar"/>
1434    </if>
1435  </target>
1436
1437  <target name="deactivate-xalan-jar">
1438    <echo>deactivating xalan.jar</echo>
1439    <delete file="${web.lib}/xalan.jar"/>
1440    <!-- should we be deleting common/endorsed/xalan.jar on mac?? -->
1441  </target>
1442
1443
1444  <target name="prepare-collections" depends="init"
1445    description="Unpack all the collections from their svn zipped versions">
1446    <property name="collect.dir" value="${web.home}/sites/localsite/collect"/>
1447    <property name="index-and-archives.zip" value="index-and-archives.zip"/>
1448
1449    <echo message="installing collections..."/>
1450    <antcall target="gs2mgdemo-install"/>
1451    <antcall target="gs2mgppdemo-install"/>
1452    <antcall target="gberg-install"/>
1453    <antcall target="lucene-jdbm-demo-install"/>
1454  </target>
1455
1456  <target name="gs2mgdemo-prepare" if="collect.dir">
1457    <property name="gs2mgdemo.dir" value="${collect.dir}/gs2mgdemo"/>
1458
1459    <condition property="gs2mgdemo.present">
1460      <and>
1461        <available file="${gs2mgdemo.dir}/${index-and-archives.zip}"/>
1462      </and>
1463    </condition>
1464  </target>
1465
1466  <target name="gs2mgdemo-install" if="gs2mgdemo.present" depends="gs2mgdemo-prepare">
1467    <unzip dest="${gs2mgdemo.dir}" src="${gs2mgdemo.dir}/${index-and-archives.zip}" />
1468    <echo>collection gs2mgdemo installed</echo>
1469  </target>
1470
1471  <target name="gs2mgppdemo-prepare" if="collect.dir">
1472    <property name="gs2mgppdemo.dir" value="${collect.dir}/gs2mgppdemo"/>
1473 
1474    <condition property="gs2mgppdemo.present">
1475      <and>
1476        <available file="${gs2mgppdemo.dir}/${index-and-archives.zip}"/>
1477      </and>
1478    </condition>
1479  </target>
1480
1481  <target name="gs2mgppdemo-install" if="gs2mgppdemo.present" depends="gs2mgppdemo-prepare">
1482    <unzip dest="${gs2mgppdemo.dir}" src="${gs2mgppdemo.dir}/${index-and-archives.zip}" />
1483    <echo>collection gs2mgppdemo installed</echo>
1484  </target>   
1485
1486  <target name="gberg-prepare" if="collect.dir">
1487    <property name="gberg.dir" value="${collect.dir}/gberg"/>
1488    <available file="${gberg.dir}/index/index.zip" property="gberg.present"/>
1489  </target>
1490
1491  <target name="gberg-install" if="gberg.present" depends="gberg-prepare">
1492    <unzip dest="${gberg.dir}/index" src="${gberg.dir}/index/index.zip"/>
1493    <echo>collection gberg installed</echo>
1494  </target>
1495
1496  <target name="lucene-jdbm-demo-prepare" if="collect.dir">
1497    <property name="lucene-jdbm-demo.dir" value="${collect.dir}/lucene-jdbm-demo"/>
1498    <available file="${lucene-jdbm-demo.dir}/${index-and-archives.zip}" property="lucene-jdbm-demo.present"/>
1499  </target>
1500
1501  <target name="lucene-jdbm-demo-install" if="lucene-jdbm-demo.present" depends="lucene-jdbm-demo-prepare">
1502    <unzip dest="${lucene-jdbm-demo.dir}" src="${lucene-jdbm-demo.dir}/${index-and-archives.zip}"/>
1503    <echo>collection lucene-jdbm-demo installed</echo>
1504  </target>
1505
1506 
1507  <target name="install-solr-ext" depends="init" >
1508    <exec executable="ant.bat" osfamily="windows" dir="${solr-ext.home}" spawn="false">
1509      <arg value="add-service"/>
1510    </exec>
1511    <exec executable="ant" os="${os.unix}" dir="${solr-ext.home}" spawn="false">
1512      <arg value="add-service"/>
1513    </exec>
1514    <antcall target="solr-jdbm-demo-install"/>
1515  </target>
1516
1517  <target name="solr-jdbm-demo-prepare" if="collect.dir">
1518    <property name="solr-jdbm-demo.dir" value="${collect.dir}/solr-jdbm-demo"/>
1519    <available file="${solr-jdbm-demo.dir}/${index.zip}" property="solr-jdbm-demo.present"/>
1520  </target>
1521
1522  <target name="solr-jdbm-demo-install" if="solr-jdbm-demo.present" depends="solr-jdbm-demo-prepare">
1523    <unzip dest="${solr-jdbm-demo.dir}" src="${solr-jdbm-demo.dir}/${index.zip}"/>
1524    <echo>collection solr-jdbm-demo installed</echo>
1525  </target>
1526
1527  <!-- Until 64 bit Linux and Mac (Lion) machines can generate a working IsisGdl,
1528       use the ones generated on a 32 bit Linux and Mac (Leopard), respectively -->
1529  <target name="get-isisgdl" if="${current.os.isunix}">
1530    <exec executable="uname" dir="${basedir}" failonerror="false"
1531      outputproperty="uname.val">
1532      <arg value="-m"/>
1533    </exec>
1534   
1535    <if><bool><equals arg1="${uname.val}" arg2="x86_64"/></bool>
1536      <echo>Bitness: ${uname.val}</echo>
1537      <if><bool><contains string="${os.bin.dir}" substring="darwin" casesensitive="false"/></bool>
1538    <get src="http://www.greenstone.org/caveat-emptor/IsisGdl.macleopard"
1539             dest="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl"/>   
1540      </if>
1541      <if><bool><contains string="${os.bin.dir}" substring="linux" casesensitive="false"/></bool>
1542    <get src="http://www.greenstone.org/caveat-emptor/IsisGdl.bin32"
1543             dest="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl"/>
1544      </if>
1545      <chmod file="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl" perm="755"/>
1546    </if>
1547  </target>
1548
1549  <target name="set-perl-shebangs" depends="perl-for-building">
1550    <if>
1551      <bool>
1552        <and><isset property="perl.path"/>
1553          <not><equals arg1="${perl.path}" arg2=""/></not>
1554        </and>
1555      </bool>
1556
1557      <if><bool><istrue value="${current.os.iswindows}"/></bool>
1558    <property name="perl.exec" value="${perl.path}perl.exe"/>
1559    <else>
1560      <property name="perl.exec" value="${perl.path}perl"/>   
1561    </else>
1562      </if>
1563
1564      <!--<echo>**** PERLPATH: ${perl.path}</echo>-->
1565      <echo>Setting perl shebangs to Perl Exec: ${perl.exec}</echo>
1566
1567      <!-- set the shebangs in the cgi files to point to the correct perlpath -->
1568      <if>
1569    <bool><not><equals arg1="${web.home}" arg2="${web.writablehome}"></equals></not></bool>
1570    <mkdir dir="${web.writablehome}"/>
1571    <copy file="${full.web.dir}/WEB-INF/cgi/gliserver.pl"       tofile="${web.writablehome}/WEB-INF/cgi/gliserver.pl"       overwrite="true"/>
1572    <copy file="${full.web.dir}/WEB-INF/cgi/metadata-server.pl" tofile="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" overwrite="true"/>
1573    <copy file="${full.web.dir}/WEB-INF/cgi/checksum.pl"        tofile="${web.writablehome}/WEB-INF/cgi/checksum.pl"        overwrite="true"/>
1574      </if>
1575
1576      <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/gliserver.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1577      <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1578      <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/checksum.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>     
1579      <else>
1580    <echo>WARNING: perl.path is empty. Unable to set the shebangs in the perl files in ${web.writablehome}/WEB-INF/cgi</echo>
1581      </else>
1582    </if>
1583  </target>
1584
1585  <target name="configure-web" depends="init,perl-for-building"
1586    description="Configure only the web app config files">
1587    <!-- we want a unix path in the global.properties file -->
1588    <pathconvert targetos="unix" property="src.gsdl3.home.unix">
1589      <path path="${web.home}"/>
1590    </pathconvert>
1591    <pathconvert targetos="unix" property="src.gsdl3.writablehome.unix">
1592      <path path="${web.writablehome}"/>
1593    </pathconvert>
1594
1595    <antcall target="set-perl-shebangs" inheritAll="true" />
1596   
1597    <filter token="gsdlhome" value="${gs2build.home}"/>
1598    <filter token="gsdlhomequoted" value="&quot;${gs2build.home}&quot;"/>
1599    <filter token="gsdl3srchome" value="${basedir}"/>
1600    <filter token="gsdl3srchomequoted" value="&quot;${basedir}&quot;"/>
1601    <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
1602    <filter token="gsdl3homequoted" value="&quot;${src.gsdl3.home.unix}&quot;"/>
1603    <filter token="gsdl3writablehome" value="${src.gsdl3.writablehome.unix}"/>
1604    <filter token="gsdl3version" value="${app.version}"/>
1605    <filter token="server.protocols" value="${server.protocols}"/>
1606    <filter token="default.server.protocol" value="${default.server.protocol}"/>
1607    <filter token="tomcat.server" value="${tomcat.server}"/>
1608    <filter token="default.tomcat.port" value="${default.tomcat.port}"/>
1609    <filter token="localhost.server.http" value="${localhost.server.http}"/>
1610    <filter token="localhost.port.http" value="${localhost.port.http}"/>
1611    <filter token="tomcat.port.https" value="${tomcat.port.https}"/>
1612    <filter token="restrict.http.to.local" value="${restrict.http.to.local}"/>
1613    <filter token="greenstone.context" value="${greenstone.context}"/>
1614    <filter token="solr.context" value="${solr.context}"/>
1615    <filter token="derbyserver" value="${derby.server}"/>
1616    <filter token="derbyserver.port" value="${derby.server.port}"/>
1617    <filter token="perlpath" value="${escaped.perl.path}"/>
1618    <filter token="disable.collection.building" value="${disable.collection.building}"/>
1619    <copy file="${basedir}/resources/cgi/gsdl3site.cfg.in" tofile="${web.writablehome}/WEB-INF/cgi/gsdl3site.cfg" filtering="true" overwrite="true"/>
1620    <copy file="${basedir}/resources/web/global.properties.in" tofile="${web.writableclasses}/global.properties" filtering="true" overwrite="true"/>
1621    <copy file="${basedir}/resources/web/log4j.properties.in" tofile="${web.writableclasses}/log4j.properties" filtering="true" overwrite="true"/>
1622    <if>
1623      <bool><istrue value="${gsdl3home.isreadonly}"/></bool>
1624      <!-- uncomment the writablehome properties -->
1625      <rsr verbosity="1" file="${web.writableclasses}/global.properties" pattern="^#gsdl3\.(writable{1})?home" replacement="gsdl3.$1home" />
1626    </if>
1627    <chmod file="${web.writableclasses}/global.properties" perm="644"/>
1628    <chmod file="${web.writableclasses}/log4j.properties" perm="644"/>
1629
1630    <copy file="${basedir}/resources/iiif/cantaloupe.properties.in" tofile="${basedir}/cantaloupe.properties" filtering="true" overwrite="true"/>
1631    <chmod file="${basedir}/cantaloupe.properties" perm="644"/>
1632  </target>
1633
1634  <target name="compile-web" depends="init">
1635    <javac srcdir="${web.classes}"
1636      destdir="${web.classes}"
1637      includeantruntime="${compile.includeantruntime}"
1638      debug="${compile.debug}"
1639      deprecation="${compile.deprecation}"
1640      optimize="${compile.optimize}"
1641      encoding="${compile.encoding}">
1642      <classpath><path refid="compile.classpath"/></classpath>
1643    </javac>
1644  </target>
1645
1646  <target name="compile-classpath-jars" depends="init">
1647    <if><bool><available file="admin/cp.mf"/></bool>
1648      <jar destfile="admin/cp.jar" manifest="admin/cp.mf"/>
1649    </if>
1650    <if><bool><available file="${lib.java}/cp.mf"/></bool>
1651      <jar destfile="${lib.java}/cp.jar" manifest="${lib.java}/cp.mf"/>
1652    </if>
1653    <if><bool><available file="${lib.jni}/cp.mf"/></bool>
1654      <jar destfile="${lib.jni}/cp.jar" manifest="${lib.jni}/cp.mf"/>
1655    </if>
1656    <if><bool><available file="${web.lib}/cp.mf"/></bool>
1657      <jar destfile="${web.lib}/cp.jar" manifest="${web.lib}/cp.mf"/>
1658    </if>
1659    <jar destfile="cp.jar">
1660      <manifest>
1661        <attribute name="Class-Path" value="server.jar admin/cp.jar lib/java/cp.jar lib/jni/cp.jar web/WEB-INF/lib/cp.jar"/>
1662      </manifest>
1663    </jar>
1664  </target>
1665
1666  <target name="clean-classpath-jars" depends="init">
1667    <delete file="admin/cp.jar"/>
1668    <delete file="${lib.java}/cp.jar"/>
1669    <delete file="${lib.jni}/cp.jar"/>
1670    <delete file="${web.lib}/cp.jar"/>
1671    <delete file="cp.jar"/>
1672  </target>
1673
1674
1675  <target name="svnupdate-web" unless="nosvn.mode">
1676    <exec executable="svn">
1677      <arg value="update"/>
1678      <arg value="${web.writablehome}"/>
1679      <arg value="-r"/><arg value="${branch.revision}"/>
1680    </exec>
1681  </target>
1682
1683  <target name="update-web" depends="init,svnupdate-web,configure-web"
1684    description="update only the web stuff (config files)"/>
1685
1686  <!-- ============ Targets concerned with https certification ================ -->
1687
1688  <target name="setup-https-cert-info">
1689    <echo>
1690      *********************************************************************
1691               NOTE TO OBTAINING A TLS (SSL) CERTIFICATE FOR HTTPS
1692      *********************************************************************
1693      A signed certificate is needed for your GS server to serve pages over https.
1694      This target will attempt to obtain a certificate for you from the official and free Certificate Authority Let's Encrypt.
1695      However, a certificate can only be obtained if you have admin/sudo permissions on this machine that you're installing Greenstone on.
1696
1697      Note that:
1698      * if you already have a certificate, then you probably don't want to be running this target but the 'ant renew-existing-https-cert' target instead, to renew your existing certificate.
1699      * if you run this target when you already have a generated certificate, the existing certificate will remain unchanged and the script will terminate with a message alerting you to this fact.
1700    </echo>
1701  </target>
1702 
1703
1704  <target name="https-conditions-set">
1705    <input addproperty="https.conditions.ok" validargs="y,n">     
1706      To run this target, ensure you have:
1707      * (if on unix) sudo permissions. Enter the sudo password if prompted.
1708      * (if on windows) sufficient privileges to run the included tomcat on port 80.
1709      * nothing running on port 80 when you run this target
1710      * edited the build.properties file with
1711        - tomcat.server set to the/a domain name of your server
1712        - server.protocols comma-separated list set to contain at least 'https' if not also http (the first in this list will be the default protocol)
1713        - tomcat.port.https set to a valid port number not yet in use
1714        - keystore.pass set to a password for the certification process
1715    * read the Let's Encrypt Subscriber Agreement at https://letsencrypt.org/repository/
1716      If any of the above is not possible, quit this target. Continue [y/n]?
1717    </input>
1718
1719    <condition property="quit.https.setup">
1720      <equals arg1="n" arg2="${https.conditions.ok}"/>
1721    </condition>
1722
1723    <fail if="quit.https.setup">https certification step aborted by user. Please edit build.properties to set server.protocol=http and comment out tomcat.port.https.</fail>
1724  </target>
1725 
1726
1727  <target name="setup-https-cert" depends="setup-https-cert-info,https-conditions-set">
1728    <if><bool><not><matches string="${server.protocols}" pattern="https"/></not></bool>
1729      <fail>To setup https certification, the server.protocols property in file build.properties must contain 'https'</fail>
1730    </if>
1731
1732    <input addproperty="https.cert.email">Enter an email that Let's Encrypt, the certification authority, can send any important notifications to</input>
1733    <input addproperty="https.other.domains">Besides tomcat.server=${tomcat.server}, enter a comma separated list of additional domains to support, if any</input>
1734    <input addproperty="https.cert.agree" validargs="y,n">You've read the Let's Encrypt Subscriber Agreement at https://letsencrypt.org/repository/ and agree</input>
1735    <if>
1736      <bool><equals arg1="y" arg2="${https.cert.agree}"/></bool>
1737
1738      <condition property="https.cert.domains" value="${tomcat.server},${https.other.domains}" else="${tomcat.server}">
1739    <and>
1740      <isset property="https.other.domains" />
1741      <not><matches string="${https.other.domains}" pattern="^\s*$"/></not>
1742    </and>
1743      </condition>     
1744
1745      <input addproperty="https.do.cert" validargs="y,n">
1746    You've agreed to the Let's Encrypt TOS with
1747    - email: ${https.cert.email}
1748    - domains: ${https.cert.domains}
1749    Looks okay? [y/n]
1750      </input>
1751    </if>
1752
1753    <if><bool><equals arg1="n" arg2="${https.do.cert}"/></bool>
1754      <echo>Not proceeding with https certification for the Greenstone 3 web server</echo>
1755    <else>
1756        <echo>Proceeding...</echo>   
1757        <if><bool><istrue value="${current.os.iswindows}"/></bool>
1758            <antcall target="setup-https-cert-windows">
1759                <param name="https.cert.renewal" value=""/><!-- for cert issuance, there are none of the additional parameters specific to cert renewal -->
1760            </antcall>
1761        </if>
1762        <if><bool><istrue value="${current.os.isunixnotmac}"/></bool>
1763            <antcall target="setup-https-cert-linux"/>
1764        </if>
1765        <if><bool><istrue value="${current.os.ismac}"/></bool>
1766            <antcall target="setup-https-cert-mac"/>
1767        </if>
1768     </else>
1769  </if>
1770 
1771  </target>
1772 
1773 
1774  <target name="setup-https-cert-windows">
1775   
1776    <echo>********** The included tomcat will be stopped, then restarted on port 80 and stopped again</echo>
1777   
1778    <!-- create folder packages\tomcat\webapps\ROOT\.well-known\acme-challenge -->
1779    <mkdir dir="${packages.home}/tomcat/webapps/ROOT/.well-known/acme-challenge"/>
1780    <mkdir dir="${packages.home}/tomcat/conf/https_cert"/>
1781 
1782    <!--
1783        For Windows, Greenstone can generate the account and domain keys with the openSSL we compiled up ourselves
1784        and put on SVN (at GS3/bin/windows/openssl) rather than let ZeroSSL generate these keys for the user.
1785        Letting Greenstone generate the keys may be considered more trustworthy by the user than letting a 3rd
1786        party do so. See https://zerossl.com/usage.html#First_time_run_and_regular_use for OpenSSL commands
1787        If we don't generate the keys ourselves with our OpenSSL, then ZeroSSL will do so automatically in the
1788        call to le64/32.exe further below, as it's passed in the flag generate-missing.
1789    -->
1790    <!-- We generate the account key named "privkey.key" in ${packages.home}\tomcat\conf\https_cert -->
1791    <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
1792      <arg value="/c" />
1793      <arg value="openssl.exe" />
1794      <arg value="genrsa" />
1795      <arg value="-out" /><arg value="${packages.home}\tomcat\conf\https_cert\privkey.key" /><arg value="4096" />
1796    </exec>
1797 
1798    <!-- Also generate the domain key (for csr-key parameter to zeroSSL's le.exe)
1799        ${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key
1800        Using 2048 instead of 4096 bits for this. See https://zerossl.com/usage.html#First_time_run_and_regular_use
1801    -->
1802    <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
1803      <arg value="/c" />
1804      <arg value="openssl.exe" />
1805      <arg value="genrsa" />
1806      <arg value="-out" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key" /><arg value="2048" />
1807    </exec>
1808 
1809    <!-- stop the included tomcat (also stopping derby and solr) -->
1810    <antcall target="stop" />
1811   
1812    <!-- rerun tomcat on port 80
1813        See https://ant.apache.org/manual/Tasks/antcall.html -->
1814    <antcall target="start">
1815        <param name="localhost.port.http" value="80"/>
1816        <param name="default.tomcat.port" value="80"/>
1817        <param name="local.http.url" value="http://${localhost.server.http}"/><!-- For port 80 over http, leave out port number in URL -->
1818        <param name="http.address.restriction" value=""/><!-- don't prevent public access over http of port 80 -->
1819        <param name="https.comment.out.start" value="${comment.start}"/>
1820        <param name="https.comment.out.end" value="${comment.end}"/>
1821    </antcall>
1822 
1823    <!-- get the certificate: use zerossl for windows
1824        Download from https://github.com/do-know/Crypt-LE/releases,
1825        For licence see https://github.com/do-know/Crypt-LE/
1826        Usage instructions at https://zerossl.com/usage.html       
1827       
1828        le64 ==key "${packages.home}\tomcat\conf\https_cert\privkey.key" ==csr "${packages.home}\tomcat\conf\https_cert\${tomcat.server}.csr" ==csr-key "${packages.home}s\tomcat\conf\https_cert\${tomcat.server}.key" ==crt "${packages.home}\tomcat\conf\https_cert\${tomcat.server}.crt" ==domains "${https.cert.domains}" ==path "${packages.home}\tomcat\webapps\ROOT\.well-known\acme-challenge" ==generate-missing ==unlink ==live -export-pfx "${keystore.pass}"
1829       
1830        which generates a .pfx file with the same name as the PEM certificate (.crt param below)
1831        .pfx vs .p12: https://stackoverflow.com/questions/6819079/convert-pfx-format-to-p12
1832       
1833        In this case "fullchain_and_prvtkey.pfx" is generated, which is the windows value of ${keystore.file} property
1834
1835        Helpful for debugging: https://stackoverflow.com/questions/10302489/ant-script-have-exec-tag-dump-out-entire-command-line
1836        -->
1837    <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}" spawn="false">
1838      <arg value="/c" />
1839      <arg value="le${os.bitness}" />
1840      <arg value="--key" /><arg value="${packages.home}\tomcat\conf\https_cert\privkey.key" />
1841      <arg value="--csr" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.csr" />
1842      <arg value="--csr-key" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key" />
1843      <!--<arg value="==crt" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.crt" />-->
1844      <arg value="--crt" /><arg value="${packages.home}\tomcat\conf\https_cert\fullchain_and_prvtkey.crt" />
1845      <arg value="--domains" /><arg value="${https.cert.domains}" />
1846      <arg value="--path" /><arg value="${packages.home}\tomcat\webapps\ROOT\.well-known\acme-challenge" />
1847      <arg value="--generate-missing" />
1848      <arg value="--unlink" />
1849      <arg line="${https.testing}" /><!-- minus-minus-live if not testing, empty if testing. https://stackoverflow.com/questions/11840284/pass-arguments-to-apache-ant-exec-task-based-on-the-variables-value -->
1850      <!--<arg value="==export-pfx" /><arg value="${keystore.pass}" />
1851      <arg value="==tag-pfx" /><arg value="greenstone3-tomcat" />--><!--Convert the certificate (that contains the full chain AND private key) to pfx format hereafter using OpenSSL instead-->
1852      <arg line="${https.cert.renewal}" /><!-- renew command on windows/mac appends min-min-renew XX, where if the day the renewal is run is XX days within expiry, the certificate will get renewed. -->
1853    </exec>
1854
1855    <!-- stop the tomcat running on port 80 -->
1856    <antcall target="stop">
1857        <param name="localhost.port.http" value="80"/>
1858        <param name="default.tomcat.port" value="80"/>
1859        <param name="local.http.url" value="http://${localhost.server.http}"/><!-- For port 80 over http, leave out port number in URL -->
1860        <param name="http.address.restriction" value=""/>
1861        <param name="https.comment.out.start" value="${comment.start}"/>
1862        <param name="https.comment.out.end" value="${comment.end}"/>
1863    </antcall>
1864
1865    <!-- Use OpenSSL instead of ZeroSSL to convert the certificate to the .pfx format that tomcat likes, using this cmd:
1866            GS3/bin/windows/openssl/bin/openssl.exe pkcs12 -inkey domain.key -in domain.crt -passin pass:pwd -passout pass:pwd -export -out ${keystore.file}
1867            GS3/bin/windows/openssl/bin/openssl.exe pkcs12 -inkey domain.key -in domain.crt -password pass:pwd -export -out ${keystore.file}
1868        where on windows, keystore.file = fullchain_and_prvtkey.pfx
1869    -->
1870    <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
1871      <arg value="/c" />
1872      <arg value="openssl.exe" />
1873      <arg value="pkcs12" />
1874      <arg value="-inkey" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key" />
1875      <arg value="-in" /><arg value="${packages.home}\tomcat\conf\https_cert\fullchain_and_prvtkey.crt" />
1876      <arg value="-export" />
1877      <arg value="-out" /><arg value="${packages.home}\tomcat\conf\https_cert\${keystore.file}" />
1878      <arg value="-name"/><arg value="greenstone3-tomcat"/><!-- See https://stackoverflow.com/questions/808669/convert-a-cert-pem-certificate-to-a-pfx-certificate -->
1879      <arg value="-password"/><arg value="pass:${keystore.pass}"/>
1880    </exec>
1881   
1882  </target>
1883
1884
1885  <!-- On Mac as on Linux, we need sudo permissions to setup https certification.
1886    But unlike on Linux, on Mac we only need to sudo when running tomcat on port 80
1887    and when stopping tomcat running on port 80. But we don't need to sudo on a Mac when calling le.pl.
1888    This also means all the files in https_cert have the correct (user, not root) permissions.
1889  -->
1890  <target name="setup-https-cert-mac">
1891   
1892    <echo>********** The included tomcat will be stopped, then restarted on port 80 and stopped again</echo>
1893   
1894    <!-- create folder packages\tomcat\webapps\ROOT\.well-known\acme-challenge -->
1895    <mkdir dir="${packages.home}/tomcat/webapps/ROOT/.well-known/acme-challenge"/>
1896    <mkdir dir="${packages.home}/tomcat/conf/https_cert"/>
1897 
1898    <!--
1899        See comments under setup-https-cert-WINDOWS
1900    -->
1901    <!-- We generate the account key named "privkey.key" in ${packages.home}\tomcat\conf\https_cert -->
1902    <if><bool><not><available file="${packages.home}/tomcat/conf/https_cert/privkey.key"/></not></bool>
1903      <exec executable="openssl" osfamily="mac" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">   
1904        <arg value="genrsa" />
1905        <arg value="-out" /><arg value="${packages.home}/tomcat/conf/https_cert/privkey.key" /><arg value="4096" />
1906      </exec>
1907    </if>
1908 
1909    <!-- Also generate the domain key (for csr-key parameter to zeroSSL's le.pl)
1910        ${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key
1911        Using 2048 instead of 4096 bits for this. See https://zerossl.com/usage.html#First_time_run_and_regular_use
1912    -->
1913    <if><bool><not><available file="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.key"/></not></bool>
1914      <exec executable="openssl" osfamily="mac" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
1915        <arg value="genrsa" />
1916        <arg value="-out" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.key" /><arg value="2048" />
1917      </exec>
1918    </if>
1919 
1920    <!-- stop the included tomcat (also stopping derby and solr) -->
1921    <antcall target="stop" />
1922   
1923    <!-- rerun tomcat on port 80
1924        See https://ant.apache.org/manual/Tasks/antcall.html -->
1925    <antcall target="start">
1926      <param name="sudo.or.not" value="/usr/bin/sudo" />
1927        <param name="localhost.port.http" value="80"/>
1928        <param name="default.tomcat.port" value="80"/>
1929        <param name="local.http.url" value="http://${localhost.server.http}"/><!-- For port 80 over http, leave out port number in URL -->
1930        <param name="http.address.restriction" value=""/><!-- don't prevent public access over http of port 80 -->
1931        <param name="https.comment.out.start" value="${comment.start}"/>
1932        <param name="https.comment.out.end" value="${comment.end}"/>
1933    </antcall>
1934 
1935    <!-- get the certificate: use zerossl's le.pl compiled up for Mac.
1936       For further notes, see under setup-https-cert-WINDOWS
1937    -->
1938
1939    <exec executable="perl" osfamily="mac" dir="${gs2build.home}/perllib/cpan/Crypt/LE/bin" spawn="false">
1940      <env key="PERL5LIB" value="${gs2build.home}/perllib/cpan${path.separator}${gs2build.home}/perllib/cpan/perl-5.18"/>
1941      <arg value="-S" />
1942      <arg value="${gs2build.home}/perllib/cpan/Crypt/LE/bin/le.pl" />
1943      <arg value="--key" /><arg value="${packages.home}/tomcat/conf/https_cert/privkey.key" />
1944      <arg value="--csr" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.csr" />
1945      <arg value="--csr-key" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.key" />
1946      <!--<arg value="==crt" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.crt" />-->
1947      <arg value="--crt" /><arg value="${packages.home}/tomcat/conf/https_cert/fullchain_and_prvtkey.crt" />
1948      <arg value="--domains" /><arg value="${https.cert.domains}" />
1949      <arg value="--path" /><arg value="${packages.home}/tomcat/webapps/ROOT/.well-known/acme-challenge" />
1950      <arg value="--generate-missing" />
1951      <arg value="--unlink" />
1952      <arg line="${https.testing}" /><!-- minus-minus-live if not testing, empty if testing. https://stackoverflow.com/questions/11840284/pass-arguments-to-apache-ant-exec-task-based-on-the-variables-value -->
1953      <!--<arg value="==export-pfx" /><arg value="${keystore.pass}" />
1954          <arg value="==tag-pfx" /><arg value="greenstone3-tomcat" />--><!-- not sure if this generates a keystore filename with ext .p12 or .pfx for Macs -->
1955      <arg line="${https.cert.renewal}" /><!-- renew command on windows/mac appends min-min-renew XX, where if the day the renewal is run is XX days within expiry, the certificate will get renewed. -->
1956    </exec>
1957
1958    <!-- stop the tomcat running on port 80 -->
1959    <antcall target="stop">
1960      <param name="sudo.or.not" value="/usr/bin/sudo" />
1961        <param name="localhost.port.http" value="80"/>
1962        <param name="default.tomcat.port" value="80"/>
1963        <param name="local.http.url" value="http://${localhost.server.http}"/>
1964        <param name="http.address.restriction" value=""/>
1965        <param name="https.comment.out.start" value="${comment.start}"/>
1966        <param name="https.comment.out.end" value="${comment.end}"/>
1967    </antcall>
1968
1969    <!-- Use OpenSSL instead of ZeroSSL to convert the certificate to the .pfx format that tomcat likes, using this cmd:
1970            GS3/bin/windows/openssl/bin/openssl.exe pkcs12 -inkey domain.key -in domain.crt -passin pass:pwd -passout pass:pwd -export -out ${keystore.file}
1971            GS3/bin/windows/openssl/bin/openssl.exe pkcs12 -inkey domain.key -in domain.crt -password pass:pwd -export -out ${keystore.file}
1972        where on windows, keystore.file = fullchain_and_prvtkey.pfx
1973    -->
1974    <exec executable="openssl" osfamily="mac" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
1975      <arg value="pkcs12" />
1976      <arg value="-inkey" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.key" />
1977      <arg value="-in" /><arg value="${packages.home}/tomcat/conf/https_cert/fullchain_and_prvtkey.crt" />
1978      <arg value="-export" />
1979      <arg value="-out" /><arg value="${packages.home}/tomcat/conf/https_cert/${keystore.file}" />
1980      <arg value="-name"/><arg value="greenstone3-tomcat"/><!-- See https://stackoverflow.com/questions/808669/convert-a-cert-pem-certificate-to-a-pfx-certificate -->
1981      <arg value="-password"/><arg value="pass:${keystore.pass}"/>
1982    </exec>
1983   
1984  </target>
1985 
1986
1987 
1988  <target name="setup-https-cert-linux">
1989      <!-- Running as
1990       ./certbot-auto certonly ==standalone ==preferred-challenges http ==email EMAIL -d DOMAINS
1991       expects input from stdin to accept (A) ToS and say Yes (Y) to sharing email.
1992       We can run in non-interactive mode as the user has at this stage already agreed
1993       to LetsEncrypt's Terms of Service and provided an email address.
1994      -->
1995      <exec executable="/bin/bash" dir="${basedir}/bin/${os.bin.dir}" failonerror="true">
1996    <arg value="./certbot-auto"/>
1997    <arg value="certonly"/>
1998    <arg line="${https.testing}"/><!-- https://stackoverflow.com/questions/11840284/pass-arguments-to-apache-ant-exec-task-based-on-the-variables-value -->
1999    <arg value="--standalone"/>
2000    <arg value="--non-interactive"/>
2001    <arg value="--agree-tos"/>
2002    <arg value="--preferred-challenges"/><arg value="http"/>
2003    <arg value="--email"/><arg value="${https.cert.email}"/>
2004    <arg value="--domains"/><arg value="${https.cert.domains}"/>
2005      </exec>
2006
2007      <!-- sudo openssl pkcs12 -export -out /tmp/DOMAIN_fullchain_and_key.p12 \
2008        -in /etc/letsencrypt/live/DOMAIN/fullchain.pem \
2009        -inkey /etc/letsencrypt/live/DOMAIN/privkey.pem \
2010        -name tomcat
2011        Must run as sudo because only admin has access to the pem files that admin
2012        generated in /etc/letsencrypt
2013        See https://computingforgeeks.com/tomcat-7-with-letsencrypt-ssl-certificate/
2014        but also https://community.letsencrypt.org/t/using-lets-encrypt-with-tomcat/41082
2015        which bypasses the step to generate the java keystore jks file
2016        and uses openssl to generate a pfx file instead of a p12 file
2017      -->
2018
2019      <exec executable="sudo" dir="/tmp" failonerror="true">
2020    <arg value="${basedir}/bin/${os.bin.dir}/openssl/bin/openssl"/>
2021    <arg value="pkcs12"/>
2022    <arg value="-export"/>
2023    <arg value="-out"/><arg value="/tmp/${tomcat.server}_fullchain_and_key.p12"/>
2024    <arg value="-in"/><arg value="/etc/letsencrypt/live/${tomcat.server}/fullchain.pem"/>
2025    <arg value="-inkey"/><arg value="/etc/letsencrypt/live/${tomcat.server}/privkey.pem"/>
2026    <arg value="-name"/><arg value="greenstone3-tomcat"/>
2027    <arg value="-password"/><arg value="pass:${keystore.pass}"/>
2028      </exec>
2029
2030      <!-- Finally, mkdir ${packages.home}/tomcat/conf/https_cert
2031       and copy the file /tmp/${tomcat.server}_fullchain_and_key.p12 into it
2032       and rename to a slightly shorter and simpler name,
2033       see https://stackoverflow.com/questions/8971187/ant-renaming-while-copying-file
2034       The file in tmp has root permissions. But copying it from tmp into
2035       the local account will give the copy local account permissions.
2036       Then sudo to remove the original copy in /tmp
2037      -->
2038      <mkdir dir="${packages.home}/tomcat/conf/https_cert"/>
2039      <!--<copy file="/tmp/${tomcat.server}_fullchain_and_key.p12" todir="${packages.home}/tomcat/conf/https_cert"/>-->
2040      <copy todir="${packages.home}/tomcat/conf/https_cert">
2041    <fileset file="/tmp/${tomcat.server}_fullchain_and_key.p12"/>
2042    <globmapper from="${tomcat.server}_fullchain_and_key.p12" to="${keystore.file}"/>
2043      </copy>
2044
2045      <exec executable="sudo" dir="/tmp" failonerror="true">
2046        <arg line="rm -f /tmp/${tomcat.server}_fullchain_and_key.p12" />
2047      </exec>
2048     
2049  </target>
2050 
2051 
2052  <!-- Revoke the certificate and remove it, including folders.
2053       See https://certbot.eff.org/docs/using.html#revoking-certificates
2054       which also states "if a certificate is a test certificate obtained via the
2055       ==staging or ==test-cert flag, that flag must be passed to the revoke subcommand."
2056  -->
2057  <target name="remove-https-cert">
2058    <echo>
2059      NOTE: If you're on Linux, you need to have sudo permissions to execute this target.
2060      Enter the sudo password if prompted.
2061    </echo>
2062    <!--
2063    On linux, we use certbot-auto.
2064    It says at https://github.com/certbot/certbot/issues/1741
2065    "you shouldn't run letsencrypt-auto [now called certbot-auto] as superuser,
2066    because the program will invoke sudo when it needs to automatically."   
2067    We need to send Y(es) as inputstring to confirm that the
2068    /etc/letsencrypt/live/${tomcat.server} folder can be deleted.
2069    Note osfamily="unix" is separate from osfamily="mac", which comes out handy here as we haven't set up certbot-auto for mac (yet).
2070    -->
2071    <exec executable="./certbot-auto" os="${os.linux},${os.solaris}" dir="${basedir}/bin/${os.bin.dir}" failonerror="true" inputstring="Y">
2072     <arg value="revoke"/>
2073     <arg line="${https.testing}"/>
2074     <arg value="--cert-path"/><arg value="/etc/letsencrypt/live/${tomcat.server}/cert.pem"/>
2075    </exec>
2076    <!-- The above command already deletes the folder when Y(es) was passed in. Explicitly deleting:
2077    <exec executable="./certbot-auto" dir="${basedir}/bin/${os.bin.dir}" failonerror="true">
2078    <arg value="delete"/>
2079    <arg value="==cert-name"/><arg value="${tomcat.server}"/>
2080    </exec>
2081    -->
2082   
2083    <!-- On Windows and Mac, we use zeroSSl. For the revoke command, see https://zerossl.com/usage.html#Certificate_revocation -->
2084    <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}" spawn="false">
2085      <arg value="/c" />
2086      <arg value="le${os.bitness}" />     
2087      <arg value="--key" /><arg value="${packages.home}\tomcat\conf\https_cert\privkey.key" />
2088      <arg value="--crt" /><arg value="${packages.home}\tomcat\conf\https_cert\fullchain_and_prvtkey.crt"/>
2089      <arg value="--revoke"/>
2090      <arg line="${https.testing}"/>
2091    </exec>
2092   
2093    <!-- On Mac, we use the le.pl we compiled up (Crypt::LE) and which needs to have PERL5LIB set correctly to run --> 
2094    <exec executable="perl" osfamily="mac" dir="${gs2build.home}/perllib/cpan/Crypt/LE/bin" spawn="false">
2095      <env key="PERL5LIB" value="${gs2build.home}/perllib/cpan${path.separator}${gs2build.home}/perllib/cpan/perl-5.18"/>
2096      <arg value="-S" />
2097      <arg value="${gs2build.home}/perllib/cpan/Crypt/LE/bin/le.pl" />
2098      <arg value="--key" /><arg value="${packages.home}/tomcat/conf/https_cert/privkey.key" />
2099      <arg value="--crt" /><arg value="${packages.home}/tomcat/conf/https_cert/fullchain_and_prvtkey.crt"/>
2100      <arg value="--revoke"/>
2101      <arg line="${https.testing}"/>
2102    </exec>
2103
2104    <!-- And remove the https_cert folder -->
2105    <delete dir="${packages.home}/tomcat/conf/https_cert"/>
2106  </target>
2107 
2108 
2109    <!-- Renewing existing https certificate
2110       Linux:
2111       https://certbot.eff.org/docs/using.html#renewing-certificates
2112       ./path/to/GS3/bin/linux/certbot-auto renew ==quiet ==no-self-upgrade
2113       Windows: reuse Windows issuance target
2114       see https://zerossl.com/usage.html#Certificate_renewal
2115    -->
2116  <target name="renew-existing-https-cert">
2117    <echo>
2118      NOTE: To run this target,
2119          * ensure nothing is running on port 80
2120          * if you're on Linux or Mac, you need to have sudo permissions. Enter the sudo password if prompted.     
2121
2122      If you want your cronjob to renew a certificate, you can add pre and post hooks
2123      refer to https://certbot.eff.org/docs/using.html#renewing-certificates
2124      For more information run:
2125         ./path/to/GS3/bin/linux/certbot-auto --help renew
2126    </echo>
2127    <exec executable="./certbot-auto" os="${os.linux},${os.solaris}" dir="${basedir}/bin/${os.bin.dir}" failonerror="true">
2128     <arg value="renew"/>
2129     <arg value="--quiet"/>
2130     <arg value="--no-self-upgrade"/>
2131    </exec>
2132   
2133    <!-- For renewal on Windows or Mac, we use ZeroSSL as intermediary between GS3 and Let's Encrypt.
2134     And when using ZeroSSL we need to re-run the original (issuance) command and append "min-min-renew XX" to it,
2135     where if it's within XX days of expiry, the certificate will get renewed.
2136     See https://zerossl.com/usage.html#Certificate_renewal -->
2137    <if><bool><or>
2138      <istrue value="${current.os.iswindows}"/>
2139      <istrue value="${current.os.ismac}"/>
2140      </or></bool>
2141     
2142      <input addproperty="https.other.domains">Enter a comma separated list of additional domains besides tomcat.server=${tomcat.server} that you registered on issuance, if any</input>
2143      <condition property="https.cert.domains" value="${tomcat.server},${https.other.domains}" else="${tomcat.server}">
2144    <and>
2145      <isset property="https.other.domains" />
2146      <not><matches string="${https.other.domains}" pattern="^\s*$"/></not>
2147    </and>
2148      </condition>
2149      <if><bool><istrue value="${current.os.iswindows}"/></bool>
2150    <antcall target="setup-https-cert-windows">
2151      <param name="https.cert.renewal" value="--renew 10"/>         
2152    </antcall>
2153    <else>
2154      <antcall target="setup-https-cert-mac">
2155        <param name="https.cert.renewal" value="--renew 10"/>           
2156      </antcall>
2157    </else>
2158      </if>
2159    </if>
2160  </target>
2161
2162  <!-- ======================= Tomcat Targets ========================== -->
2163 
2164  <!-- this target downloads and installs Tomcat -->
2165  <!-- we download tomcat (version 7 for Java 1.5 and later, version 5 for Java 1.4 plus the 1.4 compatibility package). -->
2166  <target name="prepare-tomcat" depends="init,setup-proxy" if="tomcat.islocal"
2167    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">
2168  <if>
2169      <bool>
2170        <not><available file="${packages.home}/tomcat/.flagfile"/></not>
2171      </bool>
2172
2173      <!-- check that packages dir is there -->
2174      <mkdir dir="${packages.home}"/>
2175      <get src="http://www.greenstone.org/gs3files/${tomcat.version}.zip"
2176        dest="${packages.home}/${tomcat.version}.zip"
2177        usetimestamp="true"/>
2178      <unzip src="${packages.home}/${tomcat.version}.zip"
2179        dest="${packages.home}"/>
2180     
2181      <!-- If we are using Java 1.4, we'd be using tomcat 5.5 in which case
2182      we would need to have the tomcat compat package to work with Java 1.4-->
2183      <if>
2184    <bool><equals arg1="1.4" arg2="${ant.java.version}"/></bool>
2185    <get src="http://www.greenstone.org/gs3files/${tomcat.version}-compat.zip"
2186      dest="${packages.home}/${tomcat.version}-compat.zip"
2187      usetimestamp="true"/>
2188    <unzip src="${packages.home}/${tomcat.version}-compat.zip"
2189      dest="${packages.home}"/>
2190      </if>
2191     
2192      <!-- delete any existing tomcat -->
2193      <delete dir="${packages.home}/tomcat"/>
2194      <move todir="${packages.home}/tomcat">
2195        <fileset dir="${packages.home}/${tomcat.version}"/>
2196      </move>
2197     
2198      <!-- To avoid the CGI permissions error appearing continuously in the (localhost) log,
2199        need privileged=true set in the root context.xml file too, not just greenstone context file.
2200        See http://stackoverflow.com/questions/9845936/tomcat-v7-0-load-exception-marking-servlet-ssi-as-unavailable/10305471#10305471
2201        For usage of IfTask IsLessThan: http://antelope.stage.tigris.org/nonav/docs/manual/bk03ch05s02.html -->
2202      <if><bool><not><islessthan arg1="${tomcat.version.major}" arg2="7"/></not></bool>     
2203        <copy file="${basedir}/resources/tomcat/root_context.xml.in" tofile="${packages.home}/tomcat/conf/context.xml" overwrite="true" />     
2204      </if>
2205       
2206     
2207      <!--
2208      <copy file="${basedir}/resources/tomcat/setclasspath.bat"
2209        tofile="${packages.home}/tomcat/bin/setclasspath.bat"
2210        overwrite="true"/>
2211      <copy file="${basedir}/resources/tomcat/setclasspath.sh"
2212        tofile="${packages.home}/tomcat/bin/setclasspath.sh"
2213        overwrite="true"/>
2214      -->
2215      <!-- make sure we have execute permission for the .sh files -->
2216      <chmod dir="${packages.home}/tomcat/bin" perm="ugo+rx"
2217        includes="*.sh"/>   
2218
2219      <echo file="${packages.home}/tomcat/.flagfile">
2220        the timestamp of this file is the time that tomcat was extracted from the zip files.
2221        it is used to figure out whether the files need to be refreshed or not in `ant prepare-tomcat`
2222      </echo>
2223
2224      <!-- this is not strictly a prepare tomcat thing, but if one changes
2225      Java, then they need to change tomcat as well, so might as well call
2226      it here -->
2227      <antcall target="configure-java-version"/>
2228      <else>
2229        <echo>Tomcat has been prepared, will not prepare</echo>
2230        <echo>Delete ${packages.home}/tomcat/.flagfile to force refresh</echo>
2231      </else>
2232
2233    </if>
2234
2235  </target> 
2236 
2237  <target name="configure-tomcat" depends="init,configure-tomcat-local,configure-tomcat-external"/>
2238 
2239  <target name="configure-tomcat-local" depends="init,perl-for-building" if="tomcat.islocal">
2240    <!-- re-setup the server.xml file -->
2241    <copy file="${basedir}/resources/tomcat/server_tomcat${tomcat.version.major}.xml.in"
2242        tofile="${packages.home}/tomcat/conf/server.xml" overwrite="true">
2243      <filterset>
2244        <filter token="shutdown-port" value="${tomcat.shutdown.port}"/>
2245    <filter token="tomcat.ajp.port" value="${tomcat.ajp.port}"/>
2246    <filter token="https.redirect.port" value="${https.redirect.port}"/>
2247    <filter token="localhost.port.http" value="${localhost.port.http}"/>
2248    <filter token="tomcat.port.https" value="${tomcat.port.https}"/>
2249    <!-- Relative path preferred for keystore.file, in case tomcat is moved elsewhere -->
2250    <!--<filter token="keystore.file" value="conf/https_cert/${tomcat.server}.jks" />-->
2251    <!--ON UNIX: <filter token="keystore.file" value="conf/https_cert/fullchain_and_prvtkey.p12" />-->
2252    <!--ON WINDOWS: <filter token="keystore.file" value="conf/https_cert/fullchain_and_prvtkey.pfx" />-->
2253    <filter token="keystore.file" value="conf/https_cert/${keystore.file}" />
2254    <!-- tomcat Connector's keystoreType param defaults to JKS (Java keystore), see https://tomcat.apache.org/tomcat-7.0-doc/config/http.html
2255    We'll follow the instructions at https://community.letsencrypt.org/t/using-lets-encrypt-with-tomcat/41082,
2256    https://www.ssl.com/how-to/create-a-pfx-p12-certificate-file-using-openssl/
2257    and https://computingforgeeks.com/tomcat-7-with-letsencrypt-ssl-certificate/
2258    (minus the keytool step) and use the PKCS12 file generated by openssl directly,
2259    instead of an additional step to generate the java keystore file from that -->
2260    <filter token="keystore.type" value="PKCS12"/>
2261    <filter token="keystore.pass" value="${keystore.pass}"/>
2262    <!--
2263        if server.protocols doesn't contain http, then http is only to be locally available (e.g. for solr servlet on 127.0.0.1)
2264        In that case, see https://serverfault.com/questions/218666/how-to-configure-tomcat-to-only-listen-to-127-0-0-1
2265    -->
2266    <filter token="http.address.restriction" value="${http.address.restriction}"/> 
2267    <filter token="https.comment.out.start" value="${https.comment.out.start}"/>
2268    <filter token="https.comment.out.end" value="${https.comment.out.end}"/>
2269      </filterset>
2270    </copy>
2271
2272    <!-- set up the solr context -->
2273
2274    <!-- First work out the IPv4 address for this machine -->
2275    <exec executable="${basedir}/bin/script/IPv4.sh" os="${os.unix}" failonerror="false" outputproperty="ipv4.val">
2276      <arg value="-format-for-tomcat-context"/>
2277    </exec>
2278    <exec executable="${basedir}/bin/script/IPv4.bat" osfamily="windows" failonerror="false" outputproperty="ipv4.val">
2279      <arg value="-format-for-tomcat-context"/>
2280    </exec>
2281
2282    <copy file="${basedir}/ext/solr/solr-tomcat-context.xml.in" tofile="${packages.home}/tomcat/conf/Catalina/localhost/solr.xml" overwrite="true">
2283      <filterset>
2284    <filter token="solr.context" value="${solr.context}"/>
2285        <filter token="gsdl3webhome" value="${web.writablehome}"/>
2286    <filter token="tomcathome" value="${basedir}/packages/tomcat"/>
2287    <filter token="IPv4" value="${ipv4.val}"/>
2288      </filterset>
2289    </copy>
2290
2291    <!-- set up the greenstone3 context, it may have a custom name specified in build.properties -->
2292    <if><bool><not><equals arg1="greenstone3" arg2="${greenstone.context}"></equals></not></bool>
2293        <copy file="${basedir}/resources/tomcat/greenstone3.xml.in" tofile="${basedir}/resources/tomcat/${greenstone.context}.xml.in" overwrite="true"/>
2294    </if>
2295    <copy file="${basedir}/resources/tomcat/${greenstone.context}.xml.in" tofile="${packages.home}/tomcat/conf/Catalina/localhost/${greenstone.context}.xml" overwrite="true">
2296      <filterset>
2297        <filter token="gsdl3webhome" value="${web.home}"/>
2298        <filter token="gsdl3webwritablehome" value="${web.writablehome}"/>
2299    <filter token="privilegedattribute" value="${privileged.attribute}"/>
2300    <filter token="allowedIPs" value="${allowed.IPs}"/>
2301    <filter token="derbyserver" value="${derby.server}"/>
2302    <filter token="derbyserverport" value="${derby.server.port}"/>
2303      </filterset>
2304    </copy>
2305    <if>
2306        <bool>
2307            <and>
2308                <available file="${packages.home}/tomcat/conf/Catalina/localhost/greenstone3.xml"/>
2309                <not><equals arg1="greenstone3" arg2="${greenstone.context}"></equals></not>
2310            </and>
2311        </bool>
2312        <delete file="${packages.home}/tomcat/conf/Catalina/localhost/greenstone3.xml"/>
2313    </if>
2314   
2315    <!-- set up the greenstone3 web.xml file -->
2316    <copy file="${basedir}/resources/tomcat/web8.xml.in" tofile="${packages.home}/tomcat/conf/web.xml" overwrite="true">
2317      <filterset>
2318    <filter token="perlpath" value="${perl.path}"/>
2319      </filterset>
2320    </copy>
2321  </target>
2322 
2323  <target name="configure-tomcat-external" depends="init" unless="tomcat.islocal">
2324    <!-- re-setup the server.xml file -->
2325    <!-- need to edit the config file, or do we get the user to do this???-->
2326  </target>
2327
2328  <target name="configure-solr-ext" depends="init" >
2329    <!-- re-setup the web/ext/solr/solr.xml file -->
2330    <copy file="${web.home}/ext/solr/solr.xml.in"
2331      tofile="${gsdl3.writablehome}/ext/solr/solr.xml" filtering="true" overwrite="true">
2332      <filterset>
2333        <filter token="gsdl3.home" value="${src.gsdl3.home.unix}"/>
2334        <filter token="gsdl3.writablehome" value="${src.gsdl3.writablehome.unix}"/>
2335      </filterset>
2336    </copy>
2337  </target>
2338 
2339  <!-- This target runs tomcat's "bin/catalina.bat(.sh) jpda start"
2340       to allow debugging the running GS3 server in Eclipse. See the instructions at
2341       http://www.wikijava.org/wiki/Debugging_a_servlet_with_tomcat_and_Eclipse_tutorial
2342       on how to use this with eclipse
2343    -->
2344  <target name="debug-start-tomcat" description="Startup Tomcat for debugger" depends="init" if="tomcat.islocal">
2345    <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
2346    <property name="tomcat.path" refid="local.tomcat.path"/>
2347
2348    <if><bool>
2349    <isset property="fedora.maxpermsize"/></bool>
2350      <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx800M -Dcantaloupe.config=&quot;${basedir}/cantaloupe.properties&quot; ${readonly.catalina.opts} ${fedora.maxpermsize}"/>
2351      <else>
2352    <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx800M -Dcantaloupe.config=&quot;${basedir}/cantaloupe.properties&quot; ${readonly.catalina.opts}"/>
2353      </else>
2354    </if>
2355
2356    <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
2357    <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
2358   
2359    <exec executable="${catalina.home}/bin/catalina.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
2360      <arg value="jpda" />
2361      <arg value="start" />
2362      <env key="JPDA_ADDRESS" value="8000"/> <!-- for debugging Tomcat in Eclipse -->
2363      <env key="JPDA_TRANSPORT" value="dt_socket"/> <!-- for debugging Tomcat in Eclipse -->
2364      <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
2365      <env key="PATH" path="${tomcat.path}"/>
2366      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
2367      <env key="CATALINA_HOME" value="${catalina.home}"/>
2368      <env key="CLASSPATH" path="${tomcat.classpath}"/>
2369      <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
2370      <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
2371      <env key="WNHOME" path="${wn.home}"/>
2372      <env key="FEDORA_HOME" path="${fedora.home}"/>
2373    </exec>
2374    <exec executable="${catalina.home}/bin/catalina.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="true">
2375      <arg value="jpda" />
2376      <arg value="start" />
2377      <env key="JPDA_ADDRESS" value="8000"/> <!-- for debugging Tomcat in Eclipse -->
2378      <env key="JPDA_TRANSPORT" value="dt_socket"/> <!-- for debugging Tomcat in Eclipse -->
2379      <env key="GSDLOS" value="windows"/>
2380      <env key="GSDL3HOME" value="${basedir}"/>
2381      <env key="Path" path="${tomcat.path}"/>
2382      <env key="PATH" path="${tomcat.path}"/>
2383      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
2384      <env key="CATALINA_HOME" value="${catalina.home}"/>
2385      <env key="CLASSPATH" path="${tomcat.classpath}"/>
2386      <env key="FEDORA_HOME" path="${fedora.home}"/>
2387    </exec>
2388    <!-- wait for the server to startup in case other targets need it running -->
2389    <waitfor maxwait="5" maxwaitunit="second">
2390      <and>
2391        <socket server="${tomcat.server}" port="${default.tomcat.port}"/>
2392    <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/index.html"/>-->
2393    <http url="${local.http.url}${app.path}/index.html"/>
2394      </and>
2395    </waitfor>
2396  </target> 
2397 
2398  <target name="start-tomcat" description="Startup only Tomcat" depends="check-tomcat-started">
2399
2400    <if><bool><istrue value="${tomcat.isstarted}"/></bool>
2401      <echo>**************************************</echo>
2402      <echo>A WEB SERVER IS ALREADY RUNNING ON ${default.server.protocol}://${tomcat.server}:${default.tomcat.port} (${local.http.url}). NOT STARTING.</echo>
2403      <echo>**************************************</echo>
2404      <else>
2405    <antcall target="force-start-tomcat"/>
2406      </else>
2407      </if>
2408  </target>
2409
2410  <!-- Another way: http://ptrthomas.wordpress.com/2006/03/25/how-to-start-and-stop-tomcat-from-ant/ -->
2411  <target name="force-start-tomcat" description="Startup only Tomcat" depends="init" if="tomcat.islocal">
2412
2413    <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
2414    <property name="tomcat.path" refid="local.tomcat.path"/>
2415
2416    <if><bool>
2417    <isset property="fedora.maxpermsize"/></bool>
2418      <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx800M -Dcantaloupe.config=${basedir}/cantaloupe.properties ${readonly.catalina.opts} ${fedora.maxpermsize}"/>
2419      <else>
2420    <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx800M -Dcantaloupe.config=${basedir}/cantaloupe.properties ${readonly.catalina.opts}"/>
2421      </else>
2422    </if>
2423
2424    <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
2425    <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
2426
2427    <!-- using osfamily instead of testing os against os.windows list of recognised windows versions
2428     so that future windows versions are included. See http://simonharrer.wordpress.com/tag/osfamily/
2429    Can't use the osfamily test for linux-type machines as a group since osfamily=unix is separate from osfamily=mac,
2430    see http://ant-contrib.sourceforge.net/tasks/tasks/osfamily.html -->
2431
2432    <!--<exec executable="${catalina.home}/bin/startup.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">-->
2433    <exec executable="${sudo.or.not}" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
2434      <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
2435      <env key="GSDL3HOME" value="${basedir}"/>
2436      <env key="PATH" path="${tomcat.path}"/>
2437      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
2438      <env key="CATALINA_HOME" value="${catalina.home}"/>
2439      <env key="CLASSPATH" path="${tomcat.classpath}"/>
2440      <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
2441      <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
2442      <env key="WNHOME" path="${wn.home}"/>
2443      <env key="FEDORA_HOME" path="${fedora.home}"/>
2444      <arg value="${catalina.home}/bin/startup.sh"/>
2445    </exec>
2446    <exec executable="${catalina.home}/bin/startup.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="true">
2447      <env key="GSDLOS" value="windows"/>
2448      <env key="GSDL3HOME" value="${basedir}"/>
2449      <env key="Path" path="${tomcat.path}"/>
2450      <env key="PATH" path="${tomcat.path}"/>
2451      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
2452      <env key="CATALINA_HOME" value="${catalina.home}"/>
2453      <env key="CLASSPATH" path="${tomcat.classpath}"/>
2454      <env key="FEDORA_HOME" path="${fedora.home}"/>
2455    </exec>
2456    <!-- wait for the server to startup in case other targets need it running -->
2457    <waitfor maxwait="5" maxwaitunit="second">
2458      <and>
2459        <socket server="${tomcat.server}" port="${default.tomcat.port}"/>
2460        <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/index.html"/>-->
2461        <http url="${local.http.url}${app.path}/index.html"/>
2462      </and>
2463    </waitfor>
2464
2465  </target>
2466
2467  <!--ant task http: http://www.jajakarta.org/ant/ant-1.6.1/docs/ja/manual/api/org/apache/tools/ant/taskdefs/condition/Http.html-->
2468  <target name="reconfigure" description="Reconfigure the message router">
2469    <waitfor maxwait="5" maxwaitunit="second">
2470      <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c"/>-->
2471      <http url="${local.http.url}${app.path}${server.default.servlet}?a=s&amp;sa=c"/>
2472    </waitfor>
2473  </target>
2474
2475  <!--Command-line args to Ant: http://www.jguru.com/faq/view.jsp?EID=471794-->
2476  <target name="reconfigure-collection" description="Reconfigure the collection">
2477    <waitfor maxwait="5" maxwaitunit="second">
2478      <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c&amp;sc=${collection}"/>-->
2479      <http url="${local.http.url}${app.path}${server.default.servlet}?a=s&amp;sa=c&amp;sc=${collection}"/>
2480    </waitfor>
2481  </target>
2482
2483  <!-- windows: do we want to launch a webrowser?? -->
2484  <!-- shouldn't this test whether anything is running first?
2485       It's safer to always attempt to stop tomcat: that way we won't be dependent on the right time
2486       to check whether the server is stopped or still running before attempting to start again.
2487       This target, which was recently called force-stop-tomcat for a while but is back to being
2488       called stop-tomcat, now hides the Java exception output that appears whenever tomcat is already
2489       stopped as happens when stop-tomcat is called consecutively. -->
2490  <target name="force-stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal">
2491    <!--<exec executable="${catalina.home}/bin/shutdown.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">-->
2492    <exec executable="${sudo.or.not}" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
2493      <env key="FEDORA_HOME" path="${fedora.home}"/>
2494      <env key="CATALINA_HOME" value="${catalina.home}"/>
2495      <arg value="${catalina.home}/bin/shutdown.sh"/>
2496      <arg line=">/dev/null 2>&amp;1"/>
2497    </exec>
2498    <exec executable="${catalina.home}/bin/shutdown.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="false">
2499      <env key="FEDORA_HOME" path="${fedora.home}"/>
2500      <env key="CATALINA_HOME" value="${catalina.home}"/>
2501      <arg line=">nul 2>&amp;1"/>
2502    </exec>   
2503  </target>
2504
2505  <!-- Can also try the "socket" condition in place of the "http" condition
2506       And also use a <waitfor> in place of <condition>, such as:
2507       <waitfor maxwait="5" maxwaitunit="second" timeoutproperty="tomcat.isstopped"><http url="..."/></waitfor>
2508       The http URL resolves to host:port/greenstone3
2509       Condition uses <http/> rather than <socket/> for testing, since if the server was stopped, the socket
2510       might still be in use for some moments. We test the URL with the http condition since it's likelier to
2511       fail sooner if the server has indeed been stopped. -->
2512  <target name="check-tomcat-running">
2513    <condition property="tomcat.isrunning">
2514      <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}"/>-->
2515      <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}"/>--><!-- untrusted certificates won't work, so don't test https urls-->
2516      <http url="${local.http.url}"/><!-- testing the local http url instead -->
2517    </condition>
2518  </target>
2519 
2520  <!--
2521      <target name="verbose-check-tomcat-running">
2522      <condition property="tomcat.isrunning" value="true" else="false">
2523      <http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}"/>
2524      <http url="${local.http.url}"/>
2525      </condition>
2526      <echo>Tomcat is running: ${tomcat.isrunning}</echo>
2527      </target>
2528  -->
2529  <target name="verbose-check-tomcat-running" depends="check-tomcat-running">   
2530    <if>
2531      <bool>
2532    <istrue value="${tomcat.isrunning}"/>
2533      </bool>     
2534      <echo>Tomcat is running: ${tomcat.isrunning}</echo>
2535      <else><echo>Tomcat is running: false</echo></else><!-- tomcat.isrunning not set -->
2536    </if>
2537  </target> 
2538 
2539  <!-- Need a copy of the check-tomcat-running target with a distinct property, because ant restart runs
2540       both stop and start, both of which need to do tomcat checks. Each property can be set only once during
2541       an invocation with ant. So ant restart will need two properties to store each of the tomcat checks -->
2542  <target name="check-tomcat-started">
2543    <condition property="tomcat.isstarted">
2544      <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}"/>-->
2545      <http url="${local.http.url}"/>
2546    </condition>
2547  </target>
2548
2549
2550
2551  <!-- stop-tomcat checks if the tomcat server is already running. If it appears to be running
2552       (regardless of whether tomcat was just starting to shut down), this target calls force-stop-tomcat
2553       to issue the shutdown command to tomcat. Then it waits for at most 15 seconds for the server to
2554       actually stop by checking the socket at which tomcat listens every second, printing a warning
2555       at the end of the max wait time of 15 seconds if tomcat was still running. -->
2556  <target name="stop-tomcat" description="Shutdown only Tomcat if running" depends="check-tomcat-running" if="tomcat.isrunning">
2557     <antcall target="force-stop-tomcat"/>
2558
2559     <property name="wait.numchecks" value="15"/>
2560     <echo>Waiting for the server to shutdown... (${wait.numchecks} seconds max)</echo>
2561     <waitfor maxwait="${wait.numchecks}" maxwaitunit="second" checkevery="1" checkeveryunit="second" timeoutproperty="tomcat.timedout">
2562       <not><socket server="${tomcat.server}" port="${default.tomcat.port}"/></not>
2563     </waitfor>
2564     
2565     <if>
2566       <bool>
2567     <isset property="${tomcat.timedout}"/>
2568       </bool>
2569       <property name="tomcat.isrunning" value="true"/>
2570       <echo>WARNING: Checked the socket ${wait.numchecks} times, but port ${default.tomcat.port} is still busy.</echo>
2571       <else>
2572     <echo>Tomcat is stopped.</echo>
2573     <property name="tomcat.isrunning" value="false"/>
2574       </else>
2575     </if>
2576  </target>
2577
2578  <target name="restart-tomcat" description="Shutdown and restart only Tomcat" depends="init,stop-tomcat,force-start-tomcat"/>
2579
2580  <target name="setup-catalina-ant-tasks">
2581    <!-- Configure the custom Ant tasks for the Tomcat Manager application -->
2582    <taskdef name="deploy"    classname="org.apache.catalina.ant.DeployTask"
2583      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2584    <taskdef name="list"      classname="org.apache.catalina.ant.ListTask"
2585      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2586    <taskdef name="reload"    classname="org.apache.catalina.ant.ReloadTask"
2587      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2588    <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"
2589      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2590    <taskdef name="roles"     classname="org.apache.catalina.ant.RolesTask"
2591      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2592    <taskdef name="start"     classname="org.apache.catalina.ant.StartTask"
2593      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2594    <taskdef name="stop"      classname="org.apache.catalina.ant.StopTask"
2595      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2596    <taskdef name="undeploy"  classname="org.apache.catalina.ant.UndeployTask"
2597      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2598  </target>
2599
2600  <!-- http://blog.andrewbeacock.com/2007/11/how-to-truncate-log-file-using-ubuntu.html
2601    Doing "cat </dev/null > packages/tomcat/logs/catalina.out" doesn't work as an ant target.
2602    It seems to have a problem with cat or </dev/null, with or without the < sign. -->
2603  <target name="reset-logs" description="Empties catalina.out, greenstone.log and contents of web/logs/tmp">
2604    <echo>Truncating catalina.out, solr.log, greenstone.log and server.log, and emptying ${web.writablehome}/logs/tmp</echo>   
2605    <exec executable="rm" os="${os.unix}" dir="${catalina.home}/logs" spawn="false">
2606      <arg value="-f"/>
2607      <arg value="catalina.out"/>
2608    </exec>
2609    <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
2610      <arg value="-f"/>
2611      <arg value="greenstone.log"/>
2612    </exec>
2613    <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
2614      <arg value="-f"/>
2615      <arg value="server.log"/>
2616    </exec>
2617
2618    <exec executable="touch" os="${os.unix}" dir="${catalina.home}/logs"
2619    spawn="false">
2620      <arg value="catalina.out"/>
2621    </exec>
2622    <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
2623      spawn="false">
2624      <arg value="greenstone.log"/>
2625    </exec>
2626    <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
2627      spawn="false">
2628      <arg value="server.log"/>
2629    </exec>
2630
2631    <exec executable="cmd" osfamily="windows" dir="${catalina.home}/logs" spawn="false">
2632      <arg line="/c echo. > catalina.out"/>
2633    </exec>
2634    <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
2635      <arg line="/c echo. > greenstone.log"/>
2636    </exec>
2637    <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
2638      <arg line="/c echo. > server.log"/>
2639    </exec>
2640
2641    <!-- if ext/solr/logs/solr.log exists, truncate it -->
2642    <if><bool><available file="${solr-ext.home}/logs/solr.log" type="file"/></bool>     
2643        <exec executable="rm" os="${os.unix}" dir="${solr-ext.home}/logs" spawn="false">
2644          <arg value="-f"/>
2645          <arg value="solr.log"/>
2646        </exec>
2647        <exec executable="touch" os="${os.unix}" dir="${solr-ext.home}/logs" spawn="false">
2648          <arg value="solr.log"/>
2649        </exec>   
2650        <exec executable="cmd" osfamily="windows" dir="${solr-ext.home}/logs" spawn="false">
2651          <arg line="/c echo. > solr.log"/>
2652        </exec>
2653    </if>
2654   
2655    <if>
2656      <bool><available file="${web.writablehome}/logs/tmp" type="dir"/></bool>
2657      <delete>
2658    <fileset dir="${web.writablehome}/logs/tmp" includes="**/*"/>
2659      </delete>
2660    </if>
2661  </target>
2662
2663  <target name="clear-tomcat-sessions" description="Clear the Tomcat Session info." depends="init">
2664    <exec executable="cmd" osfamily="windows" dir="${catalina.home}/work/Catalina/localhost/greenstone3" spawn="false">
2665      <arg line="/c echo. > SESSIONS.ser"/>
2666    </exec>
2667    <exec executable="rm" os="${os.unix}" dir="${catalina.home}/work/Catalina/localhost/greenstone3" spawn="false">
2668      <arg value="-f"/>
2669      <arg value="SESSIONS.ser"/>
2670    </exec>
2671
2672  </target>
2673  <!-- ======================= ant Targets ============================ -->
2674  <target name="prepare-ant" depends="init">
2675    <if>
2676      <bool>
2677        <not><available file="${packages.home}/ant/.flagfile"/></not>
2678      </bool>
2679      <property name="ant.download.version" value="apache-ant-1.9.13" />
2680      <get src="http://www.greenstone.org/gs3files/${ant.download.version}-bin.zip"
2681        dest="${packages.home}/${ant.download.version}-bin.zip"
2682        usetimestamp="true"/>
2683      <unzip src="${packages.home}/${ant.download.version}-bin.zip"
2684        dest="${packages.home}"/>
2685      <move todir="${packages.home}/ant">
2686        <fileset dir="${packages.home}/${ant.download.version}"/>
2687      </move>
2688      <echo file="${packages.home}/ant/.flagfile">
2689        the timestamp of this file is the time that ant was extracted from the zip files.
2690        it is used to figure out whether the files need to be refreshed or not in `ant prepare-ant`
2691      </echo>
2692
2693      <else>
2694        <echo>Ant has been prepared, will not prepare</echo>
2695        <echo>Delete ${packages.home}/ant/.flagfile to force refresh</echo>
2696      </else>
2697
2698    </if>
2699  </target>
2700
2701  <!-- ======================= Admin Targets ============================ --> 
2702
2703  <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
2704    See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
2705    But you can do: echo mypassword | ant config-admin -->
2706  <target name="config-admin" description="Reset admin password">
2707    <input addproperty="admin.password" defaultvalue="admin" message="New admin password (3-20 characters):&gt;">
2708      <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
2709    </input>
2710    <!--<echo>PWD: ${admin.password}</echo>-->
2711    <antcall target="update-userdb">
2712      <param name="user.username" value="admin"/>
2713      <param name="user.password" value="${admin.password}"/>
2714      <param name="user.groups" value=""/>
2715      <param name="user.status" value=""/>
2716      <param name="user.comment" value="Password updated."/>
2717      <param name="user.email" value=""/>
2718    </antcall>
2719  </target>
2720
2721  <target name="config-user" description="Add or modify users" depends="get-user-data,update-userdb"/>
2722
2723  <target name="get-user-data" description="Get user details">
2724    <input addproperty="user.username" message="Username:&gt;"/>
2725    <input addproperty="user.password" defaultvalue="" message="Password (3-20 characters):&gt;">
2726      <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
2727    </input>
2728    <input addproperty="user.groups" defaultvalue="" message="Groups (comma-separated list, e.g. personal-collections-editor):&gt;"/>
2729    <input addproperty="user.status" defaultvalue="true" message="Enabled (true/false):&gt;"/>
2730    <input addproperty="user.comment" defaultvalue="" message="Comment:&gt;"/>
2731    <input addproperty="user.email" defaultvalue="" message="Email:&gt;"/>
2732  </target>
2733
2734  <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
2735       See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
2736       But you can do: echo mypassword | ant config-admin -->
2737  <target name="update-userdb" description="Add or modify users" depends="start-derby">
2738
2739    <!--
2740       We're now using derby networked server, so stopping and starting tomcat is not necessary.
2741       For embedded derby: stop tomcat if running, since derby db is embedded
2742       and only allows connections from one jvm instance at a time
2743     See http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html
2744     The ${tomcat.isrunning} property is set by the depends-target "check-tomcat-running" -->
2745   
2746    <!-- Need the derby networked server to be running in order to modify the usersDB.
2747     The start-derby task will check if derby is already running (if not, ${derby.isstarted} will
2748     be false) and will only start up networked derby if it is not already running.
2749     The ${derby.isstarted} property is set by the depends-target "start-derby", since it won't
2750     set the property if called with antcall (like launching in a subshell). Have to use 'depends'.
2751     We'll check ${derby.isstarted} at the end to stop derby again if we had to start it up now.-->
2752    <!--<antcall target="start-derby"/>-->
2753
2754    <!-- wait a max of 5 seconds for the derbyserver to have started up -->
2755    <waitfor maxwait="5" maxwaitunit="second">
2756      <socket server="${derby.server}" port="${derby.server.port}"/>
2757    </waitfor>
2758
2759    <!--<echo>${admin.password}</echo>--> <!-- for testing -->
2760    <echo>gsdl3.writablehome: ${gsdl3.writablehome}</echo> <!-- for testing -->
2761    <echo>web.home: ${web.home}</echo> <!-- for testing -->
2762    <java classname="org.greenstone.gsdl3.util.ModifyUsersDB">
2763      <classpath refid="compile.classpath"/> <!--for ${web.lib}/gsdl3.jar and supporting files-->
2764      <sysproperty key="gsdl3.writablehome" value="${gsdl3.writablehome}" /> <!-- passes -D<syspropKey=syspropVal> to java class ModifyUsersDB. Available in java code as System.getProperty("syspropKey") -->
2765      <arg file="${web.home}/etc/usersDB"/>
2766      <arg value="${user.username}"/>
2767      <arg value="password=${user.password}"/>
2768      <arg value="groups=${user.groups}"/>
2769      <arg value="status=${user.status}"/>
2770      <arg value="comment=${user.comment}"/>
2771      <arg value="email=${user.email}"/>
2772    </java>
2773
2774    <!-- Need to stop networked derby again if we ran it for this target with the depends=start-derby call.
2775     The test here is for <not>derby.isstarted</not>, as the property would be the same as before
2776     derby was started, since properties are immutable within a single ant command. -->
2777    <if>
2778      <bool>
2779    <not><istrue value="${derby.isstarted}"/></not>
2780      </bool>
2781      <antcall target="force-stop-derby"/>
2782    </if>
2783
2784  </target>
2785
2786
2787  <!-- ======================= Axis Targets ============================ --> 
2788 
2789  <target name="prepare-axis" depends="init">
2790
2791    <if>
2792      <bool>
2793        <not><available file="${packages.home}/axis/.flagfile"/></not>
2794      </bool>
2795
2796      <get src="http://www.greenstone.org/gs3files/${axis.zip.version}"
2797        dest="${packages.home}/${axis.zip.version}"
2798        usetimestamp="true"/>
2799      <unzip src="${packages.home}/${axis.zip.version}"
2800        dest="${packages.home}"/>
2801      <move todir="${packages.home}/axis">
2802        <fileset dir="${packages.home}/${axis.dir.version}"/>
2803      </move>
2804      <!-- install axis into greenstone web app -->
2805      <copy todir="${web.lib}">
2806        <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/lib">
2807          <include name="*.jar"/>
2808        </fileset>
2809      </copy>
2810      <copy todir="${web.home}">
2811        <fileset dir="${packages.home}/axis/webapps/axis/">
2812          <include name="*.jsp"/>
2813          <include name="*.jws"/>
2814        </fileset>
2815      </copy>
2816      <copy tofile="${web.home}/axis.html" file="${packages.home}/axis/webapps/axis/index.html"/>
2817      <copy todir="${web.classes}">
2818        <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/classes">
2819          <include name="*.properties"/>
2820        </fileset>
2821      </copy>
2822      <echo file="${packages.home}/axis/.flagfile">
2823        the timestamp of this file is the time that axis was extracted from the zip files.
2824        it is used to figure out whether the files need to be refreshed or not in `ant prepare-axis`
2825      </echo>
2826
2827      <else>
2828        <echo>Axis has been prepared, will not prepare</echo>
2829        <echo>Delete ${packages.home}/axis/.flagfile to force refresh</echo>
2830      </else>
2831
2832    </if>
2833  </target>
2834
2835  <target name="soap-deploy-site" depends="init,get-sitename,get-siteuri,get-webservices,create-deployment-files,deploy-site"
2836    description="Deploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work."/>
2837   
2838    <target name="deploy-site">
2839    <java classname="org.apache.axis.client.AdminClient">
2840      <classpath refid="compile.classpath"/>
2841      <arg value="-l"/>
2842      <arg value="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/servlet/AxisServlet"/>
2843      <arg file="${basedir}/resources/soap/deploy.wsdd"/>
2844    </java>
2845    <delete file="${basedir}/resources/soap/deploy.wsdd"/> <!--clean up, no longer used-->
2846  </target>
2847 
2848  <target name="soap-undeploy-site" depends="get-undeploy-service-name"
2849    description="Undeploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work.">
2850    <filter token="servicesname" value="${axis.undeploy.servicename}"/>
2851    <copy file="${basedir}/resources/soap/undeploy-site.wsdd.template"
2852      tofile="${basedir}/resources/soap/undeploy.wsdd"
2853      filtering="true"
2854      overwrite="true"/>
2855    <java classname="org.apache.axis.client.AdminClient">
2856      <classpath refid="compile.classpath"/>
2857      <arg value="-l"/>
2858      <arg value="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/servlet/AxisServlet"/>
2859      <arg file="${basedir}/resources/soap/undeploy.wsdd"/>
2860    </java>
2861    <delete file="${basedir}/resources/soap/undeploy.wsdd"/> <!--clean up, no longer used-->
2862  </target> 
2863
2864  <!-- this target used to deploy the default web service SOAPServer (base.webservice.name) on the localsite server
2865  with the default servicename of localsite-->
2866  <target name="deploy-localsite" depends="init"
2867    description="Deploy the SOAP server for localsite. Will start and stop Tomcat.">
2868    <antcall target="force-start-tomcat"/>
2869    <echo>Deploying ${base.webservice.name} web services for localsite under service name: localsite</echo>
2870    <antcall target="create-deployment-files">
2871      <param name="axis.sitename" value="localsite"/>
2872      <param name="axis.servicesname" value="${base.webservice.name}"/>
2873      <param name="axis.siteuri" value="localsite"/>
2874    </antcall>
2875    <antcall target="deploy-site">
2876      <param name="axis.sitename" value="localsite"/>
2877      <param name="axis.servicesname" value="${base.webservice.name}"/>
2878      <param name="axis.siteuri" value="localsite"/>
2879    </antcall>
2880    <echo>The Greenstone server has been started up. If you do not want it running, please type: ant stop.</echo>
2881  </target>
2882   
2883  <target name="get-sitename" unless="axis.sitename">
2884    <input addproperty="axis.sitename" defaultvalue="localsite">What site do you want to deploy services for?
2885Press Enter for default:localsite</input>
2886  </target>
2887
2888  <target name="get-undeploy-service-name" unless="axis.undeploy.servicename">
2889    <input addproperty="axis.undeploy.servicename" defaultvalue="localsite">Please enter the full name of the service you wish to undeploy.
2890To find out which web services you've got deployed, point your browser to ${default.server.protocol}://${tomcat.server}:${default.tomcat.port}/greenstone3/services
2891Or press Enter for undeploying the default:localsite /&gt;</input>
2892     <echo>Name of service to undeploy: ${axis.undeploy.servicename}</echo>
2893  </target>
2894
2895  <target name="get-webservices" unless="axis.servicesname">
2896    <input addproperty="axis.servicesname" defaultvalue="${base.webservice.name}">Which set of web services do you want to deploy?
2897Choose from: ${web.services.list}
2898Or press Enter for default:${base.webservice.name} /&gt;</input>
2899    <echo>${axis.servicesname}</echo>
2900  </target>
2901
2902  <target name="get-siteuri" depends="get-sitename,get-webservices" unless="axis.siteuri">
2903    <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>
2904    <echo>Site: ${axis.sitename}, services: ${axis.servicesname}, servicesname: ${axis.siteuri}</echo>
2905  </target>
2906
2907  <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">
2908   <condition property="soap.method" value="provider='java:MSG' style='message' use='literal'">
2909      <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
2910    </condition>
2911   
2912   <!--everything else defaults to java:RPC at present-->
2913   <condition property="soap.method" value="provider='java:RPC'">
2914     <not>
2915      <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
2916    </not>
2917    </condition>
2918  </target>
2919   
2920  <target name="create-deployment-files" depends="set-soapmethod" if="axis.sitename">
2921    <filter token="sitename" value="${axis.sitename}"/>
2922    <filter token="siteuri" value="${axis.siteuri}"/>
2923    <filter token="servicesname" value="${axis.servicesname}"/>
2924    <filter token="soapmethod" value="${soap.method}"/>
2925    <copy file="${basedir}/resources/soap/site.wsdd.template"
2926      tofile="${basedir}/resources/soap/deploy.wsdd"
2927      filtering="true"
2928      overwrite="true"/>
2929    <!-- create the java files and compile them -->
2930    <copy file="${basedir}/resources/java/${axis.servicesname}.java.in"
2931      tofile="${src.gsdl3.home}/${axis.servicesname}${axis.sitename}.java"
2932      filtering="true"
2933      overwrite="true"/>
2934    <mkdir dir="${build.home}"/>
2935    <javac srcdir="${src.home}"
2936      destdir="${build.home}"
2937      includeantruntime="${compile.includeantruntime}"
2938      debug="${compile.debug}"
2939      deprecation="${compile.deprecation}"
2940      optimize="${compile.optimize}"
2941      encoding="${compile.encoding}">
2942      <classpath refid="compile.classpath"/>
2943      <include name="org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.java" />
2944    </javac>
2945    <mkdir dir="${web.classes}/org/greenstone/gsdl3"/>
2946    <copy file="${build.home}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
2947      tofile="${web.classes}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
2948      overwrite="true" />
2949  </target>
2950 
2951
2952  <!-- ====================== Core targets ============================== -->
2953  <!-- core targets refer to the core gsdl3 java src -->
2954 
2955  <target name="prepare-core"/>
2956 
2957  <target name="configure-core"/>
2958
2959  <target name="update-core" depends="init,svnupdate-core,clean-core,compile-core"
2960    description="Update only the Greenstone core" />
2961 
2962  <target name="svnupdate-core" unless="nosvn.mode">
2963    <exec executable="svn">
2964      <arg value="update"/>
2965      <arg value="${basedir}"/>
2966      <arg value="-r"/><arg value="${branch.revision}"/>
2967    </exec>
2968  </target>
2969
2970  <target name="clean-core"
2971    description="Clean only the Greenstone core">
2972    <!-- should this delete the gsdl3.jar from web/WEB-INF?? -->
2973    <delete dir="${build.home}"/>
2974  </target>
2975
2976  <target name="compile-core" depends="init"
2977    description="Compile only the Greenstone core">
2978    <mkdir dir="${build.home}"/>
2979   
2980    <if><bool><isset property="with.jni"/></bool>
2981    <javac srcdir="${src.home}"
2982           destdir="${build.home}"
2983           includeantruntime="${compile.includeantruntime}"
2984           debug="${compile.debug}"
2985           deprecation="${compile.deprecation}"
2986           optimize="${compile.optimize}"
2987           encoding="${compile.encoding}">
2988      <classpath>
2989            <path refid="compile.classpath"/>
2990      </classpath>
2991    </javac>
2992    <else>
2993      <property name="gsprefix" value=""/>   
2994      <javac srcdir="${src.home}"
2995         destdir="${build.home}"
2996         includeantruntime="${compile.includeantruntime}"
2997         debug="${compile.debug}"
2998         deprecation="${compile.deprecation}"
2999         optimize="${compile.optimize}"
3000         encoding="${compile.encoding}">
3001        <classpath>
3002              <path refid="compile.classpath"/>
3003        </classpath>
3004        <exclude name="org/greenstone/gsdl3/service/GS2MGPPRetrieve.java"/>
3005        <exclude name="org/greenstone/gsdl3/service/GS2MGPPSearch.java"/>
3006        <exclude name="org/greenstone/gsdl3/service/GS2MGSearch.java"/>
3007        <exclude name="org/greenstone/gsdl3/service/GS2MGRetrieve.java"/>
3008        <exclude name="org/greenstone/gsdl3/service/GoogleNgramMGPPSearch.java"/>
3009        <exclude name="org/greenstone/gsdl3/service/PhindPhraseBrowse.java"/>
3010        <exclude name="org/greenstone/gsdl3/util/GDBMWrapper.java"/>
3011      </javac>
3012    </else>
3013    </if>
3014    <jar destfile="${build.home}/gsdl3.jar">
3015      <fileset dir="${build.home}">
3016        <include name="org/greenstone/gsdl3/**"/>
3017        <include name="org/flax/**"/>
3018        <exclude name="**/Test.class"/>
3019      </fileset>
3020      <manifest>
3021        <attribute name="Built-By" value="${user.name}" />
3022      </manifest>
3023    </jar>
3024    <copy file="${build.home}/gsdl3.jar" todir="${web.lib}"/>
3025
3026    <jar destfile="${build.home}/gutil.jar">
3027      <fileset dir="${build.home}">
3028        <include name="org/greenstone/util/**"/>
3029      </fileset>
3030      <manifest>
3031        <attribute name="Built-By" value="${user.name}" />
3032      </manifest>
3033    </jar>
3034    <copy file="${build.home}/gutil.jar" todir="${web.lib}"/>
3035
3036    <!-- copy the localsite server in case we need it -->
3037    <copy file="${build.home}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" tofile="${web.classes}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" />
3038
3039    <!-- Greenstone Administrator Interface -->
3040    <jar destfile="${build.home}/GAI.jar">
3041      <fileset dir="${build.home}">
3042        <include name="org/greenstone/admin/**"/>
3043      </fileset>
3044      <manifest>
3045        <attribute name="Built-By" value="${user.name}" />
3046      </manifest>
3047    </jar>
3048    <copy file="${build.home}/GAI.jar" todir="${web.lib}"/>
3049    <copy file="${build.home}/GAI.jar" todir="${admin.dir}"/>
3050    <jar destfile="${build.home}/phind.jar">
3051      <fileset dir="${build.home}">
3052        <include name="org/greenstone/applet/phind/**"/>
3053      </fileset>
3054      <manifest>
3055        <attribute name="Built-By" value="${user.name}" />
3056      </manifest>
3057    </jar>
3058    <mkdir dir="${web.applet}"/>
3059    <copy file="${build.home}/phind.jar" todir="${web.applet}"/>
3060    <!-- phind also needs xercesImpl.jar and xml-apis.jar to be in web/applet -->
3061    <if>
3062      <bool><istrue value="${tomcat.islocal}"/></bool>
3063      <if><bool><available file="${catalina.home}/lib/xercesImpl.jar"/></bool><!-- moved for solr -->
3064    <copy file="${catalina.home}/lib/xercesImpl.jar" todir="${web.applet}"/>
3065    <copy file="${catalina.home}/lib/xml-apis.jar" todir="${web.applet}"/>
3066   
3067    <else><!-- get from default GS3 web lib location-->
3068      <copy file="${web.lib}/xercesImpl.jar" todir="${web.applet}"/>
3069      <copy file="${web.lib}/xml-apis.jar" todir="${web.applet}"/>
3070    </else>
3071      </if>
3072    </if>
3073
3074
3075    <!-- skip anttasks for now
3076    <jar destfile="${build.home}/anttasks.jar">
3077      <fileset dir="${build.home}">
3078        <include name="org/greenstone/anttasks/**"/>
3079      </fileset>
3080      <manifest>
3081        <attribute name="Built-By" value="${user.name}" />
3082      </manifest>
3083    </jar>
3084    <copy file="${build.home}/anttasks.jar" todir="${basedir}/lib/java"/>-->
3085    <jar destfile="${build.home}/gsdl3test.jar">
3086      <fileset dir="${build.home}">
3087        <include name="org/greenstone/gsdl3/**/*Test.class"/>
3088        <include name="org/greenstone/testing/**"/>
3089      </fileset>
3090      <manifest>
3091        <attribute name="Built-By" value="${user.name}" />
3092      </manifest>
3093    </jar>
3094    <jar destfile="${build.home}/server.jar">
3095      <fileset dir="${build.home}">
3096        <include name="org/greenstone/server/**"/>
3097        <include name="org/greenstone/util/**"/>
3098      </fileset>
3099      <fileset file="${basedir}/resources/java/server.properties"/>
3100      <manifest>
3101        <attribute name="Built-By" value="${user.name}"/>
3102      </manifest>
3103    </jar>
3104    <copy file="${build.home}/server.jar" todir="${basedir}"/>
3105  </target>
3106
3107  <!-- === Eclipse targets == -->
3108  <target name="setup-for-eclipse">
3109
3110    <filter token="gsdlhome" value="${gs2build.home}"/>
3111    <filter token="gsdl3srchome" value="${basedir}"/>
3112    <filter token="gsdl3home" value="${basedir}/web"/>
3113
3114    <if>
3115      <bool><not><available file="${basedir}/TransformingLibrary.launch"/></not></bool>         
3116      <copy file="${basedir}/TransformingLibrary.launch.in" tofile="${basedir}/TransformingLibrary.launch" filtering="true" overwrite="true"/>
3117    </if>
3118<!--
3119    <if>
3120      <bool><not><available file="${basedir}/LibraryCommandline.launch"/></not></bool>         
3121      <copy file="${basedir}/LibraryCommandline.launch.in" tofile="${basedir}/LibraryCommandline.launch" filtering="true" overwrite="true"/>
3122    </if>
3123-->
3124  </target>
3125 
3126  <!-- ================== Packages targets ================================ -->
3127  <!-- these targets refer to the greenstone source packages - these need
3128  updating less often, so are in  separate targets to the core -->
3129  <target name="prepare-packages" depends="init"/>
3130 
3131  <target name="update-packages" depends="init,svnupdate-packages,configure-packages,clean-packages,compile-packages"
3132    description="Update only the source packages"/>
3133
3134  <target name="svnupdate-packages" unless="nosvn.mode">
3135    <exec executable="svn">
3136      <arg value="update"/>
3137      <arg value="${src.packages.home}"/>
3138      <arg value="-r"/><arg value="${branch.revision}"/>
3139    </exec>
3140  </target>
3141
3142 
3143  <target name="configure-packages" depends="init,configure-javagdbm"
3144    description="Configure only the packages."/>
3145 
3146  <target name="configure-javagdbm" if="with.jni">
3147    <echo>
3148      Configuring JavaGDBM
3149    </echo>
3150   
3151    <exec executable="${javagdbm.home}/configure" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
3152      <arg value="--prefix=${basedir}"/>
3153      <arg value="--libdir=${lib.jni}"/>
3154      <arg value="--with-gdbm=${gdbm.home}"/>
3155      <arg line="${cross.configure.args}"/>
3156    </exec>   
3157  </target>
3158
3159  <target name="clean-packages" depends="init,clean-javagdbm" description="Clean only the packages"/>
3160
3161  <target name="clean-javagdbm" depends="init">
3162    <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
3163    <exec executable="make" os="${os.unix}"
3164      dir="${javagdbm.home}" failonerror="true">
3165      <arg value="clean"/>
3166    </exec>
3167    </if>
3168  </target>
3169 
3170  <target name="distclean-packages" depends="init,distclean-javagdbm" description="Distclean only the packages"/>
3171
3172  <target name="distclean-javagdbm" depends="init">
3173    <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
3174    <exec executable="make" os="${os.unix}"
3175      dir="${javagdbm.home}" failonerror="true">
3176      <arg value="distclean"/>
3177    </exec>
3178    </if>
3179  </target>
3180 
3181  <target name="compile-packages" description="Compile only the source packages">
3182    <!-- javagdbm -->
3183    <antcall target="compile-javagdbm"/>
3184    <!-- Search4j -->
3185    <antcall target="compile-search4j"/>
3186  </target>
3187
3188  <target name="compile-javagdbm" description="Compile JavaGDBM" if="with.jni">
3189   
3190    <!-- unix: -->
3191    <echo>compile javagdbm</echo>
3192    <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
3193      <arg value="JAVACOPTIONS=-encoding UTF8"/>
3194    </exec>
3195    <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
3196      <arg value="install"/>
3197    </exec>
3198
3199    <!-- windows: Calling without the "compile" argument first will run winMake.bat with
3200         "all" which will then perform both the compile AND link targets in jni/win32.mak
3201         (thereby also generating gdbmjava.dll). Then we run the same command with
3202         the "install" argument to copy the gdbmjava.dll into the correct location. -->
3203    <echo>Windows: compile javagdbm</echo>
3204    <exec executable="${javagdbm.home}/winMake.bat" osfamily="windows" dir="${javagdbm.home}" failonerror="true">     
3205      <env key="GSDL3SRCHOME" path="${basedir}"/>
3206    </exec>
3207    <exec executable="${javagdbm.home}/winMake.bat" osfamily="windows" dir="${javagdbm.home}" failonerror="true">
3208      <env key="GSDL3SRCHOME" path="${basedir}"/>
3209      <arg value="install"/>
3210    </exec>
3211
3212    <!-- install the jar file -->
3213    <echo>Install the javagdbm jar file ${javagdbm.home}/javagdbm.jar ${lib.jni}</echo>
3214    <copy file="${javagdbm.home}/javagdbm.jar" todir="${lib.jni}"/>
3215  </target>
3216
3217  <target name="compile-search4j">
3218
3219    <!-- windows -->
3220    <if><bool><istrue value="${current.os.iswindows}"/></bool>
3221      <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
3222        <arg value="/f"/>
3223        <arg value="win32.mak"/>
3224        <arg value='BINDIR="${basedir}\bin"'/>
3225      </exec>
3226      <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
3227        <arg value="/f"/>
3228        <arg value="win32.mak"/>
3229        <arg value="install"/>
3230        <arg value='BINDIR="${basedir}\bin"'/>
3231      </exec>
3232
3233    <!-- unix -->
3234    <else><if><bool><istrue value="${current.os.isunix}"/></bool>
3235      <exec executable="${src.packages.home}/search4j/configure" dir="${src.packages.home}/search4j" failonerror="true">
3236        <arg value="--bindir=${basedir}/bin"/>
3237        <arg value="${static.arg}"/>
3238        <arg line="${cross.configure.args}"/>
3239      </exec>
3240      <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true"/>
3241      <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true">
3242        <arg value="install"/>
3243      </exec>
3244
3245    <!-- else warn -->
3246    <else>
3247      <fail>this target does not support the current os</fail>
3248
3249    </else></if></else></if>
3250
3251  </target>
3252
3253  <target name="install-auxiliary-jar-files" depends="init">
3254
3255    <if>
3256      <bool><available file="${mg.home}/mg.jar"/></bool>
3257      <copy file="${mg.home}/mg.jar" todir="${lib.jni}"/>
3258    </if>
3259
3260    <if>
3261      <bool><available file="${mgpp.home}/mgpp.jar"/></bool>
3262      <copy file="${mgpp.home}/mgpp.jar" todir="${lib.jni}"/>
3263    </if>
3264
3265    <copy file="${lucene.home}/LuceneWrapper4.jar" todir="${web.lib}"/>   
3266  </target>
3267 
3268  <target name="install-jni-files" depends="init" if="with.jni">
3269    <antcall target="install-jni-files-linux"/>
3270    <antcall target="install-jni-files-windows"/>
3271    <antcall target="install-jni-files-macos"/>
3272  </target>
3273
3274  <target name="install-jni-files-linux" depends="init" if="current.os.isunixnotmac">
3275
3276    <if>
3277
3278      <bool><equals arg1="${os.bin.dir}" arg2="windows"/></bool>
3279      <!-- cross compiling to windows -->
3280      <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
3281      <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
3282      <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
3283      <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
3284      <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
3285      <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
3286     
3287      <else>
3288    <!-- otherwise do the usual Unix copies -->
3289    <copy file="${mg.home}/jni/libmgretrievejni.so" todir="${lib.jni}"/>
3290    <copy file="${mg.home}/jni/libmgsearchjni.so" todir="${lib.jni}"/>
3291    <copy file="${mg.home}/jni/libmgpassjni.so" todir="${lib.jni}"/>
3292    <copy file="${mgpp.home}/jni/libmgppretrievejni.so" todir="${lib.jni}"/>
3293    <copy file="${mgpp.home}/jni/libmgppsearchjni.so" todir="${lib.jni}"/>
3294    <copy file="${mgpp.home}/jni/libmgpppassjni.so" todir="${lib.jni}"/>
3295      </else>
3296    </if>
3297
3298
3299  </target>
3300  <target name="install-jni-files-windows" depends="init" if="current.os.iswindows">
3301    <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
3302    <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
3303    <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
3304    <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
3305    <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
3306    <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
3307  </target>
3308  <target name="install-jni-files-macos" depends="init" if="current.os.ismac">
3309    <copy file="${mg.home}/jni/libmgretrievejni.jnilib" todir="${lib.jni}"/>
3310    <copy file="${mg.home}/jni/libmgsearchjni.jnilib" todir="${lib.jni}"/>
3311    <copy file="${mg.home}/jni/libmgpassjni.jnilib" todir="${lib.jni}"/>
3312    <copy file="${mgpp.home}/jni/libmgppretrievejni.jnilib" todir="${lib.jni}"/>
3313    <copy file="${mgpp.home}/jni/libmgppsearchjni.jnilib" todir="${lib.jni}"/>
3314    <copy file="${mgpp.home}/jni/libmgpppassjni.jnilib" todir="${lib.jni}"/>
3315  </target>
3316 
3317  <!-- ========common-src targets =================================-->
3318  <!-- these are used to get common-src (for indexers, gdbm, sqlite etc) when
3319  collection building is not enabled -->
3320
3321  <target name="update-common-src" depends="init" if="collection.building.disabled">
3322  </target>
3323
3324  <target name="svnupdate-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
3325    <exec executable="svn">
3326      <arg value="update"/>
3327      <arg value="${common.src.home}"/>
3328      <arg value="-r"/><arg value="${branch.revision}"/>
3329    </exec>
3330  </target>
3331
3332  <target name="prepare-common-src" depends="init" if="collection.building.disabled" unless="common.src.present">
3333    <antcall target="checkout-common-src"/>
3334    <antcall target="unzip-windows-packages"/>
3335  </target>
3336
3337  <target name="checkout-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
3338    <echo>checking out common-src</echo>
3339    <exec executable="svn">
3340      <arg value="checkout"/>
3341      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src"/>
3342            <arg value="common-src"/>
3343      <arg value="-r"/><arg value="${branch.revision}"/>
3344    </exec>
3345  </target>
3346   
3347  <target name="configure-common-src" depends="init">
3348<!--
3349    <echo>cross configure args: ${cross.configure.args}</echo>
3350-->
3351    <exec executable="${common.src.home}/configure" os="${os.unix}"
3352      dir="${common.src.home}" failonerror="true">
3353      <arg value="--prefix=${gs2build.home}"/> <!-- what value to use?? -->
3354      <arg value="--bindir=${gs2build.home}/bin/${os.bin.dir}"/> <!-- what value to use?? -->
3355      <arg line="${gs2.opt.args}"/>
3356      <arg line="${static.arg}"/>
3357      <arg line="${cross.configure.args}"/>
3358      <arg line="${allargs}"/>
3359    </exec>
3360  </target>
3361
3362  <target name="clean-common-src" depends="init">
3363    <!-- unix:  -->
3364    <if><bool><available file="${common.src.home}/Makefile"/></bool>
3365    <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
3366      <arg value="clean"/>
3367    </exec>
3368    </if>
3369    <!-- windows: -->   
3370    <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
3371      <arg value="/f"/>
3372      <arg value="win32.mak"/>
3373      <arg value="clean"/>
3374      <arg value="GSDLHOME=${gs2build.home}"/>
3375    </exec>
3376  </target>
3377  <target name="distclean-common-src" depends="init">
3378    <!-- unix:  -->
3379    <if><bool><available file="${common.src.home}/Makefile"/></bool>
3380    <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
3381      <arg value="distclean"/>
3382    </exec>
3383    </if>
3384    <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->   
3385    <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
3386      <arg value="/f"/>
3387      <arg value="win32.mak"/>
3388      <arg value="clean"/>
3389      <arg value="GSDLHOME=${gs2build.home}"/>
3390    </exec>
3391  </target>
3392  <target name="compile-common-src" depends="init">
3393    <!-- unix: -->
3394    <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
3395      <arg value="${gs2.compile.target}"/>
3396    </exec>
3397    <!-- windows: -->
3398    <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
3399      <arg value="/f"/>
3400      <arg value="win32.mak"/>
3401      <arg value="GSDLHOME=${gs2build.home}"/>
3402      <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
3403      <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
3404      <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
3405      <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
3406      <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
3407    </exec>
3408  </target>
3409 
3410  <!-- ======= collection-building targets ===========================-->
3411
3412  <target name="update-collection-building" if="collection.building.enabled"
3413    depends="init,svnupdate-collection-building,gs2build-edit-setup-bat,configure-common-src,clean-common-src,compile-common-src,clean-collection-building,configure-collection-building,compile-collection-building"
3414    description="Update (SVN update, configure, compile etc) only the collection building components"/>
3415
3416  <target name="svnupdate-collection-building" if="collection.building.enabled" depends="init,svnupdate-gs2build,svnupdate-cgi,svnupdate-gli" unless="nosvn.mode"
3417    description="SVN update the collection building components">
3418  </target>
3419
3420  <target name="prepare-collection-building" depends="init,prepare-gs2build,svnupdate-cgi,prepare-gli" if="collection.building.enabled">
3421  </target>
3422
3423  <target name="configure-collection-building" depends="init,configure-build-src" if="collection.building.enabled"
3424    description="Configure the collection building components">
3425  </target>
3426
3427  <target name="clean-collection-building" depends="init,clean-gli,clean-build-src"
3428    description="Clean only the collection building components"
3429    if="collection.building.enabled"/>
3430
3431  <target name="distclean-collection-building" depends="init,clean-build-src,distclean-build-src"
3432    description="Distclean only the collection building components"
3433    if="collection.building.enabled"/>
3434
3435  <target name="compile-collection-building" depends="init,compile-build-src,compile-gli" if="collection.building.enabled"
3436    description="Compile only the collection building components">
3437    <!-- make install for common-src -->
3438    <!-- unix: -->
3439    <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
3440      <arg value="${gs2.install.target}"/>
3441    </exec>
3442     
3443    <!-- windows: -->
3444    <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
3445      <arg value="/f"/>
3446      <arg value="win32.mak"/>
3447      <arg value="install"/>
3448      <arg value="GSDLHOME=${gs2build.home}"/>
3449      <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
3450      <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
3451      <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
3452      <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
3453      <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
3454      <!--
3455      <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
3456      <arg value="USE_SQLITE=0"/>--> <!-- why is this not on by default? -->
3457    </exec>
3458
3459    <!-- install gs2build indexers for windows -->
3460      <if>
3461    <bool><istrue value="${current.os.iswindows}"/></bool>
3462    <copy todir="${gs2build.home}/bin/windows">
3463      <fileset dir="${gs2build.home}/common-src/indexers/bin">
3464        <include name="*.*"/>
3465      </fileset>
3466    </copy>
3467      </if>
3468
3469    <!-- LuceneWrapper jar file not installed by default -->
3470    <mkdir dir="${gs2build.home}/bin/java"/>
3471    <copy file="${lucene.home}/LuceneWrapper4.jar" todir="${gs2build.home}/bin/java"/>
3472
3473  </target>
3474
3475  <!-- ============== gli targets ================================= -->
3476 
3477  <!-- gliserver.pl, gsdlCGI.pm, metadata-server.pl and checksum.pl are updated alongside
3478       this in target svnupdate-collection-building -->
3479  <target name="svnupdate-gli" if="collection.building.enabled" depends="init" unless="nosvn.mode">
3480
3481    <exec executable="svn">
3482      <arg value="update"/>
3483      <arg value="${gli.home}"/>
3484      <arg value="-r"/><arg value="${branch.revision}"/>
3485    </exec>
3486
3487  </target>
3488
3489  <!-- gliserver.pl, gsdlCGI.pm, metadata-server.pl and checksum.pl are updated
3490       alongside this prepare-gli target in target prepare-collection-building -->
3491  <target name="prepare-gli" depends="init" if="collection.building.enabled" unless="gli.present">
3492    <!-- checkout -->
3493    <if><bool><and><not><istrue value="${nosvn.mode}"/></not><isset property="with.gli.and.gems"/></and></bool>
3494
3495    <exec executable="svn">
3496      <arg value="checkout"/>
3497      <arg value="${svn.root}/main/${branch.path}/gli"/>
3498      <arg value="-r"/><arg value="${branch.revision}"/>
3499    </exec>
3500
3501    </if>
3502  </target>
3503
3504  <!-- svn checkout gliserver.pl, gsdlCGI.pm for gli applet, as well as gsdlCGI.pm-dependent metadata-server.pl
3505       (checksum.pl is used by GS2 for depositdspace.dm and may eventually be used by GS3 too) -->
3506  <target name="svnupdate-cgi">
3507
3508    <exec executable="svn" dir="web/WEB-INF/cgi">
3509      <arg value="export"/>
3510      <arg value="-r"/><arg value="${branch.revision}"/>
3511      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/gliserver.pl"/>
3512    </exec>
3513    <exec executable="svn" dir="web/WEB-INF/cgi">
3514      <arg value="export"/>
3515      <arg value="-r"/><arg value="${branch.revision}"/>
3516      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/gsdlCGI.pm"/>
3517    </exec>
3518    <exec executable="svn" dir="web/WEB-INF/cgi">
3519      <arg value="export"/>
3520      <arg value="-r"/><arg value="${branch.revision}"/>
3521      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/metadata-server.pl"/>
3522    </exec>
3523    <exec executable="svn" dir="web/WEB-INF/cgi">
3524      <arg value="export"/>
3525      <arg value="-r"/><arg value="${branch.revision}"/>
3526      <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/checksum.pl"/>
3527    </exec>
3528  </target>
3529
3530 
3531  <target name="clean-gli" depends="init" if="collection.building.enabled">
3532    <!-- gli -->
3533    <property name="gli.home" value="${basedir}/gli"/>
3534    <!-- linux -->
3535    <exec executable="clean.sh" os="${os.unix}" dir="${gli.home}"
3536      resolveExecutable="true" failonerror="true"/>
3537    <!-- windows -->
3538    <exec executable="clean.bat" osfamily="windows" dir="${gli.home}"
3539      resolveExecutable="true" failonerror="true"/>
3540  </target>
3541 
3542  <target name="compile-gli" depends="init" if="collection.building.enabled">
3543    <if><bool><isset property="with.gli.and.gems"/></bool>
3544      <!-- gli -->
3545      <property name="gli.home" value="${basedir}/gli"/>
3546
3547      <!-- linux -->
3548      <exec executable="makegli.sh" os="${os.unix}" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
3549      <!--remote gli-->
3550      <exec executable="makejar.sh" os="${os.unix}" dir="${gli.home}"
3551        resolveExecutable="true" failonerror="true"/>
3552      <!-- windows -->
3553      <exec executable="makegli.bat" osfamily="windows" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
3554      <!--remote gli-->
3555      <exec executable="makejar.bat" osfamily="windows" dir="${gli.home}"
3556        resolveExecutable="true" failonerror="true"/>
3557      <copy file="${gli.home}/GLIServer.jar" todir="${gs2build.home}/bin/java" />
3558    </if>
3559  </target>
3560
3561  <target name="gli" description="Run the Greenstone Librarian Interface" depends="init" if="collection.building.enabled">
3562    <exec executable="${basedir}/gli/gli.sh" os="${os.linux},${os.solaris}" dir="${basedir}/gli" spawn="true">
3563      <env key="gsdl3path" path="${basedir}"/>
3564      <env key="gsdlpath" path="${gs2build.home}"/>
3565    </exec>
3566    <exec executable="${basedir}/gli/gli.sh" os="${os.mac}" dir="${basedir}/gli" spawn="true">
3567      <env key="gsdl3path" path="${basedir}"/>
3568      <env key="gsdlpath" path="${gs2build.home}"/>
3569      <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${gdbm.home}/lib"/>
3570    </exec>
3571    <exec executable="${basedir}/gli/gli.bat" osfamily="windows" dir="${basedir}/gli" spawn="true">
3572      <env key="GSDL3PATH" path="${basedir}"/>
3573      <env key="GSDLPATH" path="${gs2build.home}"/>
3574    </exec>
3575    <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.
3576    </echo>
3577  </target>
3578
3579  <!-- ================ gs2build targets =========================== -->
3580
3581  <target name="svnupdate-gs2build" if="collection.building.enabled" depends="init" unless="nosvn.mode">
3582    <echo>svn updating gs2build</echo>
3583    <exec executable="svn">
3584      <arg value="update"/>
3585      <arg value="${gs2build.home}"/>
3586      <arg value="-r"/><arg value="${branch.revision}"/>
3587    </exec>
3588  </target>
3589   
3590  <target name="prepare-gs2build" depends="init" if="collection.building.enabled" unless="gs2build.present">
3591    <antcall target="checkout-gs2build"/>
3592    <antcall target="prepare-pdfbox"/>
3593    <antcall target="prepare-imagemagick"/> <!-- has to be done before calling prepare-gnome-lib -->
3594    <antcall target="prepare-gnome-lib"/>
3595    <antcall target="unzip-windows-packages"/>
3596    <antcall target="checkout-winbin"/>
3597    <antcall target="get-windows-binaries"/>
3598    <antcall target="delete-winbin"/>
3599  </target>
3600
3601  <target name="checkout-gs2build" depends="init" if="collection.building.enabled" unless="nosvn.mode">
3602    <echo>checking out gs2build</echo>
3603    <exec executable="svn">
3604      <arg value="checkout"/>
3605      <arg value="${svn.root}/main/${branch.path}/gs2build"/>
3606      <arg value="-r"/><arg value="${branch.revision}"/>
3607    </exec>
3608  </target>
3609
3610  <!-- Gets the PDFBox extension into gs2build/ext if checkout.pdfbox.ext is set to true in build.properties
3611       (which it is by default) -->
3612  <target name="prepare-pdfbox" depends="init" if="collection.building.enabled">
3613    <if>
3614      <bool>
3615    <istrue value="${checkout.pdfbox.ext}"/>
3616      </bool>
3617     
3618      <property name="pdfbox.ext.dir" value="${gs2build.home}/ext/pdf-box"/>
3619      <condition property="pdfbox.ext.present">
3620    <available file="${pdfbox.ext.dir}" type="dir" />
3621      </condition>
3622     
3623      <!-- 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-->
3624      <if>
3625    <bool>
3626      <not><istrue value="${pdfbox.ext.present}"/></not>
3627    </bool>
3628
3629    <if>
3630      <bool>
3631        <not><istrue value="${gs2build.home}/ext/pdf-box-java.tar.gz"/></not>
3632      </bool>
3633
3634      <echo>Checking out the PDFBox extension into the GSDLHOME extension area</echo>
3635      <exec executable="svn">
3636        <arg value="export"/>
3637        <arg value="${svn.root}/gs2-extensions/pdf-box/trunk/pdf-box-java.tar.gz"/>
3638        <arg value="${gs2build.home}/ext/pdf-box-java.tar.gz"/>
3639      </exec>
3640    </if>   
3641
3642    <echo>Extacting the PDFBox extension into the GSDLHOME extension area</echo>
3643    <untar compression="gzip"
3644           src="${gs2build.home}/ext/pdf-box-java.tar.gz"
3645           dest="${gs2build.home}/ext"/>
3646
3647    <delete file="${gs2build.home}/ext/pdf-box-java.tar.gz"/>
3648
3649    <else>
3650      <echo>The PDFBox extension already exists at ${pdfbox.ext.dir}</echo>
3651    </else>
3652      </if>
3653
3654      <else>
3655    <echo>**** Not preparing the PDFBox extension:</echo>
3656    <echo>The property checkout.pdfbox.ext in build.properties was not set or was set to false</echo>
3657      </else>
3658    </if>
3659  </target>
3660
3661  <target name="prepare-imagemagick" depends="init" if="collection.building.enabled">
3662    <if>
3663      <bool>
3664    <istrue value="${checkout.imagemagick.ext}"/>
3665      </bool>
3666
3667      <antcall target="checkout-imagemagick"/>
3668      <!--Compilation of imagemagick now happens during ant install, still before configuring the src code, as before -->
3669
3670      <else>
3671    <echo>**** Not preparing imagemagick:</echo>
3672    <echo>property checkout.imagemagick.ext in build.properties was not set or was set to false</echo>
3673      </else>
3674    </if>
3675  </target>
3676
3677  <target name="checkout-imagemagick" depends="init" if="collection.building.enabled" unless="nosvn.mode">
3678   
3679    <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
3680    <condition property="imagemagick.src.present">
3681      <available file="${imagemagick.src.dir}" type="dir" />
3682    </condition>
3683
3684    <if>
3685      <bool>
3686    <not><istrue value="${imagemagick.src.present}"/></not>
3687      </bool>
3688     
3689      <echo>checking out imagemagick source into the extension area</echo>
3690
3691      <exec executable="svn">
3692    <arg value="checkout"/>
3693    <arg value="${svn.root}/gs2-extensions/imagemagick/trunk/src"/>
3694    <arg value="${imagemagick.src.dir}"/>
3695      </exec>
3696
3697      <else>
3698    <echo>imagemagick source code already exists at ${imagemagick.src.dir}</echo>
3699      </else>
3700    </if>
3701  </target>
3702
3703 <!-- 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. -->
3704  <target name="compile-imagemagick" if="checkout.imagemagick.ext">
3705   
3706    <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
3707    <property name="imagemagick.compiled.dir" value="${gs2build.home}/ext/imagemagick/${os.bin.dir}"/>
3708
3709    <condition property="imagemagick.src.present.firstcheck">
3710      <available file="${imagemagick.src.dir}" type="dir" />
3711    </condition>
3712    <condition property="imagemagick.compiled.present">
3713      <available file="${imagemagick.compiled.dir}" type="dir"/>
3714    </condition>
3715    <!--<condition property="imagemagick.bin.present">
3716      <available file="${basedir}/wherever/the/imgmagick/binary/is/to/be/found" type="dir" />
3717    </condition>-->
3718
3719    <!-- imagemagick will only be checked out if the user set the checkout.imagemagick.ext in build.properties -->
3720    <if>
3721      <bool>
3722    <isfalse value="${imagemagick.src.present.firstcheck}"/>
3723      </bool>
3724      <antcall target="checkout-imagemagick"/>
3725    </if>
3726
3727    <!-- keep track of whether the imagemagick src is now indeed present. Need to know this for a subsequent test -->
3728    <condition property="imagemagick.src.present">
3729      <available file="${imagemagick.src.dir}" type="dir" />
3730    </condition>
3731
3732    <if>
3733      <bool>
3734    <and>
3735      <istrue value="${imagemagick.src.present}"/> <!-- imagemagick src code is present -->
3736      <isfalse value="${imagemagick.compiled.present}"/> <!-- imagemagick src not compiled yet, so no imagemagick/os subfolder yet -->
3737    </and>
3738      </bool>
3739      <!-- then compile it. Only necessary for mac/linux, since windows has a stable working binary of imagemagick -->
3740      <exec executable="/bin/bash" dir="${imagemagick.src.dir}" failonerror="true">
3741        <arg value="CASCADE-MAKE.sh"/>
3742      </exec> 
3743    </if>
3744  </target>
3745
3746
3747  <!-- Compile up gnome-lib src folder if: checkout.gnomelib.ext is turned on, and if not using the binary
3748       version (gnome-lib-minimal), and if the gnome-lib src folder is not already compiled up. -->
3749  <target name="compile-gnome-lib" if="checkout.gnomelib.ext">
3750
3751    <!-- http://stackoverflow.com/questions/3290307/sourcing-a-shell-profile-in-an-ant-build-file
3752     TODO: CASCADE-MAKE already sources devel.bash, but we still want to source it more globally,
3753     so that the rest of the GS3 compilation process also has access to those env variables -->
3754   
3755    <property name="gnome.lib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
3756    <property name="gnome.lib.compiled.dir" value="${basedir}/gs2build/ext/gnome-lib/${os.bin.dir}"/>
3757
3758    <condition property="gnome.src.lib.present.firstcheck" value="true" else="false">
3759      <available file="${gnome.lib.src.dir}" type="dir" />
3760    </condition>
3761    <condition property="gnome.compiled.lib.present" value="true" else="false">
3762      <available file="${gnome.lib.compiled.dir}" type="dir"/>
3763    </condition>
3764    <condition property="gnome.lib.min.present" value="true" else="false">
3765      <available file="${basedir}/gs2build/ext/gnome-lib-minimal" type="dir" />
3766    </condition>
3767
3768    <!-- Make sure to checkout gnome-lib if it was not checked out at this stage
3769     since we're instructed to do so in th pre-condition to this target -->
3770    <if>
3771      <bool>
3772    <and>
3773      <isfalse value="${gnome.lib.min.present}"/>
3774      <isfalse value="${gnome.src.lib.present.firstcheck}"/>
3775    </and>
3776      </bool>
3777      <antcall target="checkout-gnome-lib"/>
3778    </if>
3779
3780    <!-- Keep track of whether we have the gnome-lib src folder now. Need to know this for a subsequent test -->
3781    <condition property="gnome.src.lib.present" value="true" else="false">
3782      <available file="${gnome.lib.src.dir}" type="dir" />
3783    </condition>
3784
3785    <!--<echo>MIN: ${gnome.lib.min.present}
3786      SRC LIB: ${gnome.src.lib.present}
3787      COMPILED: ${gnome.compiled.lib.present}</echo>-->
3788
3789    <if>
3790      <bool>
3791    <and>
3792      <isfalse value="${gnome.lib.min.present}"/> <!-- no gnome-lib-minimal binary present -->
3793      <istrue value="${gnome.src.lib.present}"/> <!-- gnome-lib folder for compilation is present-->
3794      <isfalse value="${gnome.compiled.lib.present}"/> <!-- gnome-lib not yet compiled, so no gnome-lib/os subfolder yet -->
3795    </and>
3796      </bool>
3797
3798      <!-- then compile it. Only necessary for mac/linux, since windows doesn't need gnome lib -->
3799      <exec executable="/bin/bash" dir="${gnome.lib.src.dir}" failonerror="true">
3800        <arg value="CASCADE-MAKE.sh"/>
3801      </exec> 
3802    </if>
3803  </target>
3804
3805
3806  <target name="prepare-gnome-lib" depends="init" if="collection.building.enabled" unless="gnome-lib.present">
3807    <if>
3808      <bool>
3809    <istrue value="${checkout.gnomelib.ext}"/>
3810      </bool>
3811
3812      <antcall target="checkout-gnome-lib"/>
3813      <!--Compilation of gnome-lib happens during ant install, just before configuring (common-src and) build-src-->
3814
3815      <else>
3816    <echo>**** Not preparing gnome-lib:</echo>
3817    <echo>property checkout.gnomelib.ext in build.properties was not set or was set to false</echo>
3818      </else>
3819    </if>
3820  </target>
3821
3822
3823  <target name="checkout-gnome-lib" depends="init" if="collection.building.enabled" unless="nosvn.mode">
3824
3825    <property name="gnomelib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
3826    <condition property="gnome.src.present">
3827      <available file="${gnomelib.src.dir}" type="dir" />
3828    </condition>
3829
3830    <if>
3831      <bool>
3832    <not><istrue value="${gnome.src.present}"/></not>
3833      </bool>
3834
3835      <echo>checking out gnome-lib extension</echo>
3836      <exec executable="svn">
3837    <arg value="checkout"/>
3838    <arg value="${svn.root}/gs2-extensions/gnome-lib/trunk/src"/>
3839    <arg value="${gs2build.home}/ext/gnome-lib"/>
3840      </exec>
3841
3842      <else>
3843    <echo>gnomelib source code already exists at ${gnomelib.src.dir}</echo>
3844      </else>
3845    </if>
3846
3847  </target>
3848
3849  <target name="checkout-winbin" depends="init" if="current.os.iswindows"
3850    unless="nosvn.mode">
3851
3852    <exec executable="svn">
3853      <arg value="checkout"/>
3854      <arg value="${svn.root}/main/${branch.path}/binaries/windows"/>
3855      <arg value="-r"/><arg value="${branch.revision}"/>
3856      <arg value="winbin"/>
3857    </exec>
3858
3859  </target>
3860
3861  <target name="update-winbin" depends="init" if="current.os.iswindows" unless="nosvn.mode">
3862    <exec executable="svn">
3863      <arg value="update"/>
3864      <arg value="winbin"/>
3865      <arg value="-r"/><arg value="${branch.revision}"/>
3866    </exec>
3867
3868  </target>
3869 
3870  <target name="get-windows-binaries" depends="init" if="collection.building.enabled.windows">
3871    <move todir="${gs2build.home}/bin/windows" failonerror="false">
3872      <fileset dir="${basedir}/winbin/bin"/>
3873    </move>
3874  </target>
3875
3876  <target name="delete-winbin" depends="init" if="collection.building.enabled.windows">
3877    <delete dir="${basedir}/winbin"/>
3878  </target>
3879 
3880  <target name="unzip-windows-packages" depends="init" if="current.os.iswindows"> 
3881    <unzip src="${common.src.home}/packages/windows/crypt/crypt.zip"
3882      dest="${common.src.home}/packages/windows/crypt"/>
3883    <untar compression="gzip"
3884      src="${common.src.home}/packages/sqlite/${sqlite.targz.version}"
3885      dest="${common.src.home}/packages/sqlite"/>
3886    <unzip src="${common.src.home}/indexers/packages/windows/iconv/iconv.zip"
3887      dest="${common.src.home}/indexers/packages/windows/iconv"/>
3888  </target>
3889   
3890  <target name="gs2build-edit-setup-bat" if="collection.building.enabled.windows">
3891    <!-- we want a windows path in the setup.bat file -->
3892    <pathconvert targetos="windows" property="gs2build.home.windows">
3893      <path path="${gs2build.home}"/>
3894    </pathconvert>
3895    <move file="${gs2build.home}/setup.bat" tofile="${gs2build.home}/setup-tmp.bat">
3896      <filterset>
3897        <filter token="gsdlhome" value="${gs2build.home.windows}"/>
3898      </filterset>
3899    </move> 
3900    <move file="${gs2build.home}/setup-tmp.bat" tofile="${gs2build.home}/setup.bat" />
3901  </target>
3902 
3903 
3904  <target name="clean-build-src" depends="init" if="collection.building.enabled">
3905    <!-- unix:  -->
3906    <if><bool><available file="${build.src.home}/Makefile"/></bool>
3907    <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
3908      <arg value="clean"/>
3909    </exec>
3910    </if>
3911    <!-- windows: -->   
3912    <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
3913      <arg value="/f"/>
3914      <arg value="win32.mak"/>
3915      <arg value="clean"/>
3916      <arg value="GSDLHOME=${gs2build.home}"/>
3917    </exec>
3918  </target>
3919 
3920 
3921  <target name="distclean-build-src" depends="init,clean-build-src" if="collection.building.enabled">
3922    <!-- unix:  -->
3923    <if><bool><available file="${build.src.home}/Makefile"/></bool>
3924    <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
3925      <arg value="distclean"/>
3926    </exec>
3927    </if>
3928    <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->   
3929    <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
3930      <arg value="/f"/>
3931      <arg value="win32.mak"/>
3932      <arg value="clean"/>
3933      <arg value="GSDLHOME=${gs2build.home}"/>
3934    </exec>
3935  </target>
3936 
3937  <target name="configure-build-src" depends="init" if="collection.building.enabled"
3938    description="Configure the build-src component">
3939    <exec executable="${build.src.home}/configure" os="${os.unix}"
3940      dir="${build.src.home}" failonerror="true">
3941      <arg value="--prefix=${gs2build.home}"/>
3942      <arg line="${gs2.opt.args} ${static.arg} ${cross.configure.args} ${allargs}"/>
3943    </exec>
3944  </target>
3945
3946  <!-- common-src is done separately and needs to be compiled first -->
3947  <target name="compile-build-src" depends="init" if="collection.building.enabled">
3948   
3949    <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
3950        <arg line="${ldlpath.arg}"/>
3951    </exec>
3952   
3953    <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
3954    <env key="GSDLOS" value="${os.bin.dir}"/>
3955    <arg value="install"/>
3956    </exec>
3957
3958    <!-- run the setup script -->
3959    <!-- <exec executable="${compile.windows.c++.setup}" osfamily="windows" failonerror="true"/>-->
3960      <!--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-->
3961      <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
3962        <arg value="/f"/>
3963        <arg value="win32.mak"/>
3964    <arg value="GSDLHOME=${gs2build.home}"/>
3965      </exec>
3966      <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
3967        <arg value="/f"/>
3968        <arg value="win32.mak"/>
3969        <arg value="install"/>
3970    <arg value="GSDLHOME=${gs2build.home}"/>
3971      </exec>
3972  </target>
3973 
3974
3975  <!-- ======================== TESTING Targets ========================= -->
3976 
3977  <target name="test" description="Run the (incomplete) JUnit test suite "
3978    depends="init">
3979    <mkdir dir="${basedir}/test"/>
3980    <junit printsummary="withOutAndErr"
3981      errorproperty="test.failed"
3982      failureproperty="test.failed"
3983      fork="${junit.fork}">
3984      <formatter type="plain"/>
3985      <classpath>
3986        <pathelement location="${build.home}/gsdl3test.jar"/>
3987        <path refid="compile.classpath"/>
3988      </classpath>
3989      <test name="${testcase}" if="testcase"/>
3990      <batchtest todir="${basedir}/test" unless="testcase">
3991        <fileset dir="${build.home}" includes="**/*Test.class" />
3992      </batchtest>
3993    </junit>
3994    <echo>
3995      *********************************************
3996      Test output can be found in directory 'test'
3997      *********************************************
3998    </echo>
3999  </target>
4000
4001  <!-- ======================== FLAX Targets ========================= -->
4002  <target name="prepare-flax" description="check out flax source code from another repository" if="install.flax">
4003    <echo>checking out flax ...</echo>
4004    <mkdir dir="${basedir}/src/java/org/flax"/>
4005    <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/flax"/>
4006    <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/action/flax"/>
4007    <mkdir dir="${web.home}/WEB-INF/classes/flax"/>
4008    <mkdir dir="${web.home}/interfaces/flax"/>
4009    <mkdir dir="${web.home}/sites/flax"/>
4010    <mkdir dir="${basedir}/flax-resources"/>
4011    <mkdir dir="${basedir}/flax-lib"/>
4012    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/flax"/>
4013      <arg value="src/java/org/flax"/></exec>
4014    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/flax"/>
4015      <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
4016    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/action/flax"/>
4017      <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
4018     <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/WEB-INF/classes/flax"/>
4019      <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
4020    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/interfaces/flax"/>
4021      <arg value="${web.home}/interfaces/flax"/></exec>
4022    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/sites/flax"/>
4023      <arg value="${web.home}/sites/flax"/></exec>
4024    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/flax-resources"/>
4025      <arg value="flax-resources"/></exec>
4026    <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/lib"/>
4027      <arg value="flax-lib"/></exec>
4028    <antcall target="flax-copy-del-files" />
4029  </target>
4030 
4031  <target name="flax-copy-del-files" description="copy some flax files into the appropriate greenstone3 directories and delete some unwanted greenstone stuff">
4032    <copy file="${web.home}/WEB-INF/classes/flax/web.xml" todir="${web.home}/WEB-INF" overwrite="true" />
4033    <copy todir="${web.home}/WEB-INF/lib">
4034            <fileset dir="${basedir}/flax-lib">
4035               <include name="*.jar"/>
4036            </fileset> 
4037    </copy>
4038    <!--<delete dir="${web.home}/sites/gateway"/>
4039    <delete dir="${web.home}/sites/localsite"/>-->
4040  </target>
4041
4042  <target name="update-flax" description="update flax from repository">
4043    <echo>updating flax ...</echo>
4044    <exec executable="svn"><arg value="update"/>
4045      <arg value="src/java/org/flax"/></exec>
4046    <exec executable="svn"><arg value="update"/>
4047      <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
4048    <exec executable="svn"><arg value="update"/>
4049      <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
4050    <exec executable="svn"><arg value="update"/>
4051      <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
4052    <exec executable="svn"><arg value="update"/>
4053      <arg value="${web.home}/interfaces/flax"/></exec>
4054    <exec executable="svn"><arg value="update"/>
4055      <arg value="${web.home}/web/sites/flax"/></exec>
4056    <exec executable="svn"><arg value="update"/>
4057      <arg value="flax-resources"/></exec>
4058    <exec executable="svn"><arg value="update"/>
4059      <arg value="flax-lib"/></exec>
4060    <antcall target="compile-core" />
4061  </target>
4062
4063  <!-- ========================End of FLAX Targets ========================= -->
4064
4065  <target name="compile-javadocs">
4066    <javadoc packagenames="org.greenstone.*"
4067           sourcepath="src/java"
4068           defaultexcludes="yes"
4069           destdir="docs/javadoc"
4070           author="true"
4071           version="true"
4072           use="true"
4073           windowtitle="Greenstone3 API">
4074    <doctitle><![CDATA[<h1>Greenstone3 API</h1>]]></doctitle>
4075    </javadoc>
4076  </target>
4077
4078<!-- ========== Some distribution targets ======================== -->
4079  <target name="remove-source">
4080    <if><bool><isset property="with.gli.and.gems"/></bool>
4081    <delete includeEmptyDirs="true">
4082      <fileset dir="." defaultexcludes="false">
4083        <patternset refid="greenstone3.source.component"/>
4084     </fileset>
4085    </delete>
4086   
4087    <else>
4088    <delete includeEmptyDirs="true">
4089      <fileset dir="." defaultexcludes="false">
4090        <patternset refid="greenstone3.source.no.gli.component"/>
4091     </fileset>
4092    </delete>
4093    </else>
4094    </if>
4095  </target>
4096
4097  <target name="dist-tidy"
4098    description="'tidies-up' a greenstone3 installation for distribution."
4099    unless="${properties.keep.src}">
4100
4101    <!-- delete unneeded things -->
4102    <delete dir="${packages.home}/axis"/>
4103    <delete><fileset dir="${packages.home}" includes="*.zip"/></delete>
4104    <delete file="README-SVN.txt"/>
4105    <delete file="build.properties.svn"/>
4106
4107    <!-- delete source files -->
4108    <antcall target="remove-source"/>
4109
4110    <!-- create empty directories -->
4111    <mkdir dir="${web.writablehome}/applet"/>
4112    <mkdir dir="${web.writablehome}/logs"/>
4113    <mkdir dir="${web.writablehome}/logs/tmp"/>
4114
4115    <!-- Lines with ***** are commented out because these files are useful if we want hybrid installations -->
4116   
4117    <!-- os specific tidy-ups -->
4118    <!-- linux, mac -->
4119    <if><bool><istrue value="${current.os.isunix}"/></bool>
4120      <!--*****<delete><fileset dir="." includes="*.bat"/></delete>-->
4121      <if><bool><isset property="with.gli.and.gems"/></bool>
4122        <!--*****<delete><fileset dir="gli" includes="*.bat"/></delete>-->
4123      </if>
4124      <!--*****<delete><fileset dir="gs2build" includes="*.bat"/></delete>-->
4125      <!--*****<delete><fileset dir="bin/script" includes="*.bat"/></delete>-->
4126      <delete file="${basedir}/gs2build/win32cfg.h"/>
4127      <delete file="${basedir}/gs2build/win32.mak"/>
4128      <delete dir="${basedir}/winutil"/>
4129      <delete failonerror="false"><fileset dir="${lib.jni}" includes="*.dll"/></delete>
4130
4131    <!-- windows -->
4132    <else><if><bool><istrue value="${current.os.iswindows}"/></bool>
4133      <!--*****<delete><fileset dir="." includes="*.sh,*.bash,*.csh"/></delete>-->
4134      <if><bool><isset property="with.gli.and.gems"/></bool>
4135    <!--*****<delete><fileset dir="gli" includes="*.sh,*.bash,*.csh"/></delete>-->
4136      </if>
4137      <!--*****<delete><fileset dir="gs2build" includes="*.sh,*.bash,*.csh"/></delete>-->
4138      <!--*****<delete><fileset dir="bin/script" includes="*.sh,*.bash,*.csh"/></delete>-->
4139    </if></else></if>
4140
4141  </target>
4142
4143  <!-- fix up executable permissions for binary release -->
4144  <target name="fix-execute-permissions">
4145    <echo>Setting binaries to executable</echo>
4146    <chmod perm="775">
4147      <fileset dir="."><patternset refid="greenstone3.executables"/></fileset>
4148    </chmod>
4149  </target>
4150 
4151  <!-- fix up executable permissions for source code release -->
4152  <target name="fix-execute-permissions-source">
4153    <chmod perm="775">
4154      <fileset dir="."><patternset refid="greenstone3.source.executables"/></fileset>
4155    </chmod>
4156  </target>
4157
4158  <!-- for macs, set up the .app shortcuts to gsi, gli, client-gli and gems -->
4159  <target name="gen-mac-shortcuts">   
4160    <if><bool><istrue value="${current.os.ismac}"/></bool>
4161      <filter token="gsdl3srchome" value="${basedir}"/>
4162      <copy file="${basedir}/gs3-server.app/Contents/document.wflow.in" tofile="${basedir}/gs3-server.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4163      <copy file="${basedir}/gli.app/Contents/document.wflow.in" tofile="${basedir}/gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4164      <copy file="${basedir}/client-gli.app/Contents/document.wflow.in" tofile="${basedir}/client-gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4165      <copy file="${basedir}/gems.app/Contents/document.wflow.in" tofile="${basedir}/gems.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4166    </if>
4167  </target>
4168
4169  <!-- ============= tweaks for making compilation static ========== --> 
4170  <target name="tweak-makefiles" depends="init" if="compile.static">
4171    <antcall target="rtftohtml-add-static" />
4172  </target>
4173   
4174  <target name="rtftohtml-add-static" depends="init" if="collection.building.enabled">
4175    <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" />
4176  </target>
4177   
4178    <target name="run-collection-tests">
4179        <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
4180            <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>
4181        </if>
4182        <for param="testjar">
4183            <path>
4184                <fileset dir="${basedir}" includes="web/sites/*/collect/*/tests/tests.jar"/>
4185            </path>
4186            <sequential>
4187                <echo>Testing @{testjar}</echo>
4188                <java classname="org.junit.runner.JUnitCore" fork="true">
4189                    <!--https://stackoverflow.com/questions/38676719/selenium-using-java-the-path-to-the-driver-executable-must-be-set-by-the-webdr-->
4190                    <sysproperty key="webdriver.gecko.driver" path="${basedir}/ext/testing/geckodriver"/>
4191                    <arg value="gstests.TestClass"/>
4192                    <jvmarg value="-DSERVERURL=${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}${server.default.servlet} "/>
4193                    <classpath>
4194                        <fileset dir="${basedir}/ext/testing/lib/java">
4195                            <include name="*.jar"/>
4196                        </fileset>
4197                        <files includes="@{testjar}"/>
4198                    </classpath>
4199                </java>
4200            </sequential>
4201        </for>
4202    </target>
4203   
4204    <target name="build-collection-tests">
4205        <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
4206            <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>
4207        </if>
4208        <for param="compiledir">
4209            <path>
4210                <dirset dir="${basedir}" includes="web/sites/*/collect/*/tests/src"/>
4211            </path>
4212            <sequential>
4213                <echo>Compiling @{compiledir}</echo>
4214                <if><bool><not><available file="@{compiledir}/../build" type="dir"/></not></bool>
4215                    <mkdir dir="@{compiledir}/../build"/>
4216                </if>
4217                <javac
4218                    srcdir="@{compiledir}"
4219                    destdir="@{compiledir}/../build"
4220                        includeantruntime="${compile.includeantruntime}"
4221                    debug="${compile.debug}"
4222                    deprecation="${compile.deprecation}"
4223                    optimize="${compile.optimize}"
4224                    encoding="${compile.encoding}">
4225                    <classpath>
4226                        <fileset dir="${basedir}/ext/testing/lib/java">
4227                            <include name="*.jar"/>
4228                        </fileset>
4229                    </classpath>
4230                    <include name="gstests/*.java"/>
4231                </javac>
4232                <jar destfile="@{compiledir}/../tests.jar">
4233                    <fileset dir="@{compiledir}/../build">
4234                        <include name="gstests/**"/>
4235                    </fileset>
4236                    <manifest>
4237                        <attribute name="Built-By" value="${user.name}" />
4238                    </manifest>
4239                </jar>
4240            </sequential>
4241        </for>
4242    </target>
4243</project>
Note: See TracBrowser for help on using the browser.