greenstone.org greenstone wiki greenstone trac planet greenstone

root/greenstone3/trunk/build.xml

http://svn.greenstone.org/greenstone3/trunk/build.xml
Revision 17556, 72.4 kB (checked in by oranfry, 1 month ago)

fixing a bug where the full path to configurewas not spcified in the target to compile search4j

Line 
1 <?xml version="1.0"?>
2 <!-- ======================================================================
3      March 2005                                                   
4
5      Greenstone3 build and install script
6                  
7      kjdon                                                               
8      ====================================================================== -->
9 <project name="greenstone3" default="usage" basedir=".">
10
11   <!-- ============ classpath =================== -->
12   <path id="project.classpath">
13     <fileset dir="lib/java">
14       <include name="**/*.jar"/>
15     </fileset>
16   </path>
17  
18   <!-- ============ self defined tasks =================== -->
19   <taskdef name="mysetproxy" classname="org.greenstone.anttasks.MySetProxy" classpathref="project.classpath"/>
20   <taskdef name="getuserandpassword" classname="org.greenstone.anttasks.MyGetUserAndPassword" classpathref="project.classpath"/>
21   <taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" classpathref="project.classpath"/>
22   <taskdef name="if" classname="ise.antelope.tasks.IfTask" classpathref="project.classpath"/>
23   <taskdef name="try" classname="ise.antelope.tasks.TryTask" classpathref="project.classpath"/>
24  
25   <!-- ===================== Property Definitions =========================== -->
26  
27   <!--
28
29   Each of the following properties are used in the build script.
30   Values for these properties are set by the first place they are
31   defined, from the following list:
32
33   * Definitions on the "ant" command line (ant -Dfoo=bar compile).
34
35   * Definitions from a "build.properties" file in the top level
36   source directory of this application.
37
38   * Definitions from a "build.properties" file in the user's
39   home directory.
40
41   * Default definitions in this build.xml file.
42
43   You will note below that property values can be composed based on the
44   contents of previously defined properties.  This is a powerful technique
45   that helps you minimize the number of changes required when your development
46   environment is modified.  Note that property composition is allowed within
47   "build.properties" files as well as in the "build.xml" script.
48
49   -->
50  
51   <!--the first three properties have to be put on the top to be used by build.properties-->
52   <property name="src.packages.home" value="${basedir}/src/packages"/>
53   <property name="gdbm.home" value="${src.packages.home}/gdbm-1.8.3"/>
54   <property name="flax.svn.root" value="http://svn.greenstone.org/flax"/>
55   <property file="build.properties"/>
56   <if><bool><available file="${user.home}/build.properties"/></bool>
57     <property file="${user.home}/build.properties"/>
58   </if>
59
60   <!-- get properties from the environment -->
61   <property environment="env"/>
62
63    
64   <!-- version properties for external packages -->
65   <property name="tomcat.version" value="apache-tomcat-5.5.25"/>
66   <property name="axis.zip.version" value="axis-bin-1_2_1.zip"/>
67   <property name="axis.dir.version" value="axis-1_2_1"/>
68   <property name="gdbm.version" value="gdbm-1.8.3"/>
69
70   <property name="build.home" value="${basedir}/build"/>
71   <property name="src.home" value="${basedir}/src/java"/>
72   <property name="packages.home" value="${basedir}/packages"/>
73   <!-- this may be set in build.properties, eg if you move the web dir to
74   tomcats webapps directory -->
75   <property name="web.home" value="${basedir}/web"/>
76   <!-- jar files needed by applets go here -->
77   <property name="web.applet" value="${web.home}/applet"/>
78   <!-- jar files needed by the servlet (and extra ones) go here -->
79   <property name="web.lib" value="${web.home}/WEB-INF/lib"/>
80   <!-- other files needed by the servlet go here -->
81   <property name="web.classes" value="${web.home}/WEB-INF/classes"/>
82   <!--- flax: the WordNet home -->
83   <property name="wn.home" value="${web.home}/WEB-INF/classes/flax/WordNet"/>
84
85   <!-- jni libraries and java wrappers go here -->
86   <property name="lib.jni" value="${basedir}/lib/jni"/>
87  
88   <property name="javadocs" value="${basedir}/docs/javadoc"/>
89
90   <property name="app.name"      value="greenstone3"/>
91   <property name="app.path"      value="/${app.name}"/>
92
93
94   <!-- defaults - set these on the command line or in build.properties or they will take these default values-->
95   <property name="app.version" value="trunk"/>
96   <property name="branch.path" value="trunk"/>
97   <property name="branch.revision" value="HEAD"/>
98
99   <!--constants -->
100   <property name="svn.root" value="http://svn.greenstone.org"/>
101
102   <!--  <property name="cvs.root" value=":pserver:cvs_anon@cvs.scms.waikato.ac.nz:2402/usr/local/global-cvs/gsdl-src"/> -->
103   <!-- catalina home is set to tomcat basedir is already installed, otherwise
104   use greenstone's tomcat -->
105   <condition property="catalina.home" value="${tomcat.installed.path}">
106     <and>
107       <isset property="tomcat.installed.path"/>
108       <not>
109       <equals arg1="" arg2="${tomcat.installed.path}"/>
110       </not>
111     </and>
112   </condition>
113   <property name="catalina.home" value="${packages.home}/tomcat"/>
114
115   <property name="os.linux" value="Linux"/>
116   <property name="os.mac" value="Mac OS X"/>
117   <property name="os.solaris" value="SunOS"/>
118   <property name="os.unix" value="${os.linux},${os.mac},${os.solaris}"/>
119   <property name="os.windows" value="Windows 95,Windows 98,Windows 2000,Windows 2003,Windows XP,Windows NT,Windows ME,Windows Vista"/> <!-- check this!!!-->
120
121   <!-- this is true for linux and macs -->
122   <condition property="current.os.isunix">
123     <os family="unix"/>
124   </condition>
125  
126   <condition property="current.os.isunixnotmac">
127     <and>
128       <os family="unix"/>
129       <not>
130   <os family="mac"/>
131       </not>
132     </and>
133   </condition>
134   <condition property="current.os.ismac">
135     <os family="mac"/>
136   </condition>
137  
138   <condition property="current.os.iswindows">
139     <os family="windows"/>
140   </condition>
141
142   <condition property="collection.building.enabled">
143     <not>
144       <isset property="disable.collection.building"/>
145     </not>
146   </condition>
147
148   <condition property="collection.building.enabled.windows">
149     <and>
150       <isset property="collection.building.enabled"/>
151       <isset property="current.os.iswindows"/>
152     </and>
153   </condition>
154  
155   <condition property="collection.building.enabled.unix">
156     <and>
157       <isset property="collection.building.enabled"/>
158       <isset property="current.os.isunix"/>
159     </and>
160   </condition>
161  
162   <condition property="independent-indexers">
163     <isset property="disable.collection.building"/>
164   </condition>
165
166   <!-- where is search4j tool -->
167   <condition property="search4j.exec" value="bin/search4j.exe">
168     <isset property="current.os.iswindows"/>
169   </condition>
170   <property name="search4j.exec" value="bin/search4j"/>
171
172  
173   <!-- ============= Base dirs for each package and component ============ -->
174   <property name="src.applet.home" value="${src.home}/org/greenstone/applet"/>
175   <property name="src.gsdl3.home" value="${src.home}/org/greenstone/gsdl3"/>
176   <property name="anttasks.home" value="${src.home}/org/greenstone/anttasks"/>
177   <property name="gs2build.home" value="${basedir}/gs2build"/>
178   <property name="gli.home" value="${basedir}/gli"/>
179   <property name="javagdbm.home" value="${src.packages.home}/javagdbm"/>
180  
181   <!--<property name="indexers.home" value="${basedir}/src/packages/indexers">-->
182   <condition property="indexers.home" value="${basedir}/src/packages/indexers">
183     <isset property="disable.collection.building"/>
184   </condition>
185   <condition property="indexers.home" value="${gs2build.home}/common-src/indexers">
186     <not>
187       <isset property="disable.collection.building"/>
188     </not>
189   </condition>
190
191   <property name="mg.home" value="${indexers.home}/mg"/>
192   <property name="mgpp.home" value="${indexers.home}/mgpp"/>
193   <property name="lucene.home" value="${indexers.home}/lucene-gs"/>
194
195   <!--  ==================== Compilation Control Options ==================== -->
196
197   <!--
198
199   These properties control option settings on the Javac compiler when it
200   is invoked using the <javac> task.
201
202   compile.debug        Should compilation include the debug option?
203
204   compile.deprecation  Should compilation include the deprecation option?
205
206   compile.optimize     Should compilation include the optimize option?
207
208   -->
209
210   <property name="compile.debug"       value="true"/>
211   <property name="compile.deprecation" value="true"/>
212   <property name="compile.optimize"    value="true"/>
213
214   <!--
215
216   Rather than relying on the CLASSPATH environment variable, Ant includes
217   features that makes it easy to dynamically construct the classpath you
218   need for each compilation.  The example below constructs the compile
219   classpath to include the servlet.jar file, as well as the other components
220   that Tomcat makes available to web applications automatically, plus anything
221   that you explicitly added.
222
223   -->
224
225   <path id="compile.classpath">
226     <!-- Include all jar files and libraries in our jni lib directory -->
227     <pathelement location="${lib.jni}"/>
228     <fileset dir="${lib.jni}">
229       <include name="*.jar"/>
230     </fileset>
231     <!-- Include all jar files in our web lib directory -->
232     <pathelement location="${web.lib}"/>
233     <fileset dir="${web.lib}">
234       <include name="*.jar"/>
235     </fileset>
236    
237     <!-- Include the axis jar files -->
238     <!--<fileset dir="${basedir}/comms/soap/axis/lib">
239       <include name="*.jar"/>
240     </fileset>-->
241    
242     <!-- include the jar files from the source packages -->
243     <!-- mg and mgpp get installed into lib/jni but they may not be there yet
244     so we add them in by name -->
245     <pathelement location="${lib.jni}/mg.jar"/>
246     <pathelement location="${lib.jni}/mgpp.jar"/>
247    
248     <!-- Include all elements that Tomcat exposes to applications -->
249     <pathelement location="${catalina.home}/common/classes"/>
250     <fileset dir="${catalina.home}/common/endorsed">
251       <include name="*.jar"/>
252     </fileset>
253     <fileset dir="${catalina.home}/common/lib">
254       <include name="*.jar"/>
255     </fileset>
256     <pathelement location="${catalina.home}/shared/classes"/>
257     <fileset dir="${catalina.home}/shared/lib">
258       <include name="*.jar"/>
259     </fileset>
260   </path>
261
262   <path id="local.tomcat.classpath">
263     <!-- explicitly include the jni java wrappers in the classpath -->
264     <pathelement location="${lib.jni}"/>
265     <fileset dir="${lib.jni}">
266       <include name="*.jar"/>
267     </fileset>
268   </path>
269  
270   <path id="local.tomcat.path">
271     <pathelement location="${basedir}/bin/script"/>
272     <pathelement location="${basedir}/bin"/>
273     <pathelement location="${lib.jni}"/>
274     <pathelement path="${env.PATH}"/>
275     <pathelement path="${env.Path}"/>
276     <pathelement path="${wn.home}/bin"/>
277   </path>
278
279   <target name="test-setup">
280     <echo>ant java version=${ant.java.version}</echo>
281     <echo>is unix : ${current.os.isunix}</echo>
282     <echo>is mac : ${current.os.ismac}</echo>
283     <echo>is unixnotmac : ${current.os.isunixnotmac}</echo>
284     <echo>is windows : ${current.os.iswindows}</echo>
285     <echo>os.unix: ${os.unix}</echo>
286   </target>
287   <!-- ==================== Primary and Global Targets ============================= -->
288
289   <!-- add comments about using xxx-core, xxx-packages if only want certain parts?? -->
290
291   <target name="prepare" depends="accept-properties,init,prepare-core,prepare-packages,prepare-gs2building,prepare-tomcat,prepare-axis,prepare-web,prepare-collections,prepare-gdbm, prepare-flax"
292     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.">
293     <!--  <target name="prepare" depends="accept-properties,init,prepare-core,prepare-packages,prepare-gs2building,prepare-tomcat,prepare-axis,prepare-web,prepare-collections"
294     description="Use this when you first checkout the code: 'ant prepare install'. This will do some additional cvs checkouts and downloads, so you need to be online to run this.">-->
295
296     <!-- make sure .sh files are executable -->
297     <chmod dir="${basedir}" perm="ugo+rx"
298       includes="*.sh"/>
299     <chmod dir="${basedir}/bin/script" perm="ugo+rx"
300       includes="*.sh,*.pl"/>
301   </target>
302
303   <target name="install" depends="init,install-indexer-files,configure,configure-c++,compile"
304     description="Install Greenstone 3. Use this when you first checkout the code: 'ant prepare install'."/>
305  
306   <!--  <target name="cvsupdate" depends="init,cvsupdate-packages,cvsupdate-core,cvsupdate-gs2building,cvsupdate-web"
307   description="Do a cvs update for all sources. Doesn't recompile the code. You need to be online to run this."/>-->
308   <target name="svnupdate" depends="init,svnupdate-packages,svnupdate-core,svnupdate-gs2building,svnupdate-web"
309     description="Do a `svn update` for all sources. Doesn't recompile the code. You need to be online to run this."/>
310
311   <target name="configure-c++" depends="init,configure-packages,configure-core,configure-gs2building"
312     description="Configure any C/C+/+ package code and gs2building code if necessary"/>
313  
314   <target name="configure" depends="init,configure-tomcat,configure-web"
315     description="Configure the installation. Includes setting up config files. Should be re-run if you change the build.properties file."/>
316
317   <target name="clean" depends="init,clean-packages,clean-core,clean-gs2building,clean-gdbm"
318     description="Remove all old compiled code. Includes core, packages and gs2building if necessary"/>
319  
320   <target name="distclean" depends="init,distclean-packages,clean-core,distclean-gs2building,distclean-gdbm"
321     description="Remove all compiled code and also any Makefiles etc generated during configure-c++. Includes core, packages, gs2building as necessary"/>
322  
323   <target name="compile" depends="init,compile-web,compile-packages,compile-core,compile-gs2building"
324     description="Compile all the source code, includes core, packages and gs2building if necessary. Copy jar files and executables to their correct places."/>
325  
326   <target name="update" depends="init,svnupdate,clean,configure,configure-c++,compile"
327     description="Update (thru Subversion) all the source (including core, packages and gs2building), then clean, configure and recompile. To do this without any SVN updates, run it like 'ant -Dnosvn.mode=yes update'"/>
328
329   <target name="start" depends="init,start-tomcat"
330     description="Startup the Tomcat server." >
331     <echo>${app.name} (${app.version}) server running using Apache Tomcat and Java</echo>
332     <echo>Tomcat: ${catalina.home}</echo>
333     <echo>Java  : ${java.home}</echo>
334     <echo>URL   : http://${tomcat.server}:${tomcat.port}${app.path}/</echo>
335     <!-- assuming that index.html is not needed here -->   
336   </target>
337
338   <target name="stop" depends="init,stop-tomcat"
339     description="Shutdown the Tomcat server."/>
340  
341   <target name="restart" description="Shutdown and restart Tomcat"  depends="init,stop,start"/>
342
343
344   <!-- =========== Help targets ===================================  -->
345  
346   <property name="install-command" value="ant [options] prepare install"/>
347  
348   <target name="usage" description="Print a help message">
349     <echo message="  Execute 'ant -projecthelp' for a list of targets."/>
350     <echo message="  Execute 'ant -help' for Ant help."/>
351     <echo>To install Greenstone3, run '${install-command}'.
352       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.
353       To log the output, use the '-logfile build.log' option.
354       The README.txt file has more information about the ant targets and install process.
355     </echo>
356   </target>
357  
358   <target name="help" depends="usage" description="Print a help message"/>
359  
360   <target name="debug" depends="init" description="Display all the currently used properties">
361     <echoproperties/>
362   </target>
363
364   <!-- ====== initialization and setup targets ================== -->
365
366   <target name="accept-properties" unless="properties.accepted">
367     <input addproperty="properties.ok" validargs="y,n">The following properties (among others) are being used from a build.properties file found in this directory:
368       tomcat.server=${tomcat.server}
369       tomcat.port=${tomcat.port}
370       tomcat.installed.path=${tomcat.installed.path} (this is the location of Tomcat's base dir if it is already installed)
371       proxy.host=${proxy.host}
372       proxy.port=${proxy.port}
373       If these are not acceptable, please change them and rerun this target. Continue [y/n]? />
374     </input>
375     <condition property="do.abort">
376       <equals arg1="n" arg2="${properties.ok}"/>
377     </condition>
378     <fail if="do.abort">Build aborted by user. Please change your properties settings and re-run the target</fail>
379   </target>
380
381
382   <!-- this sets up some initial properties -->
383   <target name="init">
384
385     <condition property="java.too.old">
386       <or>
387         <equals arg1="1.1" arg2="${ant.java.version}"/>
388         <equals arg1="1.2" arg2="${ant.java.version}"/>
389         <equals arg1="1.3" arg2="${ant.java.version}"/>
390       </or>
391     </condition>
392     <fail if="java.too.old" message="You need Java 1.4 or greater to run Greenstone 3"/>
393    
394     <available file="${indexers.home}" property="indexers.present"/>
395     <available file="${basedir}/gli" property="gli.present"/>
396     <available file="${basedir}/gs2build" property="gs2build.present"/>
397
398     <condition property="tomcat.islocal">
399       <or>
400         <not><isset property="tomcat.installed.path"/></not>
401         <equals arg1="" arg2="${tomcat.installed.path}"/>
402       </or>
403     </condition>
404    
405     <echo>tomcat.port = ${tomcat.port}</echo>
406     <echo>gli.present = ${gli.present}</echo>
407     <echo>gs2build.present = ${gs2build.present}</echo>
408     <!-- gsdl2.installed.path appears not to be set, so wrap in if block -->
409     <if>
410         <bool><isset property="gsdl2.installed.path"/></bool>
411         <echo>gsdl2.installed.path = ${gsdl2.installed.path}</echo>
412     </if>
413
414     <condition property="proxy.present">
415       <and>
416         <isset property="proxy.host"/>
417         <not><equals arg1="" arg2="${proxy.host}"/></not>
418       </and>
419     </condition>
420
421     <condition property="need.macos.extra">
422       <and>
423         <isset property="current.os.ismac"/>
424         <not><isset property="disable.collection.building"/></not>
425       </and>
426     </condition>
427   </target>
428
429   <target name="setup-proxy" depends="init" if="proxy.present">
430     <condition property="ask.user">
431       <or>
432         <equals arg1="" arg2="${proxy.user}"/>
433         <equals arg1="" arg2="${proxy.password}"/>
434       </or>
435     </condition>
436     <getuserandpassword message="Using proxy: ${proxy.host}:${proxy.port}" if="ask.user" username="${proxy.user}" userproperty="proxy.username" pwordproperty="proxy.password"/>
437     <mysetproxy proxyhost="${proxy.host}" proxyport="${proxy.port}" proxyuser="${proxy.username}" proxypassword="${proxy.password}"/>
438   </target>
439  
440   <!-- ========== Web app Targets ================================ -->
441  
442   <target name="prepare-web" depends="init,configure-java-version">
443     <mkdir dir="${web.home}/applet"/>
444     <mkdir dir="${web.home}/logs"/>
445   </target>
446  
447   <!-- 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 -->
448   <target name="configure-java-version" depends="init"
449     description="Activates or deactivates some jar libraries as needed depending on your java version">
450
451     <available property="have.xalan.jar" file="${web.lib}/xalan.jar"/>
452     <condition property="need.xalan.jar">
453       <or>
454         <equals arg1="1.5" arg2="${ant.java.version}"/>
455         <equals arg1="1.6" arg2="${ant.java.version}"/>
456       </or>
457     </condition>
458
459     <!-- if they have xalan.jar but dont need it -->
460     <if>
461       <bool>
462         <and>
463           <isset property="have.xalan.jar"/>
464           <not><isset property="need.xalan.jar"/></not>
465         </and>
466       </bool>
467       <antcall target="deactivate-xalan-jar"/>
468     </if>
469
470     <!-- if they need xalan.jar but dont have it -->
471     <if>
472       <bool>
473         <and>
474           <not><isset property="have.xalan.jar"/></not>
475           <isset property="need.xalan.jar"/>
476         </and>
477       </bool>
478       <antcall target="activate-xalan-jar"/>
479     </if>
480
481   </target>
482  
483   <target name="activate-xalan-jar">
484     <echo>activating xalan.jar</echo>
485     <copy file="${web.lib}/xalan.jar.tmp" tofile="${web.lib}/xalan.jar"/>
486     <if><bool><isset property="current.os.ismac"/></bool>
487       <copy file="${web.lib}/xalan.jar.tmp" tofile="${catalina.home}/common/endorsed/xalan.jar"/>
488     </if>
489   </target>
490
491   <!-- to delete -->
492   <target name="copy-xalan-for-mac"></target>
493
494   <target name="deactivate-xalan-jar">
495     <echo>deactivating xalan.jar</echo>
496     <delete file="${web.lib}/xalan.jar"/>
497   </target>
498
499
500   <target name="prepare-collections" depends="init">
501     <property name="collect.dir" value="${web.home}/sites/localsite/collect"/>
502     <property name="import.zip" value="import.zip"/>
503     <property name="metadata.zip" value="metadata.zip"/>
504     <property name="index.zip" value="index.zip"/>
505
506     <echo message="installing collections..."/>
507     <antcall target="gs2mgdemo-install"/>
508     <antcall target="gs2mgppdemo-install"/>
509     <antcall target="gberg-install"/>
510   </target>
511
512   <target name="gs2mgdemo-prepare" if="collect.dir">
513     <property name="gs2mgdemo.dir" value="${collect.dir}/gs2mgdemo"/>
514     <fileset id="gs2mgdemofiles" dir="${gs2mgdemo.dir}">
515       <include name="${import.zip}"/>
516       <include name="${metadata.zip}"/>
517       <include name="${index.zip}"/>
518     </fileset>
519
520     <condition property="gs2mgdemo.present">
521       <and>
522         <available file="${gs2mgdemo.dir}/${import.zip}"/>
523         <available file="${gs2mgdemo.dir}/${metadata.zip}"/>
524         <available file="${gs2mgdemo.dir}/${index.zip}"/>
525       </and>
526     </condition>
527   </target>
528
529   <target name="gs2mgdemo-install" if="gs2mgdemo.present" depends="gs2mgdemo-prepare">
530     <echo> installing gs2mgdemo</echo>
531     <unzip dest="${gs2mgdemo.dir}" src="${gs2mgdemo.dir}/${import.zip}" />
532     <unzip dest="${gs2mgdemo.dir}" src="${gs2mgdemo.dir}/${metadata.zip}" />
533     <unzip dest="${gs2mgdemo.dir}" src="${gs2mgdemo.dir}/${index.zip}" />
534     <!--Don't delete the zips, else doing an svn update will get them all over again.-->
535     <!--<delete><fileset refid="gs2mgdemofiles"/></delete>-->
536     <echo>collection gs2mgdemo installed</echo>
537   </target>
538
539   <target name="gs2mgppdemo-prepare" if="collect.dir">
540     <property name="gs2mgppdemo.dir" value="${collect.dir}/gs2mgppdemo"/>
541  
542     <fileset id="gs2mgppdemofiles" dir="${gs2mgppdemo.dir}">
543       <include name="${import.zip}"/>
544       <include name="${metadata.zip}"/>
545       <include name="${index.zip}"/>
546     </fileset>
547
548     <condition property="gs2mgppdemo.present">
549       <and>
550         <available file="${gs2mgppdemo.dir}/${import.zip}"/>
551         <available file="${gs2mgppdemo.dir}/${metadata.zip}"/>
552         <available file="${gs2mgppdemo.dir}/${index.zip}"/>
553       </and>
554     </condition>
555   </target>
556
557   <target name="gs2mgppdemo-install" if="gs2mgppdemo.present" depends="gs2mgppdemo-prepare">
558     <unzip dest="${gs2mgppdemo.dir}" src="${gs2mgppdemo.dir}/${import.zip}" />
559     <unzip dest="${gs2mgppdemo.dir}" src="${gs2mgppdemo.dir}/${metadata.zip}" />
560     <unzip dest="${gs2mgppdemo.dir}" src="${gs2mgppdemo.dir}/${index.zip}" />
561     <!--<delete><fileset refid="gs2mgppdemofiles"/></delete>-->
562     <echo>collection gs2mgppdemo installed</echo>
563   </target>   
564
565   <target name="gberg-prepare" if="collect.dir">
566     <property name="gberg.dir" value="${collect.dir}/gberg"/>
567     <fileset id="gbergfiles" dir="${gberg.dir}">
568       <include name="index/${index.zip}"/>
569     </fileset>
570     <available file="${gberg.dir}/index/${index.zip}" property="gberg.present"/>
571   </target>
572
573   <target name="gberg-install" if="gberg.present" depends="gberg-prepare">
574     <unzip dest="${gberg.dir}/index">
575       <fileset refid="gbergfiles"/>
576     </unzip>
577     <!--<delete><fileset refid="gbergfiles"/></delete>-->
578     <echo>collection gberg installed</echo>
579   </target>
580
581   <!--
582   <target name="prepare-collections" depends="init">
583     <property name="collect.dir" value="${web.home}/sites/localsite/collect"/>
584     <unzip src="${collect.dir}/gs2mgdemo/import.zip"
585       dest="${collect.dir}/gs2mgdemo"/>
586     <unzip src="${collect.dir}/gs2mgdemo/metadata.zip"
587       dest="${collect.dir}/gs2mgdemo"/>
588     <unzip src="${collect.dir}/gs2mgdemo/index/index.zip"
589       dest="${collect.dir}/gs2mgdemo/index"/>
590     <delete file="${collect.dir}/gs2mgdemo/import.zip"/>
591     <delete file="${collect.dir}/gs2mgdemo/metadata.zip"/>
592     <delete file="${collect.dir}/gs2mgdemo/index/index.zip"/>
593    
594     <unzip src="${collect.dir}/gs2mgppdemo/import.zip"
595       dest="${collect.dir}/gs2mgppdemo"/>
596     <unzip src="${collect.dir}/gs2mgppdemo/metadata.zip"
597       dest="${collect.dir}/gs2mgppdemo"/>
598     <unzip src="${collect.dir}/gs2mgppdemo/index/index.zip"
599       dest="${collect.dir}/gs2mgppdemo/index"/>
600     <delete file="${collect.dir}/gs2mgppdemo/import.zip"/>
601     <delete file="${collect.dir}/gs2mgppdemo/metadata.zip"/>
602     <delete file="${collect.dir}/gs2mgppdemo/index/index.zip"/>
603  
604     <unzip src="${collect.dir}/gberg/index/index.zip"
605       dest="${collect.dir}/gberg/index"/>
606     <delete file="${collect.dir}/gberg/index/index.zip"/>
607   </target>
608   -->
609
610   <target name="configure-web" depends="init"
611     description="Configure only the web app config files">
612     <!-- we want a unix path in the global.properties file -->
613     <pathconvert targetos="unix" property="src.gsdl3.home.unix">
614       <path path="${web.home}"/>
615     </pathconvert>
616     <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
617     <filter token="gsdl3version" value="${app.version}"/>
618     <filter token="tomcat.server" value="${tomcat.server}"/>
619     <filter token="tomcat.port" value="${tomcat.port}"/>
620     <copy file="${basedir}/resources/java/global.properties.in" tofile="${web.classes}/global.properties" filtering="true" overwrite="true"/>
621     <copy file="${basedir}/resources/java/log4j.properties.in" tofile="${web.classes}/log4j.properties" filtering="true" overwrite="true"/>
622     <chmod file="${web.classes}/global.properties" perm="600"/>
623     <chmod file="${web.classes}/log4j.properties" perm="600"/>
624   </target>
625
626   <target name="compile-web" depends="init">
627     <javac srcdir="${web.classes}"
628       destdir="${web.classes}"
629       debug="${compile.debug}"
630       deprecation="${compile.deprecation}"
631       optimize="${compile.optimize}">
632       <classpath><path refid="compile.classpath"/></classpath>
633     </javac>
634   </target>
635
636   <target name="svnupdate-web" unless="nosvn.mode">
637     <svn>
638       <update dir="${web.home}" revision="${branch.revision}"/>
639     </svn>
640   </target>
641
642   <target name="update-web" depends="init,svnupdate-web,configure-web"
643     description="update only the web stuff (config files)"/>
644
645   <!-- ======================= Tomcat Targets ========================== -->
646  
647   <!-- this target downloads and installs Tomcat -->
648   <!-- we download tomcat and the compat module - its needed for 1.4, and doesn't seem to harm 1.5 -->
649   <target name="prepare-tomcat" depends="init,setup-proxy" if="tomcat.islocal">
650
651     <if>
652       <bool>
653         <not><available file="${packages.home}/tomcat/.flagfile"/></not>
654       </bool>
655
656       <!-- check that packages dir is there -->
657       <mkdir dir="${packages.home}"/>
658       <get src="http://www.greenstone.org/gs3files/${tomcat.version}.zip"
659         dest="${packages.home}/${tomcat.version}.zip"
660         usetimestamp="true"/>
661       <unzip src="${packages.home}/${tomcat.version}.zip"
662         dest="${packages.home}"/>
663       <get src="http://www.greenstone.org/gs3files/${tomcat.version}-compat.zip"
664         dest="${packages.home}/${tomcat.version}-compat.zip"
665         usetimestamp="true"/>
666       <unzip src="${packages.home}/${tomcat.version}-compat.zip"
667         dest="${packages.home}"/>
668       <!-- delete any existing tomcat -->
669       <delete dir="${packages.home}/tomcat"/>
670       <move todir="${packages.home}/tomcat">
671         <fileset dir="${packages.home}/${tomcat.version}"/>
672       </move>
673       <copy file="${basedir}/resources/tomcat/setclasspath.bat"
674         tofile="${packages.home}/tomcat/bin/setclasspath.bat"
675         overwrite="true"/>
676       <copy file="${basedir}/resources/tomcat/setclasspath.sh"
677         tofile="${packages.home}/tomcat/bin/setclasspath.sh"
678         overwrite="true"/>
679       <!-- make sure we have execute permission for the .sh files -->
680       <chmod dir="${packages.home}/tomcat/bin" perm="ugo+rx"
681         includes="*.sh"/>   
682
683       <echo file="${packages.home}/tomcat/.flagfile">
684         the timestamp of this file is the time that tomcat was extracted from the zip files.
685         it is used to figure out whether the files need to be refreshed or not in `ant prepare-tomcat`
686       </echo>
687
688       <else>
689         <echo>Tomcat has been prepared, will not prepare</echo>
690         <echo>Delete ${packages.home}/tomcat/.flagfile to force refresh</echo>
691       </else>
692
693     </if>
694
695   </target>
696  
697   <target name="configure-tomcat" depends="init,configure-tomcat-local,configure-tomcat-external"/>
698  
699   <target name="configure-tomcat-local" depends="init" if="tomcat.islocal">
700     <!-- re-setup the server.xml file -->
701     <copy file="${basedir}/resources/tomcat/server.xml" tofile="${packages.home}/tomcat/conf/server.xml" overwrite="true">
702       <filterset>
703         <filter token="port" value="${tomcat.port}"/>
704         <filter token="shutdown-port" value="${tomcat.shutdown.port}"/>
705       </filterset>
706     </copy>
707     <!-- set up the greenstone3 context -->
708     <copy file="${basedir}/resources/tomcat/greenstone3.xml" tofile="${packages.home}/tomcat/conf/Catalina/localhost/greenstone3.xml" overwrite="true">
709       <filterset>
710         <filter token="gsdl3webhome" value="${web.home}"/>
711       </filterset>
712     </copy>
713   </target>
714
715   <target name="configure-tomcat-external" depends="init" unless="tomcat.islocal">
716     <!-- re-setup the server.xml file -->
717     <!-- need to edit the config file, or do we get the user to do this???-->
718   </target>
719  
720   <target name="start-tomcat" description="Startup only Tomcat" depends="init,configure-java-version" if="tomcat.islocal">
721     <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
722     <property name="tomcat.path" refid="local.tomcat.path"/>
723     <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx400M"/>
724     <exec executable="${catalina.home}/bin/startup.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
725       <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
726       <env key="GSDL3HOME" value="${basedir}"/>
727       <env key="PATH" path="${tomcat.path}"/>
728       <env key="CATALINA_OPTS" value="${catalina.opts}"/>
729       <env key="CATALINA_HOME" value="${catalina.home}"/>
730       <env key="CLASSPATH" path="${tomcat.classpath}"/>
731       <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
732       <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.installed.path}/lib"/> <!-- for mac os -->
733       <env key="WNHOME" path="${wn.home}"/>
734     </exec>
735     <exec executable="${catalina.home}/bin/startup.bat" os="${os.windows}" dir="${catalina.home}/bin" spawn="true">
736       <env key="GSDLOS" value="windows"/>
737       <env key="GSDL3HOME" value="${basedir}"/>
738       <env key="Path" path="${tomcat.path}"/>
739       <env key="PATH" path="${tomcat.path}"/>
740       <env key="CATALINA_OPTS" value="${catalina.opts}"/>
741       <env key="CATALINA_HOME" value="${catalina.home}"/>
742       <env key="CLASSPATH" path="${tomcat.classpath}"/>
743     </exec>
744     <!-- wait for the server to startup in case other targets need it running -->
745     <waitfor maxwait="5" maxwaitunit="second">
746       <and>
747         <socket server="${tomcat.server}" port="${tomcat.port}"/>
748         <http url="http://${tomcat.server}:${tomcat.port}${app.path}/index.html"/>
749       </and>
750     </waitfor>
751   </target>
752
753   <!-- windows: do we want to launch a webrowser?? -->
754   <!-- shouldn't this test whether anything is running first? -->
755   <target name="stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal">
756     <exec executable="${catalina.home}/bin/shutdown.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
757       <env key="CATALINA_HOME" value="${catalina.home}"/>
758     </exec>
759     <exec executable="${catalina.home}/bin/shutdown.bat" os="${os.windows}" dir="${catalina.home}/bin" spawn="false">
760       <env key="CATALINA_HOME" value="${catalina.home}"/>
761     </exec>
762   </target>
763
764   <target name="restart-tomcat" description="Shutdown and restart only Tomcat" depends="init,stop-tomcat,start-tomcat"/>
765
766   <target name="setup-catalina-ant-tasks">
767     <!-- Configure the custom Ant tasks for the Tomcat Manager application -->
768     <taskdef name="deploy"    classname="org.apache.catalina.ant.DeployTask"
769       classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
770     <taskdef name="list"      classname="org.apache.catalina.ant.ListTask"
771       classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
772     <taskdef name="reload"    classname="org.apache.catalina.ant.ReloadTask"
773       classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
774     <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"
775       classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
776     <taskdef name="roles"     classname="org.apache.catalina.ant.RolesTask"
777       classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
778     <taskdef name="start"     classname="org.apache.catalina.ant.StartTask"
779       classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
780     <taskdef name="stop"      classname="org.apache.catalina.ant.StopTask"
781       classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
782     <taskdef name="undeploy"  classname="org.apache.catalina.ant.UndeployTask"
783       classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
784   </target>
785
786
787   <!-- ======================= ant Targets ============================ -->
788   <target name="prepare-ant" depends="init">
789     <if>
790       <bool>
791         <not><available file="${packages.home}/ant/.flagfile"/></not>
792       </bool>
793
794       <get src="http://www.greenstone.org/gs3files/apache-ant-1.7.0-bin.zip"
795         dest="${packages.home}/apache-ant-1.7.0-bin.zip"
796         usetimestamp="true"/>
797       <unzip src="${packages.home}/apache-ant-1.7.0-bin.zip"
798         dest="${packages.home}"/>
799       <move todir="${packages.home}/ant">
800         <fileset dir="${packages.home}/apache-ant-1.7.0"/>
801       </move>
802       <echo file="${packages.home}/ant/.flagfile">
803         the timestamp of this file is the time that ant was extracted from the zip files.
804         it is used to figure out whether the files need to be refreshed or not in `ant prepare-ant`
805       </echo>
806
807       <else>
808         <echo>Ant has been prepared, will not prepare</echo>
809         <echo>Delete ${packages.home}/ant/.flagfile to force refresh</echo>
810       </else>
811
812     </if>
813   </target>
814
815   <!-- ======================= Axis Targets ============================ -->
816
817   <target name="prepare-axis" depends="init">
818
819     <if>
820       <bool>
821         <not><available file="${packages.home}/axis/.flagfile"/></not>
822       </bool>
823
824       <get src="http://www.greenstone.org/gs3files/${axis.zip.version}"
825         dest="${packages.home}/${axis.zip.version}"
826         usetimestamp="true"/>
827       <unzip src="${packages.home}/${axis.zip.version}"
828         dest="${packages.home}"/>
829       <move todir="${packages.home}/axis">
830         <fileset dir="${packages.home}/${axis.dir.version}"/>
831       </move>
832       <!-- install axis into greenstone web app -->
833       <copy todir="${web.lib}">
834         <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/lib">
835           <include name="*.jar"/>
836         </fileset>
837       </copy>
838       <copy todir="${web.home}">
839         <fileset dir="${packages.home}/axis/webapps/axis/">
840           <include name="*.jsp"/>
841           <include name="*.jws"/>
842         </fileset>
843       </copy>
844       <copy tofile="${web.home}/axis.html" file="${packages.home}/axis/webapps/axis/index.html"/>
845       <copy todir="${web.classes}">
846         <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/classes">
847           <include name="*.properties"/>
848         </fileset>
849       </copy>
850       <echo file="${packages.home}/axis/.flagfile">
851         the timestamp of this file is the time that axis was extracted from the zip files.
852         it is used to figure out whether the files need to be refreshed or not in `ant prepare-axis`
853       </echo>
854
855       <else>
856         <echo>Axis has been prepared, will not prepare</echo>
857         <echo>Delete ${packages.home}/axis/.flagfile to force refresh</echo>
858       </else>
859
860     </if>
861   </target>
862
863   <target name="soap-deploy-site" depends="init,get-sitename,get-siteuri,get-webservices,create-deployment-files,deploy-site"
864     description="Deploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work."/>
865    
866     <target name="deploy-site">
867     <java classname="org.apache.axis.client.AdminClient">
868       <classpath refid="compile.classpath"/>
869       <arg value="-l"/>
870       <arg value="http://${tomcat.server}:${tomcat.port}${app.path}/servlet/AxisServlet"/>
871       <arg file="${basedir}/resources/soap/deploy.wsdd"/>
872     </java>
873     <delete file="${basedir}/resources/soap/deploy.wsdd"/> <!--clean up, no longer used-->
874   </target>
875  
876   <target name="soap-undeploy-site" depends="get-undeploy-service-name"
877     description="Undeploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work.">
878     <filter token="servicesname" value="${axis.undeploy.servicename}"/>
879     <copy file="${basedir}/resources/soap/undeploy-site.wsdd.template"
880       tofile="${basedir}/resources/soap/undeploy.wsdd"
881       filtering="true"
882       overwrite="true"/>
883     <java classname="org.apache.axis.client.AdminClient">
884       <classpath refid="compile.classpath"/>
885       <arg value="-l"/>
886       <arg value="http://${tomcat.server}:${tomcat.port}${app.path}/servlet/AxisServlet"/>
887       <arg file="${basedir}/resources/soap/undeploy.wsdd"/>
888     </java>
889     <delete file="${basedir}/resources/soap/undeploy.wsdd"/> <!--clean up, no longer used-->
890   </target> 
891
892   <!-- this target used to deploy the default web service SOAPServer (base.webservice.name) on the localsite server
893   with the default servicename of localsite-->
894   <target name="deploy-localsite" depends="init"
895     description="Deploy the SOAP server for localsite. Will start and stop Tomcat.">
896     <antcall target="start-tomcat"/>
897     <echo>Deploying ${base.webservice.name} web services for localsite under service name: localsite</echo>
898     <antcall target="create-deployment-files">
899       <param name="axis.sitename" value="localsite"/>
900       <param name="axis.servicesname" value="${base.webservice.name}"/>
901       <param name="axis.siteuri" value="localsite"/>
902     </antcall>
903     <antcall target="deploy-site">
904       <param name="axis.sitename" value="localsite"/>
905       <param name="axis.servicesname" value="${base.webservice.name}"/>
906       <param name="axis.siteuri" value="localsite"/>
907     </antcall>
908     <echo>The Greenstone server has been started up. If you do not want it running, please type: ant stop.</echo>
909   </target>
910    
911   <target name="get-sitename" unless="axis.sitename">
912     <input addproperty="axis.sitename" defaultvalue="localsite">What site do you want to deploy services for?
913 Press Enter for default:localsite</input>
914   </target>
915
916   <target name="get-undeploy-service-name" unless="axis.undeploy.servicename">
917     <input addproperty="axis.undeploy.servicename" defaultvalue="localsite">Please enter the full name of the service you wish to undeploy.
918 To find out which web services you've got deployed, point your browser to http://HOST:PORT/greenstone3/services
919 Or press Enter for undeploying the default:localsite /></input>
920      <echo>Name of service to undeploy: ${axis.undeploy.servicename}</echo>
921   </target>
922
923   <target name="get-webservices" unless="axis.servicesname">
924     <input addproperty="axis.servicesname" defaultvalue="${base.webservice.name}">Which set of web services do you want to deploy?
925 Choose from: ${web.services.list}
926 Or press Enter for default:${base.webservice.name} /></input>
927     <echo>${axis.servicesname}</echo>
928   </target>
929
930   <target name="get-siteuri" depends="get-sitename,get-webservices" unless="axis.siteuri">
931     <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>
932     <echo>Site: ${axis.sitename}, services: ${axis.servicesname}, servicesname: ${axis.siteuri}</echo>
933   </target>
934
935   <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">
936    <condition property="soap.method" value="provider='java:MSG' style='message' use='literal'">
937       <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
938     </condition>
939    
940    <!--everything else defaults to java:RPC at present-->
941    <condition property="soap.method" value="provider='java:RPC'">
942      <not>
943       <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
944     </not>
945     </condition>
946   </target>
947    
948   <target name="create-deployment-files" depends="set-soapmethod" if="axis.sitename">
949     <filter token="sitename" value="${axis.sitename}"/>
950     <filter token="siteuri" value="${axis.siteuri}"/>
951     <filter token="servicesname" value="${axis.servicesname}"/>
952     <filter token="soapmethod" value="${soap.method}"/>
953     <copy file="${basedir}/resources/soap/site.wsdd.template"
954       tofile="${basedir}/resources/soap/deploy.wsdd"
955       filtering="true"
956       overwrite="true"/>
957     <!-- create the java files and compile them -->
958     <copy file="${basedir}/resources/java/${axis.servicesname}.java.in"
959       tofile="${src.gsdl3.home}/${axis.servicesname}${axis.sitename}.java"
960       filtering="true"
961       overwrite="true"/>
962     <mkdir dir="${build.home}"/>
963     <javac srcdir="${src.home}"
964       destdir="${build.home}"
965       debug="${compile.debug}"
966       deprecation="${compile.deprecation}"
967       optimize="${compile.optimize}">
968       <classpath refid="compile.classpath"/>
969       <include name="org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.java" />
970     </javac>
971     <mkdir dir="${web.classes}/org/greenstone/gsdl3"/>
972     <copy file="${build.home}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
973       tofile="${web.classes}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
974       overwrite="true" />
975   </target>
976  
977
978   <!-- ====================== Core targets ============================== -->
979   <!-- core targets refer to the core gsdl3 java src -->
980  
981   <target name="prepare-core" unless="nosvn.mode">
982     <!-- just get rid of empty directories-->
983     <svn>
984       <update dir="."  revision="${branch.revision}"/>
985     </svn>
986   </target>
987  
988   <target name="configure-core"/>
989
990   <target name="update-core" depends="init,svnupdate-core,clean-core,compile-core"
991     description="Update only the Greenstone core" />
992  
993   <target name="svnupdate-core" unless="nosvn.mode">
994
995     <svn>
996       <update dir="." recurse="false" revision="${branch.revision}"/>
997     </svn>
998
999     <svn>
1000       <update dir="bin" revision="${branch.revision}"/>
1001       <update dir="comms" revision="${branch.revision}"/>
1002       <update dir="dist-resources" revision="${branch.revision}"/>
1003       <update dir="docs" revision="${branch.revision}"/>
1004       <update dir="lib" revision="${branch.revision}"/>
1005       <update dir="resources" revision="${branch.revision}"/>
1006       <update dir="src" revision="${branch.revision}"/>
1007       <update dir="winutil" revision="${branch.revision}"/>
1008     </svn>
1009
1010   </target>