root/greenstone3/trunk/build.xml @ 20839

Revision 20839, 76.4 KB (checked in by xiao, 10 years ago)

Modified the target flax-copy-files to copy the file FlaxWebService?.wsdl from flax-resources/ to web/, replacing tomcat server and port on the fly

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