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

Revision 22847, 82.7 KB (checked in by sjm84, 10 years ago)

Fixed a few small mistakes and added ldflags

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