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

Revision 27846, 124.1 KB (checked in by davidb, 7 years ago)

Target added that means the Solr extension is now automatically added to main java code, and installs an example collection

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