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

Revision 22199, 79.0 KB (checked in by sjm84, 10 years ago)

Fixed mistake in jar filename (should have been mgpp.jar not mg.jar). Copy and paste error!

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