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

Revision 26433, 103.8 KB (checked in by ak19, 7 years ago)

Forgot to commit inclusion of FEDORA_HOME env to tomcat start and stop in build.xml, and the all important index write lock timeout property (for fedoragsearch) in build.properties.in.

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