source: main/trunk/greenstone3/build.xml@ 27848

Last change on this file since 27848 was 27848, checked in by davidb, 11 years ago

solr-ext now part of the 'prepare' sequence. In other work (outside of this file) the devel.bash file to the gnome-lib extension is now automatically source (in gs2build/common-src/packages/configure) if the extension is detected on the file system. This means it is no longer necessary to print out the reminder (in thfile) about sourcing devel.bash

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