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

Revision 32337, 153.1 KB (checked in by ak19, 13 months ago)

Changing tomcat port variable names so they'll be easier to work with later: it's now tomcat.port.http(s) instead of tomcat.http(s).port.

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