root/greenstone3/trunk/build.xml @ 16951

Revision 16951, 71.4 KB (checked in by oranfry, 11 years ago)

dont download or extract packages that have already been prepared

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
11  <!-- ============ classpath =================== -->
12  <path id="project.classpath">
13    <fileset dir="lib/java">
14      <include name="**/*.jar"/>
15    </fileset>
16  </path>
17 
18  <!-- ============ self defined tasks =================== -->
19  <taskdef name="mysetproxy" classname="org.greenstone.anttasks.MySetProxy" classpathref="project.classpath"/>
20  <taskdef name="getuserandpassword" classname="org.greenstone.anttasks.MyGetUserAndPassword" classpathref="project.classpath"/>
21  <taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" classpathref="project.classpath"/>
22  <taskdef name="if" classname="ise.antelope.tasks.IfTask" classpathref="project.classpath"/>
23  <taskdef name="try" classname="ise.antelope.tasks.TryTask" classpathref="project.classpath"/>
24 
25  <!-- ===================== Property Definitions =========================== -->
26 
27  <!--
28
29  Each of the following properties are used in the build script.
30  Values for these properties are set by the first place they are
31  defined, from the following list:
32
33  * Definitions on the "ant" command line (ant -Dfoo=bar compile).
34
35  * Definitions from a "build.properties" file in the top level
36  source directory of this application.
37
38  * Definitions from a "build.properties" file in the user's
39  home directory.
40
41  * Default definitions in this build.xml file.
42
43  You will note below that property values can be composed based on the
44  contents of previously defined properties.  This is a powerful technique
45  that helps you minimize the number of changes required when your development
46  environment is modified.  Note that property composition is allowed within
47  "build.properties" files as well as in the "build.xml" script.
48
49  -->
50 
51  <!--the first three properties have to be put on the top to be used by build.properties-->
52  <property name="src.packages.home" value="${basedir}/src/packages"/>
53  <property name="gdbm.home" value="${src.packages.home}/gdbm-1.8.3"/>
54  <property name="flax.svn.root" value="http://svn.greenstone.org/flax"/>
55  <property file="build.properties"/>
56  <property file="${user.home}/build.properties"/>
57
58  <!-- get properties from the environment -->
59  <property environment="env"/>
60
61   
62  <!-- version properties for external packages -->
63  <property name="tomcat.version" value="apache-tomcat-5.5.25"/>
64  <property name="axis.zip.version" value="axis-bin-1_2_1.zip"/>
65  <property name="axis.dir.version" value="axis-1_2_1"/>
66  <property name="gdbm.version" value="gdbm-1.8.3"/>
67
68  <property name="build.home" value="${basedir}/build"/>
69  <property name="src.home" value="${basedir}/src/java"/>
70  <property name="packages.home" value="${basedir}/packages"/>
71  <!-- this may be set in build.properties, eg if you move the web dir to
72  tomcats webapps directory -->
73  <property name="web.home" value="${basedir}/web"/>
74  <!-- jar files needed by applets go here -->
75  <property name="web.applet" value="${web.home}/applet"/>
76  <!-- jar files needed by the servlet (and extra ones) go here -->
77  <property name="web.lib" value="${web.home}/WEB-INF/lib"/>
78  <!-- other files needed by the servlet go here -->
79  <property name="web.classes" value="${web.home}/WEB-INF/classes"/>
80  <!--- flax: the WordNet home -->
81  <property name="wn.home" value="${web.home}/WEB-INF/classes/flax/WordNet"/>
82
83  <!-- jni libraries and java wrappers go here -->
84  <property name="lib.jni" value="${basedir}/lib/jni"/>
85 
86  <property name="javadocs" value="${basedir}/docs/javadoc"/>
87
88  <property name="app.name"      value="greenstone3"/>
89  <property name="app.path"      value="/${app.name}"/>
90
91
92  <!-- defaults - set these on the command line or in build.properties or they will take these default values-->
93  <property name="app.version" value="trunk"/>
94  <property name="branch.path" value="trunk"/>
95  <property name="branch.revision" value="HEAD"/>
96
97  <!--constants -->
98  <property name="svn.root" value="http://svn.greenstone.org"/>
99
100  <!--  <property name="cvs.root" value=":pserver:cvs_anon@cvs.scms.waikato.ac.nz:2402/usr/local/global-cvs/gsdl-src"/> -->
101  <!-- catalina home is set to tomcat basedir is already installed, otherwise
102  use greenstone's tomcat -->
103  <condition property="catalina.home" value="${tomcat.installed.path}">
104    <and>
105      <isset property="tomcat.installed.path"/>
106      <not>
107      <equals arg1="" arg2="${tomcat.installed.path}"/>
108      </not>
109    </and>
110  </condition>
111  <property name="catalina.home" value="${packages.home}/tomcat"/>
112
113  <property name="os.linux" value="Linux"/>
114  <property name="os.mac" value="Mac OS X"/>
115  <property name="os.solaris" value="SunOS"/>
116  <property name="os.unix" value="${os.linux},${os.mac},${os.solaris}"/>
117  <property name="os.windows" value="Windows 95,Windows 98,Windows 2000,Windows 2003,Windows XP,Windows NT,Windows ME"/> <!-- check this!!!-->
118
119  <!-- this is true for linux and macs -->
120  <condition property="current.os.isunix">
121    <os family="unix"/>
122  </condition>
123 
124  <condition property="current.os.isunixnotmac">
125    <and>
126      <os family="unix"/>
127      <not>
128  <os family="mac"/>
129      </not>
130    </and>
131  </condition>
132  <condition property="current.os.ismac">
133    <os family="mac"/>
134  </condition>
135 
136  <condition property="current.os.iswindows">
137    <os family="windows"/>
138  </condition>
139
140  <condition property="collection.building.enabled">
141    <not>
142      <isset property="disable.collection.building"/>
143    </not>
144  </condition>
145
146  <condition property="collection.building.enabled.windows">
147    <and>
148      <isset property="collection.building.enabled"/>
149      <isset property="current.os.iswindows"/>
150    </and>
151  </condition>
152 
153  <condition property="collection.building.enabled.unix">
154    <and>
155      <isset property="collection.building.enabled"/>
156      <isset property="current.os.isunix"/>
157    </and>
158  </condition>
159 
160  <condition property="independent-indexers">
161    <isset property="disable.collection.building"/>
162  </condition>
163
164  <!-- where is search4j tool -->
165  <condition property="search4j.exec" value="bin/search4j.exe">
166    <isset property="current.os.iswindows"/>
167  </condition>
168  <property name="search4j.exec" value="bin/search4j"/>
169
170 
171  <!-- ============= Base dirs for each package and component ============ -->
172  <property name="src.applet.home" value="${src.home}/org/greenstone/applet"/>
173  <property name="src.gsdl3.home" value="${src.home}/org/greenstone/gsdl3"/>
174  <property name="anttasks.home" value="${src.home}/org/greenstone/anttasks"/>
175  <property name="gs2build.home" value="${basedir}/gs2build"/>
176  <property name="gli.home" value="${basedir}/gli"/>
177  <property name="javagdbm.home" value="${src.packages.home}/javagdbm"/>
178 
179  <!--<property name="indexers.home" value="${basedir}/src/packages/indexers">-->
180  <condition property="indexers.home" value="${basedir}/src/packages/indexers">
181    <isset property="disable.collection.building"/>
182  </condition>
183  <condition property="indexers.home" value="${gs2build.home}/common-src/indexers">
184    <not>
185      <isset property="disable.collection.building"/>
186    </not>
187  </condition>
188
189  <property name="mg.home" value="${indexers.home}/mg"/>
190  <property name="mgpp.home" value="${indexers.home}/mgpp"/>
191  <property name="lucene.home" value="${indexers.home}/lucene-gs"/>
192
193  <!--  ==================== Compilation Control Options ==================== -->
194
195  <!--
196
197  These properties control option settings on the Javac compiler when it
198  is invoked using the <javac> task.
199
200  compile.debug        Should compilation include the debug option?
201
202  compile.deprecation  Should compilation include the deprecation option?
203
204  compile.optimize     Should compilation include the optimize option?
205
206  -->
207
208  <property name="compile.debug"       value="true"/>
209  <property name="compile.deprecation" value="true"/>
210  <property name="compile.optimize"    value="true"/>
211
212  <!--
213
214  Rather than relying on the CLASSPATH environment variable, Ant includes
215  features that makes it easy to dynamically construct the classpath you
216  need for each compilation.  The example below constructs the compile
217  classpath to include the servlet.jar file, as well as the other components
218  that Tomcat makes available to web applications automatically, plus anything
219  that you explicitly added.
220
221  -->
222
223  <path id="compile.classpath">
224    <!-- Include all jar files and libraries in our jni lib directory -->
225    <pathelement location="${lib.jni}"/>
226    <fileset dir="${lib.jni}">
227      <include name="*.jar"/>
228    </fileset>
229    <!-- Include all jar files in our web lib directory -->
230    <pathelement location="${web.lib}"/>
231    <fileset dir="${web.lib}">
232      <include name="*.jar"/>
233    </fileset>
234   
235    <!-- Include the axis jar files -->
236    <!--<fileset dir="${basedir}/comms/soap/axis/lib">
237      <include name="*.jar"/>
238    </fileset>-->
239   
240    <!-- include the jar files from the source packages -->
241    <!-- mg and mgpp get installed into lib/jni but they may not be there yet
242    so we add them in by name -->
243    <pathelement location="${lib.jni}/mg.jar"/>
244    <pathelement location="${lib.jni}/mgpp.jar"/>
245   
246    <!-- Include all elements that Tomcat exposes to applications -->
247    <pathelement location="${catalina.home}/common/classes"/>
248    <fileset dir="${catalina.home}/common/endorsed">
249      <include name="*.jar"/>
250    </fileset>
251    <fileset dir="${catalina.home}/common/lib">
252      <include name="*.jar"/>
253    </fileset>
254    <pathelement location="${catalina.home}/shared/classes"/>
255    <fileset dir="${catalina.home}/shared/lib">
256      <include name="*.jar"/>
257    </fileset>
258  </path>
259
260  <path id="local.tomcat.classpath">
261    <!-- explicitly include the jni java wrappers in the classpath -->
262    <pathelement location="${lib.jni}"/>
263    <fileset dir="${lib.jni}">
264      <include name="*.jar"/>
265    </fileset>
266  </path>
267 
268  <path id="local.tomcat.path">
269    <pathelement location="${basedir}/bin/script"/>
270    <pathelement location="${basedir}/bin"/>
271    <pathelement location="${lib.jni}"/>
272    <pathelement path="${env.PATH}"/>
273    <pathelement path="${env.Path}"/>
274    <pathelement path="${wn.home}/bin"/>
275  </path>
276
277  <target name="test-setup">
278    <echo>ant java version=${ant.java.version}</echo>
279    <echo>is unix : ${current.os.isunix}</echo>
280    <echo>is mac : ${current.os.ismac}</echo>
281    <echo>is unixnotmac : ${current.os.isunixnotmac}</echo>
282    <echo>is windows : ${current.os.iswindows}</echo>
283    <echo>os.unix: ${os.unix}</echo>
284  </target>
285  <!-- ==================== Primary and Global Targets ============================= -->
286
287  <!-- add comments about using xxx-core, xxx-packages if only want certain parts?? -->
288
289  <target name="prepare" depends="accept-properties,init,prepare-core,prepare-packages,prepare-gs2building,prepare-tomcat,prepare-axis,prepare-web,prepare-collections,prepare-gdbm, prepare-flax"
290    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.">
291    <!--  <target name="prepare" depends="accept-properties,init,prepare-core,prepare-packages,prepare-gs2building,prepare-tomcat,prepare-axis,prepare-web,prepare-collections"
292    description="Use this when you first checkout the code: 'ant prepare install'. This will do some additional cvs checkouts and downloads, so you need to be online to run this.">-->
293
294    <!-- make sure .sh files are executable -->
295    <chmod dir="${basedir}" perm="ugo+rx"
296      includes="*.sh"/>
297    <chmod dir="${basedir}/bin/script" perm="ugo+rx"
298      includes="*.sh,*.pl"/>
299  </target>
300
301  <target name="install" depends="init,install-indexer-files,configure,configure-c++,compile"
302    description="Install Greenstone 3. Use this when you first checkout the code: 'ant prepare install'."/>
303 
304  <!--  <target name="cvsupdate" depends="init,cvsupdate-packages,cvsupdate-core,cvsupdate-gs2building,cvsupdate-web"
305  description="Do a cvs update for all sources. Doesn't recompile the code. You need to be online to run this."/>-->
306  <target name="svnupdate" depends="init,svnupdate-packages,svnupdate-core,svnupdate-gs2building,svnupdate-web"
307    description="Do a `svn update` for all sources. Doesn't recompile the code. You need to be online to run this."/>
308
309  <target name="configure-c++" depends="init,configure-packages,configure-core,configure-gs2building"
310    description="Configure any C/C+/+ package code and gs2building code if necessary"/>
311 
312  <target name="configure" depends="init,configure-tomcat,configure-web"
313    description="Configure the installation. Includes setting up config files. Should be re-run if you change the build.properties file."/>
314
315  <target name="clean" depends="init,clean-packages,clean-core,clean-gs2building,clean-gdbm"
316    description="Remove all old compiled code. Includes core, packages and gs2building if necessary"/>
317 
318  <target name="distclean" depends="init,distclean-packages,clean-core,distclean-gs2building,distclean-gdbm"
319    description="Remove all compiled code and also any Makefiles etc generated during configure-c++. Includes core, packages, gs2building as necessary"/>
320 
321  <target name="compile" depends="init,compile-web,compile-packages,compile-core,compile-gs2building"
322    description="Compile all the source code, includes core, packages and gs2building if necessary. Copy jar files and executables to their correct places."/>
323 
324  <target name="update" depends="init,svnupdate,clean,configure,configure-c++,compile"
325    description="Update (thru Subversion) all the source (including core, packages and gs2building), then clean, configure and recompile. To do this without any SVN updates, run it like 'ant -Dnosvn.mode=yes update'"/>
326
327  <target name="start" depends="init,start-tomcat"
328    description="Startup the Tomcat server." >
329    <echo>${app.name} (${app.version}) server running using Apache Tomcat and Java</echo>
330    <echo>Tomcat: ${catalina.home}</echo>
331    <echo>Java  : ${java.home}</echo>
332    <echo>URL   : http://${tomcat.server}:${tomcat.port}${app.path}/</echo>
333    <!-- assuming that index.html is not needed here -->   
334  </target>
335
336  <target name="stop" depends="init,stop-tomcat"
337    description="Shutdown the Tomcat server."/>
338 
339  <target name="restart" description="Shutdown and restart Tomcat"  depends="init,stop,start"/>
340
341
342  <!-- =========== Help targets ===================================  -->
343 
344  <property name="install-command" value="ant [options] prepare install"/>
345 
346  <target name="usage" description="Print a help message">
347    <echo message="  Execute 'ant -projecthelp' for a list of targets."/>
348    <echo message="  Execute 'ant -help' for Ant help."/>
349    <echo>To install Greenstone3, run '${install-command}'.
350      There are properties defined in build.properties. The install process will ask you if these properties are set correctly. To avoid this prompt, use the '-Dproperties.accepted=yes' option.
351      To log the output, use the '-logfile build.log' option.
352      The README.txt file has more information about the ant targets and install process.
353    </echo>
354  </target>
355 
356  <target name="help" depends="usage" description="Print a help message"/>
357 
358  <target name="debug" depends="init" description="Display all the currently used properties">
359    <echoproperties/>
360  </target>
361
362  <!-- ====== initialization and setup targets ================== -->
363
364  <target name="accept-properties" unless="properties.accepted">
365    <input addproperty="properties.ok" validargs="y,n">The following properties (among others) are being used from a build.properties file found in this directory:
366      tomcat.server=${tomcat.server}
367      tomcat.port=${tomcat.port}
368      tomcat.installed.path=${tomcat.installed.path} (this is the location of Tomcat's base dir if it is already installed)
369      proxy.host=${proxy.host}
370      proxy.port=${proxy.port}
371      If these are not acceptable, please change them and rerun this target. Continue [y/n]? />
372    </input>
373    <condition property="do.abort">
374      <equals arg1="n" arg2="${properties.ok}"/>
375    </condition>
376    <fail if="do.abort">Build aborted by user. Please change your properties settings and re-run the target</fail>
377  </target>
378
379
380  <!-- this sets up some initial properties -->
381  <target name="init">
382
383    <condition property="java.too.old">
384      <or>
385        <equals arg1="1.1" arg2="${ant.java.version}"/>
386        <equals arg1="1.2" arg2="${ant.java.version}"/>
387        <equals arg1="1.3" arg2="${ant.java.version}"/>
388      </or>
389    </condition>
390    <fail if="java.too.old" message="You need Java 1.4 or greater to run Greenstone 3"/>
391   
392    <available file="${indexers.home}" property="indexers.present"/>
393    <available file="${basedir}/gli" property="gli.present"/>
394    <available file="${basedir}/gs2build" property="gs2build.present"/>
395
396    <condition property="tomcat.islocal">
397      <or>
398        <not><isset property="tomcat.installed.path"/></not>
399        <equals arg1="" arg2="${tomcat.installed.path}"/>
400      </or>
401    </condition>
402   
403    <echo>tomcat.port = ${tomcat.port}</echo>
404    <echo>gli.present = ${gli.present}</echo>
405    <echo>gs2build.present = ${gs2build.present}</echo>
406    <!-- gsdl2.installed.path appears not to be set, so wrap in if block -->
407    <if>
408        <bool><isset property="gsdl2.installed.path"/></bool>
409        <echo>gsdl2.installed.path = ${gsdl2.installed.path}</echo>
410    </if>
411
412    <condition property="proxy.present">
413      <and>
414        <isset property="proxy.host"/>
415        <not><equals arg1="" arg2="${proxy.host}"/></not>
416      </and>
417    </condition>
418
419    <condition property="need.macos.extra">
420      <and>
421        <isset property="current.os.ismac"/>
422        <not><isset property="disable.collection.building"/></not>
423      </and>
424    </condition>
425  </target>
426
427  <target name="setup-proxy" depends="init" if="proxy.present">
428    <condition property="ask.user">
429      <or>
430        <equals arg1="" arg2="${proxy.user}"/>
431        <equals arg1="" arg2="${proxy.password}"/>
432      </or>
433    </condition>
434    <getuserandpassword message="Using proxy: ${proxy.host}:${proxy.port}" if="ask.user" username="${proxy.user}" userproperty="proxy.username" pwordproperty="proxy.password"/>
435    <mysetproxy proxyhost="${proxy.host}" proxyport="${proxy.port}" proxyuser="${proxy.username}" proxypassword="${proxy.password}"/>
436  </target>
437 
438  <!-- ========== Web app Targets ================================ -->
439 
440  <target name="prepare-web" depends="init,configure-java-version">
441    <mkdir dir="${web.home}/applet"/>
442    <mkdir dir="${web.home}/logs"/>
443  </target>
444 
445  <!-- 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 -->
446  <target name="configure-java-version" depends="init"
447    description="Activates or deactivates some jar libraries as needed depending on your java version">
448
449    <available property="have.xalan.jar" file="${web.lib}/xalan.jar"/>
450    <condition property="need.xalan.jar">
451      <or>
452        <equals arg1="1.5" arg2="${ant.java.version}"/>
453        <equals arg1="1.6" arg2="${ant.java.version}"/>
454      </or>
455    </condition>
456
457    <!-- if they have xalan.jar but dont need it -->
458    <if>
459      <bool>
460        <and>
461          <isset property="have.xalan.jar"/>
462          <not><isset property="need.xalan.jar"/></not>
463        </and>
464      </bool>
465      <antcall target="deactivate-xalan-jar"/>
466    </if>
467
468    <!-- if they need xalan.jar but dont have it -->
469    <if>
470      <bool>
471        <and>
472          <not><isset property="have.xalan.jar"/></not>
473          <isset property="need.xalan.jar"/>
474        </and>
475      </bool>
476      <antcall target="activate-xalan-jar"/>
477    </if>
478
479  </target>
480 
481  <target name="activate-xalan-jar">
482    <echo>activating xalan.jar</echo>
483    <copy file="${web.lib}/xalan.jar.tmp" tofile="${web.lib}/xalan.jar"/>
484    <if><bool><isset property="current.os.ismac"/></bool>
485      <copy file="${web.lib}/xalan.jar.tmp" tofile="${catalina.home}/common/endorsed/xalan.jar"/>
486    </if>
487  </target>
488
489  <!-- to delete -->
490  <target name="copy-xalan-for-mac"></target>
491
492  <target name="deactivate-xalan-jar">
493    <echo>deactivating xalan.jar</echo>
494    <delete file="${web.lib}/xalan.jar"/>
495  </target>
496
497
498  <target name="prepare-collections" depends="init">
499    <property name="collect.dir" value="${web.home}/sites/localsite/collect"/>
500    <property name="import.zip" value="import.zip"/>
501    <property name="metadata.zip" value="metadata.zip"/>
502    <property name="index.zip" value="index/index.zip"/>
503
504    <echo message="installing collections..."/>
505    <antcall target="gs2mgdemo-install"/>
506    <antcall target="gs2mgppdemo-install"/>
507    <antcall target="gberg-install"/>
508  </target>
509
510  <target name="gs2mgdemo-prepare" if="collect.dir">
511    <property name="gs2mgdemo.dir" value="${collect.dir}/gs2mgdemo"/>
512    <fileset id="gs2mgdemofiles" dir="${gs2mgdemo.dir}">
513      <include name="${import.zip}"/>
514      <include name="${metadata.zip}"/>
515      <include name="${index.zip}"/>
516    </fileset>
517
518    <condition property="gs2mgdemo.present">
519      <and>
520        <available file="${gs2mgdemo.dir}/${import.zip}"/>
521        <available file="${gs2mgdemo.dir}/${metadata.zip}"/>
522        <available file="${gs2mgdemo.dir}/${index.zip}"/>
523      </and>
524    </condition>
525  </target>
526
527  <target name="gs2mgdemo-install" if="gs2mgdemo.present"  depends="gs2mgdemo-prepare">
528    <echo> installing gs2mgdemo</echo>
529    <unzip dest="${gs2mgdemo.dir}" src="${gs2mgdemo.dir}/${import.zip}" />
530    <unzip dest="${gs2mgdemo.dir}" src="${gs2mgdemo.dir}/${metadata.zip}" />
531    <unzip dest="${gs2mgdemo.dir}/index" src="${gs2mgdemo.dir}/${index.zip}" />
532    <!--Don't delete the zips, else doing an svn update will get them all over again.-->
533    <!--<delete><fileset refid="gs2mgdemofiles"/></delete>-->
534    <echo>collection gs2mgdemo installed</echo>
535  </target>
536
537  <target name="gs2mgppdemo-prepare" if="collect.dir">
538    <property name="gs2mgppdemo.dir" value="${collect.dir}/gs2mgppdemo"/>
539 
540    <fileset id="gs2mgppdemofiles" dir="${gs2mgppdemo.dir}">
541      <include name="${import.zip}"/>
542      <include name="${metadata.zip}"/>
543      <include name="${index.zip}"/>
544    </fileset>
545
546    <condition property="gs2mgppdemo.present">
547      <and>
548        <available file="${gs2mgppdemo.dir}/${import.zip}"/>
549        <available file="${gs2mgppdemo.dir}/${metadata.zip}"/>
550        <available file="${gs2mgppdemo.dir}/${index.zip}"/>
551      </and>
552    </condition>
553  </target>
554
555  <target name="gs2mgppdemo-install" if="gs2mgppdemo.present" depends="gs2mgppdemo-prepare">
556    <unzip dest="${gs2mgppdemo.dir}" src="${gs2mgppdemo.dir}/${import.zip}" />
557    <unzip dest="${gs2mgppdemo.dir}" src="${gs2mgppdemo.dir}/${metadata.zip}" />
558    <unzip dest="${gs2mgppdemo.dir}/index" src="${gs2mgppdemo.dir}/${index.zip}" />
559    <!--<delete><fileset refid="gs2mgppdemofiles"/></delete>-->
560    <echo>collection gs2mgppdemo installed</echo>
561  </target>   
562
563  <target name="gberg-prepare" if="collect.dir">
564    <property name="gberg.dir" value="${collect.dir}/gberg"/>
565    <fileset id="gbergfiles" dir="${gberg.dir}">
566      <include name="${index.zip}"/>
567    </fileset>
568    <available file="${gberg.dir}/${index.zip}" property="gberg.present"/>
569  </target>
570
571  <target name="gberg-install" if="gberg.present" depends="gberg-prepare">
572    <unzip dest="${gberg.dir}/index">
573      <fileset refid="gbergfiles"/>
574    </unzip>
575    <!--<delete><fileset refid="gbergfiles"/></delete>-->
576    <echo>collection gberg installed</echo>
577  </target>
578
579  <!--
580  <target name="prepare-collections" depends="init">
581    <property name="collect.dir" value="${web.home}/sites/localsite/collect"/>
582    <unzip src="${collect.dir}/gs2mgdemo/import.zip"
583      dest="${collect.dir}/gs2mgdemo"/>
584    <unzip src="${collect.dir}/gs2mgdemo/metadata.zip"
585      dest="${collect.dir}/gs2mgdemo"/>
586    <unzip src="${collect.dir}/gs2mgdemo/index/index.zip"
587      dest="${collect.dir}/gs2mgdemo/index"/>
588    <delete file="${collect.dir}/gs2mgdemo/import.zip"/>
589    <delete file="${collect.dir}/gs2mgdemo/metadata.zip"/>
590    <delete file="${collect.dir}/gs2mgdemo/index/index.zip"/>
591   
592    <unzip src="${collect.dir}/gs2mgppdemo/import.zip"
593      dest="${collect.dir}/gs2mgppdemo"/>
594    <unzip src="${collect.dir}/gs2mgppdemo/metadata.zip"
595      dest="${collect.dir}/gs2mgppdemo"/>
596    <unzip src="${collect.dir}/gs2mgppdemo/index/index.zip"
597      dest="${collect.dir}/gs2mgppdemo/index"/>
598    <delete file="${collect.dir}/gs2mgppdemo/import.zip"/>
599    <delete file="${collect.dir}/gs2mgppdemo/metadata.zip"/>
600    <delete file="${collect.dir}/gs2mgppdemo/index/index.zip"/>
601 
602    <unzip src="${collect.dir}/gberg/index/index.zip"
603      dest="${collect.dir}/gberg/index"/>
604    <delete file="${collect.dir}/gberg/index/index.zip"/>
605  </target>
606  -->
607
608  <target name="configure-web" depends="init"
609    description="Configure only the web app config files">
610    <!-- we want a unix path in the global.properties file -->
611    <pathconvert targetos="unix" property="src.gsdl3.home.unix">
612      <path path="${web.home}"/>
613    </pathconvert>
614    <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
615    <filter token="gsdl3version" value="${app.version}"/>
616    <filter token="tomcat.server" value="${tomcat.server}"/>
617    <filter token="tomcat.port" value="${tomcat.port}"/>
618    <copy file="${basedir}/resources/java/global.properties.in" tofile="${web.classes}/global.properties" filtering="true" overwrite="true"/>
619    <copy file="${basedir}/resources/java/log4j.properties.in" tofile="${web.classes}/log4j.properties" filtering="true" overwrite="true"/>
620    <chmod file="${web.classes}/global.properties" perm="600"/>
621    <chmod file="${web.classes}/log4j.properties" perm="600"/>
622  </target>
623
624  <target name="compile-web" depends="init">
625    <javac srcdir="${web.classes}"
626      destdir="${web.classes}"
627      debug="${compile.debug}"
628      deprecation="${compile.deprecation}"
629      optimize="${compile.optimize}">
630      <classpath><path refid="compile.classpath"/></classpath>
631    </javac>
632  </target>
633
634  <target name="svnupdate-web" unless="nosvn.mode">
635    <svn>
636      <update dir="${web.home}" revision="${branch.revision}"/>
637    </svn>
638  </target>
639
640  <target name="update-web" depends="init,svnupdate-web,configure-web"
641    description="update only the web stuff (config files)"/>
642
643  <!-- ======================= Tomcat Targets ========================== -->
644 
645  <!-- this target downloads and installs Tomcat -->
646  <!-- we download tomcat and the compat module - its needed for 1.4, and doesn't seem to harm 1.5 -->
647  <target name="prepare-tomcat" depends="init,setup-proxy" if="tomcat.islocal">
648
649    <if>
650      <bool>
651        <not><available file="${packages.home}/tomcat/.flagfile"/></not>
652      </bool>
653
654      <!-- check that packages dir is there -->
655      <mkdir dir="${packages.home}"/>
656      <get src="http://www.greenstone.org/gs3files/${tomcat.version}.zip"
657        dest="${packages.home}/${tomcat.version}.zip"
658        usetimestamp="true"/>
659      <unzip src="${packages.home}/${tomcat.version}.zip"
660        dest="${packages.home}"/>
661      <get src="http://www.greenstone.org/gs3files/${tomcat.version}-compat.zip"
662        dest="${packages.home}/${tomcat.version}-compat.zip"
663        usetimestamp="true"/>
664      <unzip src="${packages.home}/${tomcat.version}-compat.zip"
665        dest="${packages.home}"/>
666      <!-- delete any existing tomcat -->
667      <delete dir="${packages.home}/tomcat"/>
668      <move todir="${packages.home}/tomcat">
669        <fileset dir="${packages.home}/${tomcat.version}"/>
670      </move>
671      <copy file="${basedir}/resources/tomcat/setclasspath.bat"
672        tofile="${packages.home}/tomcat/bin/setclasspath.bat"
673        overwrite="true"/>
674      <copy file="${basedir}/resources/tomcat/setclasspath.sh"
675        tofile="${packages.home}/tomcat/bin/setclasspath.sh"
676        overwrite="true"/>
677      <!-- make sure we have execute permission for the .sh files -->
678      <chmod dir="${packages.home}/tomcat/bin" perm="ugo+rx"
679        includes="*.sh"/>   
680
681      <echo file="${packages.home}/tomcat/.flagfile">
682        the timestamp of this file is the time that tomcat was extracted from the zip files.
683        it is used to figure out whether the files need to be refreshed or not in `ant prepare-tomcat`
684      </echo>
685
686      <else>
687        <echo>Tomcat has been prepared, will not prepare</echo>
688        <echo>Delete ${packages.home}/tomcat/.flagfile to force refresh</echo>
689      </else>
690
691    </if>
692
693  </target>
694 
695  <target name="configure-tomcat" depends="init,configure-tomcat-local,configure-tomcat-external"/>
696 
697  <target name="configure-tomcat-local" depends="init" if="tomcat.islocal">
698    <!-- re-setup the server.xml file -->
699    <copy file="${basedir}/resources/tomcat/server.xml" tofile="${packages.home}/tomcat/conf/server.xml" overwrite="true">
700      <filterset>
701        <filter token="port" value="${tomcat.port}"/>
702        <filter token="shutdown-port" value="${tomcat.shutdown.port}"/>
703      </filterset>
704    </copy>
705    <!-- set up the greenstone3 context -->
706    <copy file="${basedir}/resources/tomcat/greenstone3.xml" tofile="${packages.home}/tomcat/conf/Catalina/localhost/greenstone3.xml" overwrite="true">
707      <filterset>
708        <filter token="gsdl3webhome" value="${web.home}"/>
709      </filterset>
710    </copy>
711  </target>
712
713  <target name="configure-tomcat-external" depends="init" unless="tomcat.islocal">
714    <!-- re-setup the server.xml file -->
715    <!-- need to edit the config file, or do we get the user to do this???-->
716  </target>
717 
718  <target name="start-tomcat" description="Startup only Tomcat" depends="init,configure-java-version" if="tomcat.islocal">
719    <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
720    <property name="tomcat.path" refid="local.tomcat.path"/>
721    <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx400M"/>
722    <exec executable="${catalina.home}/bin/startup.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
723      <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
724      <env key="GSDL3HOME" value="${basedir}"/>
725      <env key="PATH" path="${tomcat.path}"/>
726      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
727      <env key="CATALINA_HOME" value="${catalina.home}"/>
728      <env key="CLASSPATH" path="${tomcat.classpath}"/>
729      <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
730      <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.installed.path}/lib"/> <!-- for mac os -->
731      <env key="WNHOME" path="${wn.home}"/>
732    </exec>
733    <exec executable="${catalina.home}/bin/startup.bat" os="${os.windows}" dir="${catalina.home}/bin" spawn="true">
734      <env key="GSDLOS" value="windows"/>
735      <env key="GSDL3HOME" value="${basedir}"/>
736      <env key="Path" path="${tomcat.path}"/>
737      <env key="PATH" path="${tomcat.path}"/>
738      <env key="CATALINA_OPTS" value="${catalina.opts}"/>
739      <env key="CATALINA_HOME" value="${catalina.home}"/>
740      <env key="CLASSPATH" path="${tomcat.classpath}"/>
741    </exec>
742    <!-- wait for the server to startup in case other targets need it running -->
743    <waitfor maxwait="5" maxwaitunit="second">
744      <and>
745        <socket server="${tomcat.server}" port="${tomcat.port}"/>
746        <http url="http://${tomcat.server}:${tomcat.port}${app.path}/index.html"/>
747      </and>
748    </waitfor>
749  </target>
750
751  <!-- windows: do we want to launch a webrowser?? -->
752  <!-- shouldn't this test whether anything is running first? -->
753  <target name="stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal">
754    <exec executable="${catalina.home}/bin/shutdown.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
755      <env key="CATALINA_HOME" value="${catalina.home}"/>
756    </exec>
757    <exec executable="${catalina.home}/bin/shutdown.bat" os="${os.windows}" dir="${catalina.home}/bin" spawn="false">
758      <env key="CATALINA_HOME" value="${catalina.home}"/>
759    </exec>
760  </target>
761
762  <target name="restart-tomcat" description="Shutdown and restart only Tomcat" depends="init,stop-tomcat,start-tomcat"/>
763
764  <target name="setup-catalina-ant-tasks">
765    <!-- Configure the custom Ant tasks for the Tomcat Manager application -->
766    <taskdef name="deploy"    classname="org.apache.catalina.ant.DeployTask"
767      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
768    <taskdef name="list"      classname="org.apache.catalina.ant.ListTask"
769      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
770    <taskdef name="reload"    classname="org.apache.catalina.ant.ReloadTask"
771      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
772    <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"
773      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
774    <taskdef name="roles"     classname="org.apache.catalina.ant.RolesTask"
775      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
776    <taskdef name="start"     classname="org.apache.catalina.ant.StartTask"
777      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
778    <taskdef name="stop"      classname="org.apache.catalina.ant.StopTask"
779      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
780    <taskdef name="undeploy"  classname="org.apache.catalina.ant.UndeployTask"
781      classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
782  </target>
783
784
785  <!-- ======================= ant Targets ============================ -->
786  <target name="prepare-ant" depends="init">
787    <if>
788      <bool>
789        <not><available file="${packages.home}/ant/.flagfile"/></not>
790      </bool>
791
792      <get src="http://www.greenstone.org/gs3files/apache-ant-1.7.0-bin.zip"
793        dest="${packages.home}/apache-ant-1.7.0-bin.zip"
794        usetimestamp="true"/>
795      <unzip src="${packages.home}/apache-ant-1.7.0-bin.zip"
796        dest="${packages.home}"/>
797      <move todir="${packages.home}/ant">
798        <fileset dir="${packages.home}/apache-ant-1.7.0"/>
799      </move>
800      <echo file="${packages.home}/ant/.flagfile">
801        the timestamp of this file is the time that ant was extracted from the zip files.
802        it is used to figure out whether the files need to be refreshed or not in `ant prepare-ant`
803      </echo>
804
805      <else>
806        <echo>Ant has been prepared, will not prepare</echo>
807        <echo>Delete ${packages.home}/ant/.flagfile to force refresh</echo>
808      </else>
809
810    </if>
811  </target>
812
813  <!-- ======================= Axis Targets ============================ -->
814
815  <target name="prepare-axis" depends="init">
816
817    <if>
818      <bool>
819        <not><available file="${packages.home}/axis/.flagfile"/></not>
820      </bool>
821
822      <get src="http://www.greenstone.org/gs3files/${axis.zip.version}"
823        dest="${packages.home}/${axis.zip.version}"
824        usetimestamp="true"/>
825      <unzip src="${packages.home}/${axis.zip.version}"
826        dest="${packages.home}"/>
827      <move todir="${packages.home}/axis">
828        <fileset dir="${packages.home}/${axis.dir.version}"/>
829      </move>
830      <!-- install axis into greenstone web app -->
831      <copy todir="${web.lib}">
832        <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/lib">
833          <include name="*.jar"/>
834        </fileset>
835      </copy>
836      <copy todir="${web.home}">
837        <fileset dir="${packages.home}/axis/webapps/axis/">
838          <include name="*.jsp"/>
839          <include name="*.jws"/>
840        </fileset>
841      </copy>
842      <copy tofile="${web.home}/axis.html" file="${packages.home}/axis/webapps/axis/index.html"/>
843      <copy todir="${web.classes}">
844        <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/classes">
845          <include name="*.properties"/>
846        </fileset>
847      </copy>
848      <echo file="${packages.home}/axis/.flagfile">
849        the timestamp of this file is the time that axis was extracted from the zip files.
850        it is used to figure out whether the files need to be refreshed or not in `ant prepare-axis`
851      </echo>
852
853      <else>
854        <echo>Axis has been prepared, will not prepare</echo>
855        <echo>Delete ${packages.home}/axis/.flagfile to force refresh</echo>
856      </else>
857
858    </if>
859  </target>
860
861  <target name="soap-deploy-site" depends="init,get-sitename,get-siteuri,get-webservices,create-deployment-files,deploy-site"
862    description="Deploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work."/>
863   
864    <target name="deploy-site">
865    <java classname="org.apache.axis.client.AdminClient">
866      <classpath refid="compile.classpath"/>
867      <arg value="-l"/>
868      <arg value="http://${tomcat.server}:${tomcat.port}${app.path}/servlet/AxisServlet"/>
869      <arg file="${basedir}/resources/soap/deploy.wsdd"/>
870    </java>
871    <delete file="${basedir}/resources/soap/deploy.wsdd"/> <!--clean up, no longer used-->
872  </target>
873 
874  <target name="soap-undeploy-site" depends="get-undeploy-service-name"
875    description="Undeploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work.">
876    <filter token="servicesname" value="${axis.undeploy.servicename}"/>
877    <copy file="${basedir}/resources/soap/undeploy-site.wsdd.template"
878      tofile="${basedir}/resources/soap/undeploy.wsdd"
879      filtering="true"
880      overwrite="true"/>
881    <java classname="org.apache.axis.client.AdminClient">
882      <classpath refid="compile.classpath"/>
883      <arg value="-l"/>
884      <arg value="http://${tomcat.server}:${tomcat.port}${app.path}/servlet/AxisServlet"/>
885      <arg file="${basedir}/resources/soap/undeploy.wsdd"/>
886    </java>
887    <delete file="${basedir}/resources/soap/undeploy.wsdd"/> <!--clean up, no longer used-->
888  </target> 
889
890  <!-- this target used to deploy the default web service SOAPServer (base.webservice.name) on the localsite server
891  with the default servicename of localsite-->
892  <target name="deploy-localsite" depends="init"
893    description="Deploy the SOAP server for localsite. Will start and stop Tomcat.">
894    <antcall target="start-tomcat"/>
895    <echo>Deploying ${base.webservice.name} web services for localsite under service name: localsite</echo>
896    <antcall target="create-deployment-files">
897      <param name="axis.sitename" value="localsite"/>
898      <param name="axis.servicesname" value="${base.webservice.name}"/>
899      <param name="axis.siteuri" value="localsite"/>
900    </antcall>
901    <antcall target="deploy-site">
902      <param name="axis.sitename" value="localsite"/>
903      <param name="axis.servicesname" value="${base.webservice.name}"/>
904      <param name="axis.siteuri" value="localsite"/>
905    </antcall>
906    <echo>The Greenstone server has been started up. If you do not want it running, please type: ant stop.</echo>
907  </target>
908   
909  <target name="get-sitename" unless="axis.sitename">
910    <input addproperty="axis.sitename" defaultvalue="localsite">What site do you want to deploy services for?
911Press Enter for default:localsite</input>
912  </target>
913
914  <target name="get-undeploy-service-name" unless="axis.undeploy.servicename">
915    <input addproperty="axis.undeploy.servicename" defaultvalue="localsite">Please enter the full name of the service you wish to undeploy.
916To find out which web services you've got deployed, point your browser to http://HOST:PORT/greenstone3/services
917Or press Enter for undeploying the default:localsite /></input>
918     <echo>Name of service to undeploy: ${axis.undeploy.servicename}</echo>
919  </target>
920
921  <target name="get-webservices" unless="axis.servicesname">
922    <input addproperty="axis.servicesname" defaultvalue="${base.webservice.name}">Which set of web services do you want to deploy?
923Choose from: ${web.services.list}
924Or press Enter for default:${base.webservice.name} /></input>
925    <echo>${axis.servicesname}</echo>
926  </target>
927
928  <target name="get-siteuri" depends="get-sitename,get-webservices" unless="axis.siteuri">
929    <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>
930    <echo>Site: ${axis.sitename}, services: ${axis.servicesname}, servicesname: ${axis.siteuri}</echo>
931  </target>
932
933  <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">
934   <condition property="soap.method" value="provider='java:MSG' style='message' use='literal'">
935      <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
936    </condition>
937   
938   <!--everything else defaults to java:RPC at present-->
939   <condition property="soap.method" value="provider='java:RPC'">
940     <not>
941      <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
942    </not>
943    </condition>
944  </target>
945   
946  <target name="create-deployment-files" depends="set-soapmethod" if="axis.sitename">
947    <filter token="sitename" value="${axis.sitename}"/>
948    <filter token="siteuri" value="${axis.siteuri}"/>
949    <filter token="servicesname" value="${axis.servicesname}"/>
950    <filter token="soapmethod" value="${soap.method}"/>
951    <copy file="${basedir}/resources/soap/site.wsdd.template"
952      tofile="${basedir}/resources/soap/deploy.wsdd"
953      filtering="true"
954      overwrite="true"/>
955    <!-- create the java files and compile them -->
956    <copy file="${basedir}/resources/java/${axis.servicesname}.java.in"
957      tofile="${src.gsdl3.home}/${axis.servicesname}${axis.sitename}.java"
958      filtering="true"
959      overwrite="true"/>
960    <mkdir dir="${build.home}"/>
961    <javac srcdir="${src.home}"
962      destdir="${build.home}"
963      debug="${compile.debug}"
964      deprecation="${compile.deprecation}"
965      optimize="${compile.optimize}">
966      <classpath refid="compile.classpath"/>
967      <include name="org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.java" />
968    </javac>
969    <mkdir dir="${web.classes}/org/greenstone/gsdl3"/>
970    <copy file="${build.home}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
971      tofile="${web.classes}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
972      overwrite="true" />
973  </target>
974 
975
976  <!-- ====================== Core targets ============================== -->
977  <!-- core targets refer to the core gsdl3 java src -->
978 
979  <target name="prepare-core" unless="nosvn.mode">
980    <!-- just get rid of empty directories-->
981    <svn>
982      <update dir="."  revision="${branch.revision}"/>
983    </svn>
984  </target>
985 
986  <target name="configure-core"/>
987
988  <target name="update-core" depends="init,svnupdate-core,clean-core,compile-core"
989    description="Update only the Greenstone core" />
990 
991  <target name="svnupdate-core" unless="nosvn.mode">
992
993    <svn>
994      <update dir="." recurse="false" revision="${branch.revision}"/>
995    </svn>
996
997    <svn>
998      <update dir="bin" revision="${branch.revision}"/>
999      <update dir="comms" revision="${branch.revision}"/>
1000      <update dir="dist-resources" revision="${branch.revision}"/>
1001      <update dir="docs" revision="${branch.revision}"/>
1002      <update dir="lib" revision="${branch.revision}"/>
1003      <update dir="resources" revision="${branch.revision}"/>
1004      <update dir="src" revision="${branch.revision}"/>
1005      <update dir="winutil" revision="${branch.revision}"/>
1006    </svn>
1007
1008  </target>
1009
1010  <target name="clean-core"
1011    description="Clean only the Greenstone core">
1012    <delete dir="${build.home}"/>
1013  </target>
1014
1015  <target name="compile-core" depends="init"
1016    description="Compile only the Greenstone core">
1017    <mkdir dir="${build.home}"/>
1018    <javac srcdir="${src.home}"
1019      destdir="${build.home}"
1020      debug="${compile.debug}"
1021      deprecation="${compile.deprecation}"
1022      optimize="${compile.optimize}">
1023      <classpath>
1024        <path refid="compile.classpath"/>
1025      </classpath>
1026    </javac>
1027    <jar destfile="${build.home}/gsdl3.jar">
1028      <fileset dir="${build.home}">
1029        <include name="org/greenstone/gsdl3/**"/>
1030        <include name="org/flax/**"/>
1031        <exclude name="**/Test.class"/>
1032      </fileset>
1033      <manifest>
1034        <attribute name="Built-By" value="${user.name}" />
1035      </manifest>
1036    </jar>
1037    <copy file="${build.home}/gsdl3.jar" todir="${web.lib}"/>
1038    <!-- copy the localsite server in case we need it -->
1039    <copy file="${build.home}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" tofile="${web.classes}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" />
1040
1041    <jar destfile="${build.home}/GAI.jar">
1042      <fileset dir="${build.home}">
1043        <include name="org/greenstone/admin/**"/>
1044      </fileset>
1045      <manifest>
1046        <attribute name="Built-By" value="${user.name}" />
1047      </manifest>
1048    </jar>
1049   
1050    <jar destfile="${build.home}/phind.jar">
1051      <fileset dir="${build.home}">
1052        <include name="org/greenstone/applet/phind/**"/>
1053      </fileset>
1054      <manifest>
1055        <attribute name="Built-By" value="${user.name}" />
1056      </manifest>
1057    </jar>
1058    <mkdir dir="${web.applet}"/>
1059    <copy file="${build.home}/phind.jar" todir="${web.applet}"/>
1060    <!-- phind also needs xercesImpl.jar and xml-apis.jar to be in web/applet -->
1061    <copy file="${packages.home}/tomcat/common/endorsed/xercesImpl.jar" todir="${web.applet}"/>
1062    <copy file="${packages.home}/tomcat/common/endorsed/xml-apis.jar" todir="${web.applet}"/>
1063    <jar destfile="${build.home}/anttasks.jar">
1064      <fileset dir="${build.home}">
1065        <include name="org/greenstone/anttasks/**"/>
1066      </fileset>
1067      <manifest>
1068        <attribute name="Built-By" value="${user.name}" />
1069      </manifest>
1070    </jar>
1071    <copy file="${build.home}/anttasks.jar" todir="${basedir}/lib/java"/>
1072    <jar destfile="${build.home}/gsdl3test.jar">
1073      <fileset dir="${build.home}">
1074        <include name="org/greenstone/gsdl3/**/*Test.class"/>
1075        <include name="org/greenstone/testing/**"/>
1076      </fileset>
1077      <manifest>
1078        <attribute name="Built-By" value="${user.name}" />
1079      </manifest>
1080    </jar>
1081    <jar destfile="${build.home}/server.jar">
1082      <fileset dir="${build.home}">
1083        <include name="org/greenstone/server/**"/>
1084      </fileset>
1085      <fileset file="${basedir}/resources/java/server.properties"/>
1086      <manifest>
1087        <attribute name="Built-By" value="${user.name}"/>
1088      </manifest>
1089    </jar>
1090    <copy file="${build.home}/server.jar" todir="${basedir}"/>
1091  </target>
1092 
1093  <!-- ================== Packages targets ================================ -->
1094  <!-- these targets refer to the greenstone source packages - these need
1095  updating less often, so are in  separate targets to the core -->
1096  <target name="prepare-packages" depends="init,prepare-indexers"/>
1097 
1098  <target name="checkout-indexers" depends="init" if="independent-indexers" unless="nosvn.mode">
1099    <svn>
1100      <checkout url="${svn.root}/indexers/${branch.path}" dest="${src.packages.home}/indexers" revision="${branch.revision}"/>
1101    </svn>
1102  </target>
1103 
1104  <target name="prepare-indexers" depends="init" if="independent-indexers" unless="indexers.present">
1105    <antcall target="checkout-indexers"/>
1106  </target>
1107
1108  <target name="update-packages" depends="init,svnupdate-packages,configure-packages,clean-packages,compile-packages"
1109    description="Update only the source packages"/>
1110
1111  <target name="svnupdate-packages" unless="nosvn.mode">
1112    <svn>
1113      <update dir="${src.packages.home}" revision="${branch.revision}"/>
1114    </svn>
1115  </target>
1116 
1117  <target name="configure-packages" depends="init,configure-javagdbm,configure-indexers"
1118    description="Configure only the packages."/>
1119 
1120  <target name="configure-javagdbm">
1121    <echo>
1122      Configuring JavaGDBM
1123    </echo>
1124    <exec executable="${javagdbm.home}/configure" os="${os.linux},${os.solaris}"
1125      dir="${javagdbm.home}">
1126      <arg value="--prefix=${basedir}"/>
1127      <arg value="--libdir=${lib.jni}"/>
1128    </exec>   
1129    <exec executable="${javagdbm.home}/configure" os="${os.mac}"
1130      dir="${javagdbm.home}">
1131      <arg value="--prefix=${basedir}"/>
1132      <arg value="--libdir=${lib.jni}"/>
1133      <arg value="--with-gdbm=${gdbm.installed.path}"/>
1134    </exec>   
1135  </target>
1136
1137  <!-- Message from oran. I removed the condition from this line becuase it meant
1138  the indexers would only be configured if collection building was DISabled.
1139  Shouldn't they be configured when collection building is ENabled? -->
1140
1141  <!-- <target name="configure-indexers" depends="init" if="independent-indexers"> -->
1142  <target name="configure-indexers" depends="init">
1143    <echo>Configuring Indexers</echo>
1144    <exec executable="${indexers.home}/configure" os="${os.unix}" dir="${indexers.home}">
1145      <arg value="--prefix=${basedir}"/>
1146      <arg value="--libdir=${lib.jni}"/>
1147    </exec>         
1148  </target>
1149
1150  <target name="clean-packages" depends="init,clean-javagdbm,clean-indexers" description="Clean only the packages"/>
1151
1152  <target name="clean-javagdbm" depends="init">
1153    <exec executable="make" os="${os.unix}"
1154      dir="${javagdbm.home}">
1155      <arg value="clean"/>
1156    </exec>
1157  </target>
1158 
1159  <target name="clean-indexers" depends="init" if="independent-indexers">
1160    <exec executable="make" os="${os.unix}"
1161      dir="${indexers.home}">
1162      <arg value="clean"/>
1163    </exec>
1164    <exec executable="${indexers.home}/winMake.bat" os="${os.windows}"
1165      dir="${indexers.home}">
1166      <arg value="clean"/>
1167    </exec>
1168  </target>
1169
1170  <target name="distclean-packages" depends="init,distclean-javagdbm,distclean-indexers" description="Distclean only the packages"/>
1171
1172  <target name="distclean-javagdbm" depends="init">
1173    <exec executable="make" os="${os.unix}"
1174      dir="${javagdbm.home}">
1175      <arg value="distclean"/>
1176    </exec>
1177  </target>
1178 
1179  <target name="distclean-indexers" depends="init" if="independent-indexers">
1180    <exec executable="make" os="${os.unix}"
1181      dir="${indexers.home}">
1182      <arg value="distclean"/>
1183    </exec>
1184    <exec executable="${indexers.home}/winMake.bat" os="${os.windows}"
1185      dir="${indexers.home}">
1186      <arg value="clean"/>
1187    </exec>
1188  </target>
1189 
1190  <target name="compile-packages" description="Compile only the source packages">
1191   
1192    <!-- javagdbm -->
1193    <echo>compile javagdbm</echo>
1194    <exec executable="make" os="${os.unix}" dir="${javagdbm.home}"/>
1195    <exec executable="make" os="${os.unix}" dir="${javagdbm.home}">
1196      <arg value="install"/>
1197    </exec>
1198
1199    <!-- windows: just the java stuff. -->
1200    <echo>Windows: compile javagdbm (java only)</echo>
1201    <exec executable="${javagdbm.home}/winMake.bat" os="${os.windows}" dir="${javagdbm.home}">
1202      <arg value="compile"/>
1203      <arg value="javaonly"/>
1204    </exec>
1205
1206    <!-- install the jar file -->
1207    <echo>Install the javagdbm jar file</echo>
1208    <copy file="${javagdbm.home}/javagdbm.jar" todir="${lib.jni}"/>
1209
1210    <!-- Indexers -->
1211
1212    <!-- this may be in gs2build - we will be recompiling, but never mind -->
1213    <echo>Indexers: make (from ${indexers.home})</echo>
1214    <exec executable="make" os="${os.unix}" dir="${indexers.home}"/>
1215    <echo>Indexers: make install</echo>
1216    <exec executable="make" os="${os.unix}" dir="${indexers.home}">
1217      <arg value="install"/>
1218    </exec>
1219
1220    <echo>Indexers: make</echo>
1221    <exec executable="${indexers.home}/winMake.bat" os="${os.windows}" dir="${indexers.home}">
1222      <arg value="all"/>
1223    </exec>
1224    <echo>Indexers: make install</echo>
1225    <exec executable="${indexers.home}/winMake.bat" os="${os.windows}" dir="${indexers.home}">
1226      <arg value="install"/>
1227    </exec>
1228
1229    <!-- install the jar and jni files -->
1230    <echo>Install the indexers' jar and jni files</echo>
1231    <copy file="${mg.home}/mg.jar" todir="${lib.jni}"/>
1232    <copy file="${mgpp.home}/mgpp.jar" todir="${lib.jni}"/>
1233    <copy file="${lucene.home}/LuceneWrapper.jar" todir="${web.lib}"/>
1234    <antcall target="install-jni-files"/>
1235  </target>
1236
1237  <target name="install-jni-files" depends="init,install-jni-files-linux,install-jni-files-windows,install-jni-files-macos"/>
1238
1239  <target name="install-jni-files-linux" depends="init" if="current.os.isunixnotmac">
1240    <copy file="${mg.home}/jni/libmgretrievejni.so" todir="${lib.jni}"/>
1241    <copy file="${mg.home}/jni/libmgsearchjni.so" todir="${lib.jni}"/>
1242    <copy file="${mg.home}/jni/libmgpassjni.so" todir="${lib.jni}"/>
1243    <copy file="${mgpp.home}/jni/libmgppretrievejni.so" todir="${lib.jni}"/>
1244    <copy file="${mgpp.home}/jni/libmgppsearchjni.so" todir="${lib.jni}"/>
1245    <copy file="${mgpp.home}/jni/libmgpppassjni.so" todir="${lib.jni}"/>
1246  </target>
1247  <target name="install-jni-files-windows" depends="init" if="current.os.iswindows">
1248    <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
1249    <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
1250    <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
1251    <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
1252    <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
1253    <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
1254  </target>
1255  <target name="install-jni-files-macos" depends="init" if="current.os.ismac">
1256    <copy file="${mg.home}/jni/libmgretrievejni.jnilib" todir="${lib.jni}"/>
1257    <copy file="${mg.home}/jni/libmgsearchjni.jnilib" todir="${lib.jni}"/>
1258    <copy file="${mg.home}/jni/libmgpassjni.jnilib" todir="${lib.jni}"/>
1259    <copy file="${mgpp.home}/jni/libmgppretrievejni.jnilib" todir="${lib.jni}"/>
1260    <copy file="${mgpp.home}/jni/libmgppsearchjni.jnilib" todir="${lib.jni}"/>
1261    <copy file="${mgpp.home}/jni/libmgpppassjni.jnilib" todir="${lib.jni}"/>
1262  </target>
1263 
1264  <!-- ================== gs2building targets ===============-->
1265
1266
1267  <target name="update-gs2building" if="collection.building.enabled"
1268    depends="init,svnupdate-gs2building,rename-gs2build-files,configure-gs2building,clean-gs2building,compile-gs2building"
1269    description="Update only the Greenstone 2 building components"/>
1270
1271  <target name="svnupdate-gs2building" if="collection.building.enabled" depends="init,svnupdate-gs2build,svnupdate-gli" unless="nosvn.mode">
1272  </target>
1273
1274  <target name="svnupdate-gs2build" if="collection.building.enabled" depends="init" unless="nosvn.mode">
1275    <!-- please keep this function in sync with checkout-gs2build -->
1276
1277    <echo>updating gs2build</echo>
1278    <!-- svn updates -->
1279    <svn>
1280      <!-- perllib -->
1281      <update dir="gs2build" revision="${branch.revision}"/>
1282    </svn>
1283  </target>
1284 
1285  <target name="svnupdate-gli" if="collection.building.enabled" depends="init" unless="nosvn.mode">
1286    <svn>
1287      <update dir="${gli.home}" revision="${branch.revision}"/>
1288    </svn>
1289  </target>
1290
1291  <target name="prepare-gs2building" depends="init,prepare-gs2build,prepare-gli" if="collection.building.enabled">
1292  </target>
1293  <target name="checkout-gs2build" depends="init" if="collection.building.enabled" unless="nosvn.mode">
1294    <!-- please keep this function in sync with update-gs2build -->
1295    <echo>checking out gs2build</echo>
1296
1297    <!-- this has to be created first to avoid errors when trying to export to it later -->
1298    <mkdir dir="${basedir}/gs2build/src/lib"/>
1299
1300    <!-- svn checkouts -->
1301    <svn>
1302      <!-- perllib -->
1303      <checkout url="${svn.root}/gs2build" destPath="gs2build" revision="${branch.revision}"/>
1304
1305    </svn>
1306  </target>
1307
1308  <target name="prepare-gs2build" depends="init" if="collection.building.enabled" unless="gs2build.present">
1309    <antcall target="checkout-gs2build"/>
1310    <antcall target="unzip-windows-packages"/>
1311    <antcall target="checkout-winbin"/>
1312    <antcall target="get-windows-binaries"/>
1313    <antcall target="delete-winbin"/>
1314    <antcall target="get-macos-extra"/>
1315  </target>
1316
1317  <target name="checkout-winbin" depends="init" if="current.os.iswindows"
1318    unless="nosvn.mode">
1319    <svn>
1320      <checkout url="${svn.root}/other-projects/trunk/winbin" destPath="${basedir}/winbin" revision="${branch.revision}"/>
1321    </svn>
1322  </target>
1323
1324  <target name="update-winbin" depends="init" if="current.os.iswindows" unless="nosvn.mode">
1325    <svn>
1326      <update dir="winbin" revision="${branch.revision}"/>
1327    </svn>
1328  </target>
1329 
1330  <target name="get-windows-binaries" depends="init" if="collection.building.enabled.windows">
1331    <move todir="${gs2build.home}/bin/windows" failonerror="false">
1332      <fileset dir="${basedir}/winbin/bin"/>
1333    </move>
1334  </target>
1335  <target name="delete-winbin" depends="init" if="collection.building.enabled.windows">
1336    <delete dir="${basedir}/winbin"/>
1337  </target>
1338 
1339  <target name="unzip-windows-packages" depends="init" if="collection.building.enabled.windows"> 
1340    <unzip src="${gs2build.home}/common-src/packages/windows/gdbm/gdbm.zip"
1341      dest="${gs2build.home}/common-src/packages/windows/gdbm"/>
1342    <unzip src="${gs2build.home}/common-src/packages/windows/crypt/crypt.zip"
1343      dest="${gs2build.home}/common-src/packages/windows/crypt"/>
1344    <unzip src="${gs2build.home}/common-src/packages/windows/expat/expat.zip"
1345      dest="${gs2build.home}/common-src/packages/windows/expat"/>
1346  </target>
1347 
1348  <!-- downloads a good XML-Parser -->
1349  <target name="get-macos-extra" depends="init" if="need.macos.extra">
1350    <!--
1351    <get src="http://www.greenstone.org/gs3files/XML-Parser.tar.gz"
1352      dest="${gs2build.home}/perllib/cpan/XML-Parser.tar.gz"
1353      usetimestamp="true"/>
1354      -->
1355    <echo>Nothing extra currently needed for MacOs prepare</echo>
1356  </target>
1357
1358  <!-- untars the XML-Parser. need to do this after compiling in gs2build-->
1359  <target name="install-macos-extra" depends="init,get-macos-extra" if="need.macos.extra">
1360    <!-- make sure these directories are present, otherwise chmod craps out
1361    this chmod is needed in case we are unpacking for a second time -->
1362    <!--
1363    <mkdir dir="${gs2build.home}/perllib/cpan/perl-5.8"/>
1364    <mkdir dir="${gs2build.home}/perllib/cpan/perl-5.6"/>
1365    <chmod dir="${gs2build.home}/perllib/cpan/perl-5.8" perm="ug+w" includes="**"/>
1366    <chmod dir="${gs2build.home}/perllib/cpan/perl-5.6" perm="ug+w" includes="**"/>
1367    <untar src="${gs2build.home}/perllib/cpan/XML-Parser.tar.gz"
1368      dest="${gs2build.home}/perllib/cpan/"
1369      compression="gzip"/>
1370    -->
1371    <echo>Nothing extra currently needed for MacOs install</echo>
1372  </target>
1373
1374  <target name="install-indexer-files" depends="init" unless="indexers.present">
1375    <copy todir="${indexers.home}">
1376      <fileset dir="${gs2build.home}/common-src/indexers" />
1377    </copy>
1378    <chmod file="${indexers.home}/configure" perm="a+x"/>
1379  </target>
1380
1381  <target name="rename-gs2build-files" depends="gs2build-edit-setup-bat" if="collection.building.enabled"/>
1382 
1383  <target name="gs2build-edit-setup-bat" if="collection.building.enabled.windows">
1384    <!-- we want a windows path in the setup.bat file -->
1385    <pathconvert targetos="windows" property="gs2build.home.windows">
1386      <path path="${gs2build.home}"/>
1387    </pathconvert>
1388    <move file="${gs2build.home}/setup.bat" tofile="${gs2build.home}/setup-tmp.bat">
1389      <filterset>
1390        <filter token="gsdlhome" value="${gs2build.home.windows}"/>
1391      </filterset>
1392    </move> 
1393    <move file="${gs2build.home}/setup-tmp.bat" tofile="${gs2build.home}/setup.bat" />
1394  </target>
1395 
1396  <target name="prepare-gli" depends="init" if="collection.building.enabled" unless="gli.present">
1397    <antcall target="checkout-gli"/>
1398  </target>
1399 
1400  <target name="checkout-gli" depends="init" if="collection.building.enabled" unless="nosvn.mode">
1401    <echo>checking out gli</echo>
1402    <svn>
1403      <checkout url="${svn.root}/gli/${branch.path}" destPath="gli" revision="${branch.revision}"/>
1404    </svn>
1405  </target>
1406 
1407  <target name="configure-gs2building" depends="init" if="collection.building.enabled"
1408    description="Configure only the Greenstone 2 building components">
1409    <exec executable="${gs2build.home}/configure" os="${os.linux},${os.solaris}"
1410      dir="${gs2build.home}">
1411      <arg value="--prefix=${gs2build.home}"/>
1412    </exec>
1413    <exec executable="${gs2build.home}/configure" os="${os.mac}"
1414      dir="${gs2build.home}">
1415      <arg value="--prefix=${gs2build.home}"/>
1416      <arg value="--with-gdbm=${gdbm.installed.path}"/>
1417    </exec>
1418  </target>
1419
1420  <target name="clean-gs2building" depends="init,clean-gli,clean-gs2build"
1421    description="Clean only the Greenstone 2 building components"
1422    if="collection.building.enabled"/>
1423 
1424  <target name="clean-gli" depends="init" if="collection.building.enabled">
1425    <!-- gli -->
1426    <property name="gli.home" value="${basedir}/gli"/>
1427    <!-- linux -->
1428    <exec executable="clean.sh" os="${os.unix}" dir="${gli.home}"
1429      resolveExecutable="true"/>
1430    <!-- windows -->
1431    <exec executable="clean.bat" os="${os.windows}" dir="${gli.home}"
1432      resolveExecutable="true"/>
1433  </target>
1434 
1435  <target name="clean-gs2build" depends="init" if="collection.building.enabled">
1436    <!-- gs2build -->
1437    <!--linux:  -->
1438    <exec executable="make" os="${os.unix}" dir="${gs2build.home}">
1439      <arg value="clean"/>
1440    </exec>
1441    <!-- windows: -->   
1442    <!-- run the setup script -->
1443    <!--<exec executable="${compile.windows.c++.setup}" os="${os.windows}" />-->
1444    <!--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-->
1445    <exec executable="nmake" dir="${gs2build.home}" os="${os.windows}" >
1446      <arg value="/f"/>
1447      <arg value="win32.mak"/>
1448      <arg value="clean"/>
1449    </exec>
1450  </target>
1451 
1452  <target name="distclean-gs2building" depends="init,clean-gli,clean-gs2build,distclean-gs2build"
1453    description="Distclean only the Greenstone 2 building components"
1454    if="collection.building.enabled"/>
1455
1456  <target name="distclean-gs2build" depends="init" if="collection.building.enabled">
1457    <exec executable="make" os="${os.unix}" dir="${gs2build.home}">
1458      <arg value="distclean"/>
1459    </exec>
1460  </target>
1461 
1462  <target name="compile-gs2building" depends="init,compile-gs2build,compile-gli" if="collection.building.enabled"
1463    description="Compile only the Greenstone 2 building components">
1464  </target>
1465 
1466  <target name="compile-gli" depends="init" if="collection.building.enabled">
1467    <!-- gli -->
1468    <property name="gli.home" value="${basedir}/gli"/>
1469
1470    <!-- linux -->
1471    <exec executable="makegli.sh" os="${os.unix}" dir="${gli.home}" resolveExecutable="true"/>
1472    <!--remote gli-->
1473    <exec executable="makejar.sh" os="${os.unix}" dir="${gli.home}"
1474      resolveExecutable="true"/>
1475    <!-- windows -->
1476    <exec executable="makegli.bat" os="${os.windows}" dir="${gli.home}" resolveExecutable="true"/>
1477    <!--remote gli-->
1478    <exec executable="makejar.bat" os="${os.windows}" dir="${gli.home}"
1479      resolveExecutable="true"/>
1480    <copy file="${gli.home}/GLIServer.jar" todir="${gs2build.home}/bin/java" />
1481  </target>
1482 
1483  <target name="compile-gs2build" depends="init" if="collection.building.enabled">
1484    <!-- gs2build -->
1485    <!--linux: make, make install -->
1486    <exec executable="make" os="${os.unix}" dir="${gs2build.home}">
1487    </exec>
1488    <exec executable="make" os="${os.unix}" dir="${gs2build.home}">
1489      <arg value="install"/>
1490    </exec>
1491    <!-- run the setup script -->
1492    <!-- <exec executable="${compile.windows.c++.setup}" os="${os.windows}"/>-->
1493     <!--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-->
1494    <exec executable="nmake" dir="${gs2build.home}" os="${os.windows}">
1495      <arg value="/f"/>
1496      <arg value="win32.mak"/>
1497    </exec>
1498    <exec executable="nmake" dir="${gs2build.home}" os="${os.windows}">
1499      <arg value="/f"/>
1500      <arg value="win32.mak"/>
1501      <arg value="install"/>
1502    </exec>
1503    <!-- LuceneWrapper jar file not installed by default -->
1504    <mkdir dir="${gs2build.home}/bin/java"/>
1505    <copy file="${lucene.home}/LuceneWrapper.jar" todir="${gs2build.home}/bin/java"/>
1506    <antcall target="install-gs2build-indexers-windows"/>
1507    <antcall target="install-macos-extra"/>
1508  </target>
1509 
1510  <target name="install-gs2build-indexers-windows" depends="init" if="collection.building.enabled.windows">
1511    <copy todir="${gs2build.home}/bin/windows">
1512      <fileset dir="${gs2build.home}/common-src/indexers/bin">
1513        <include name="*.*"/>
1514      </fileset>
1515    </copy>
1516  </target>
1517
1518  <target name="gli" description="Run the Greenstone Librarian Interface" depends="init" if="collection.building.enabled">
1519    <exec executable="${basedir}/gli/gli4gs3.sh" os="${os.linux},${os.solaris}" dir="${basedir}/gli" spawn="true">
1520      <env key="gsdl3path" path="${basedir}"/>
1521      <env key="gsdlpath" path="${basedir}/gs2build"/>
1522    </exec>
1523    <exec executable="${basedir}/gli/gli4gs3.sh" os="${os.mac}" dir="${basedir}/gli" spawn="true">
1524      <env key="gsdl3path" path="${basedir}"/>
1525      <env key="gsdlpath" path="${basedir}/gs2build"/>
1526      <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${gdbm.installed.path}/lib"/>
1527    </exec>
1528    <exec executable="${basedir}/gli/gli4gs3.bat" os="${os.windows}" dir="${basedir}/gli" spawn="true">
1529      <env key="GSDL3PATH" path="${basedir}"/>
1530      <env key="GSDLPATH" path="${basedir}/gs2build"/>
1531    </exec>
1532    <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 gli4gs3.sh/bat from the greenstone3/gli directory.
1533    </echo>
1534  </target>
1535 
1536
1537  <!-- ======================== TESTING Targets ========================= -->
1538 
1539  <target name="test" description="Run the (incomplete) JUnit test suite "
1540    depends="init">
1541    <mkdir dir="${basedir}/test"/>
1542    <junit printsummary="withOutAndErr"
1543      errorproperty="test.failed"
1544      failureproperty="test.failed"
1545      fork="${junit.fork}">
1546      <formatter type="plain"/>
1547      <classpath>
1548        <pathelement location="${build.home}/gsdl3test.jar"/>
1549        <path refid="compile.classpath"/>
1550      </classpath>
1551      <test name="${testcase}" if="testcase"/>
1552      <batchtest todir="${basedir}/test" unless="testcase">
1553        <fileset dir="${build.home}" ncludes="**/*Test.class" />
1554      </batchtest>
1555    </junit>
1556    <echo>
1557      *********************************************
1558      Test output can be found in directory 'test'
1559      *********************************************
1560    </echo>
1561  </target>
1562
1563  <!-- ======================== FLAX Targets ========================= -->
1564  <target name="prepare-flax" description="check out flax source code from another repository" if="install.flax">
1565    <echo>checking out flax ...</echo>
1566    <mkdir dir="${basedir}/src/java/org/flax"/>
1567    <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/flax"/>
1568    <mkdir dir="${web.home}/WEB-INF/classes/flax"/>
1569    <mkdir dir="${web.home}/interfaces/flax"/>
1570    <mkdir dir="${web.home}/sites/flax"/>
1571    <mkdir dir="${basedir}/flax-resources"/>
1572    <mkdir dir="${basedir}/flax-lib"/>
1573    <svn>
1574      <checkout url="${flax.checkout.path}/src/java/org/flax/" 
1575        destPath="${basedir}/src/java/org/flax"/>
1576      <checkout url="${flax.checkout.path}/src/java/org/greenstone/gsdl3/flax/"
1577        destPath="${basedir}/src/java/org/greenstone/gsdl3/flax"/>
1578      <checkout url="${flax.checkout.path}/web/WEB-INF/classes/flax/"
1579        destPath="${web.home}/WEB-INF/classes/flax"/>
1580      <checkout url="${flax.checkout.path}/web/interfaces/flax/"
1581        destPath="${web.home}/interfaces/flax"/>
1582      <checkout url="${flax.checkout.path}/web/sites/flax/"
1583        destPath="${web.home}/sites/flax"/>
1584      <checkout url="${flax.checkout.path}/flax-resources"
1585        destPath="${basedir}/flax-resources"/>
1586      <checkout url="${flax.checkout.path}/lib"
1587        destPath="${basedir}/flax-lib"/>
1588    </svn>
1589    <echo>prepare flax files...</echo>
1590    <move file="${web.home}/WEB-INF/web.xml" tofile="${web.home}/WEB-INF/web.xml.greenstone3backup"/>
1591    <antcall target="flax-copy-files" />
1592    <antcall target="unzip-flax-collections" />
1593    <antcall target="unzip-flax-resources" />
1594  </target>
1595
1596  <target name="update-flax" description="update flax from repository">
1597    <echo>updating flax ...</echo>
1598    <svn>
1599      <update dir="${basedir}/src/java/org/flax"/>
1600      <update dir="${basedir}/src/java/org/greenstone/gsdl3/flax"/>
1601      <update dir="${web.home}/WEB-INF/classes/flax"/>
1602      <update dir="${web.home}/interfaces/flax"/>
1603      <update dir="${web.home}/sites/flax"/>
1604    </svn>
1605    <antcall target="flax-copy-files" />
1606    <antcall target="unzip-flax-collections" />       
1607  </target>
1608
1609  <target name="unzip-flax-collections" >
1610    <property name="coll.dir" value="${web.home}/sites/flax/collect"/>
1611    <unzip dest="${coll.dir}"> 
1612      <fileset dir="${coll.dir}">
1613        <include name="*.zip"/>
1614      </fileset>   
1615    </unzip>   
1616    <delete>
1617      <fileset dir="${coll.dir}" includes="*.zip"/>
1618    </delete>
1619  </target>
1620
1621  <target name="unzip-flax-resources" >
1622    <property name="classes.dir" value="${web.home}/WEB-INF/classes/flax"/>
1623    <unzip dest="${classes.dir}"> 
1624      <fileset dir="${classes.dir}">
1625        <include name="*.zip"/>
1626      </fileset>   
1627    </unzip>   
1628    <delete>
1629      <fileset dir="${classes.dir}" includes="*.zip"/>
1630    </delete>
1631  </target>
1632 
1633  <target name="flax-copy-files" description="copy some flax files into the appropriate greenstone3 directories">
1634    <echo>copying flax files ...</echo>
1635    <copy file="${web.home}/WEB-INF/classes/flax/web.xml" todir="${web.home}/WEB-INF" overwrite="true" />
1636    <!-- A configuration file containing web service binding information for the axis engine -->
1637    <copy file="${web.home}/WEB-INF/classes/flax/server-config.wsdd" todir="${web.home}/WEB-INF" overwrite="true" />
1638    <copy file="${basedir}/flax-resources/flax-build.xml" todir="${basedir}" overwrite="true" />
1639    <copy file="${basedir}/flax-lib/opennlp-tools-1.3.0.jar" todir="${web.home}/WEB-INF/lib" overwrite="true" />   
1640  </target>
1641
1642
1643  <!-- ======================== GDBM Targets ========================= -->
1644
1645  <target name="prepare-gdbm" depends="init" if="install.gdbm">
1646
1647    <if>
1648      <bool>
1649        <not><available file="${src.packages.home}/${gdbm.version}/.flagfile"/></not>
1650      </bool>
1651
1652      <get src="http://www.greenstone.org/gs3files/${gdbm.version}.tar.gz"
1653        dest="${src.packages.home}/${gdbm.version}.tar.gz" usetimestamp="true"/>
1654      <untar compression= "gzip" src="${src.packages.home}/${gdbm.version}.tar.gz" dest="${src.packages.home}" />
1655      <echo file="${src.packages.home}/${gdbm.version}/.flagfile">
1656        the timestamp of this file is the time that gdbm was extracted from the tar files.
1657        it is used to figure out whether the files need to be refreshed or not in `ant prepare-gdbm`
1658      </echo>
1659      <chmod dir="${src.packages.home}/${gdbm.version}" perm="ugo+wrx" includes="**" />
1660      <antcall target="configure-gdbm" />
1661      <antcall target="compile-gdbm" />
1662
1663     <else>
1664       <echo>GDBM has been prepared, will not prepare</echo>
1665       <echo>Delete ${src.packages.home}/${gdbm.version}/.flagfile to force a fresh prepare</echo>
1666     </else>
1667
1668    </if>
1669
1670  </target> 
1671
1672  <target name="configure-gdbm" if="install.gdbm">
1673    <echo>
1674      Configuring GDBM
1675    </echo>
1676    <exec executable="${gdbm.home}/configure" os="${os.mac},${os.unix}"
1677      dir="${gdbm.home}">
1678      <arg value="--prefix=${gdbm.home}"/>
1679    </exec>   
1680  </target>
1681
1682  <target name="clean-gdbm" depends="init"  if="install.gdbm">   
1683    <echo>clean GDBM</echo>
1684    <exec executable="make" os="${os.unix}" dir="${gdbm.home}" >
1685      <arg value="clean"/>
1686    </exec>
1687  </target>
1688
1689
1690  <target name="distclean-gdbm" depends="init"  if="install.gdbm">   
1691    <echo>distclean GDBM</echo>
1692    <exec executable="make" os="${os.unix}" dir="${gdbm.home}" >
1693      <arg value="distclean"/>
1694    </exec>
1695  </target>
1696
1697  <target name="compile-gdbm" depends="init"  if="install.gdbm">   
1698    <echo>compile GDBM</echo>
1699    <exec executable="groups" os="${os.unix}" outputproperty="usergroups"/>
1700    <exec executable="awk" os="${os.unix}" inputstring="${usergroups}" outputproperty="firstgroup">
1701      <arg line="'{print $1}'"/>
1702    </exec>
1703
1704    <exec executable="make" os="${os.unix}" dir="${gdbm.home}"/>
1705    <exec executable="make" os="${os.unix}" dir="${gdbm.home}">
1706      <arg value="BINOWN=${env.USER}"/>
1707      <arg value="BINGRP=${firstgroup}"/>
1708      <arg value="install"/>
1709    </exec>
1710  </target>
1711
1712</project>
Note: See TracBrowser for help on using the browser.