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

Revision 32334, 153.0 KB (checked in by ak19, 13 months ago)

All the changes (still preliminary) that use tomcat.https.port and tomcat.http.port to determine tomcat.port and write it out to build.xml. Now the server application won't quite work: it can't change the port numbers as its code only knows to write out the tomcat.port, and the actual tomcat port (https or http) will remain unaffected. But I'll fix this later, as there may be a better way to do this.

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