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

Last change on this file since 27849 was 27849, checked in by davidb, 8 years ago

Need slightly different <exec> commands for Windows and Unix

File size: 124.4 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.bat" os="${os.windows}" dir="${solr-ext.home}" spawn="false">
1053 <arg value="add-service"/>
1054 </exec>
1055 <exec executable="ant" os="${os.unix}" dir="${solr-ext.home}" spawn="false">
1056 <arg value="add-service"/>
1057 </exec>
1058 <antcall target="solr-jdbm-demo-install"/>
1059 </target>
1060
1061 <target name="solr-jdbm-demo-prepare" if="collect.dir">
1062 <property name="solr-jdbm-demo.dir" value="${collect.dir}/solr-jdbm-demo"/>
1063 <available file="${solr-jdbm-demo.dir}/${index.zip}" property="solr-jdbm-demo.present"/>
1064 </target>
1065
1066 <target name="solr-jdbm-demo-install" if="solr-jdbm-demo.present" depends="solr-jdbm-demo-prepare">
1067 <unzip dest="${solr-jdbm-demo.dir}" src="${solr-jdbm-demo.dir}/${index.zip}"/>
1068 <echo>collection solr-jdbm-demo installed</echo>
1069 </target>
1070
1071
1072 <target name="set-perl-shebangs" depends="perl-for-building">
1073 <if>
1074 <bool>
1075 <and><isset property="perl.path"/>
1076 <not><equals arg1="${perl.path}" arg2=""/></not>
1077 </and>
1078 </bool>
1079
1080 <if><bool><istrue value="${current.os.iswindows}"/></bool>
1081 <property name="perl.exec" value="${perl.path}perl.exe"/>
1082 <else>
1083 <property name="perl.exec" value="${perl.path}perl"/>
1084 </else>
1085 </if>
1086
1087 <!--<echo>**** PERLPATH: ${perl.path}</echo>-->
1088 <echo>**** Setting perl shebangs to Perl Exec: ${perl.exec}</echo>
1089
1090 <!-- set the shebangs in the cgi files to point to the correct perlpath -->
1091 <if>
1092 <bool><not><equals arg1="${web.home}" arg2="${web.writablehome}"></equals></not></bool>
1093 <mkdir dir="${web.writablehome}"/>
1094 <copy file="${web.home}/WEB-INF/cgi/gliserver.pl" tofile="${web.writablehome}/WEB-INF/cgi/gliserver.pl" overwrite="true"/>
1095 <copy file="${web.home}/WEB-INF/cgi/metadata-server.pl" tofile="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" overwrite="true"/>
1096 <copy file="${web.home}/WEB-INF/cgi/checksum.pl" tofile="${web.writablehome}/WEB-INF/cgi/checksum.pl" overwrite="true"/>
1097 </if>
1098
1099 <rsr file="${web.writablehome}/WEB-INF/cgi/gliserver.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1100 <rsr file="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1101 <rsr file="${web.writablehome}/WEB-INF/cgi/checksum.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1102 <else>
1103 <echo>WARNING: perl.path is empty. Unable to set the shebangs in the perl files in ${web.writablehome}/WEB-INF/cgi</echo>
1104 </else>
1105 </if>
1106 </target>
1107
1108 <target name="configure-web" depends="init,perl-for-building"
1109 description="Configure only the web app config files">
1110 <!-- we want a unix path in the global.properties file -->
1111 <pathconvert targetos="unix" property="src.gsdl3.home.unix">
1112 <path path="${web.home}"/>
1113 </pathconvert>
1114 <pathconvert targetos="unix" property="src.gsdl3.writablehome.unix">
1115 <path path="${web.writablehome}"/>
1116 </pathconvert>
1117
1118 <antcall target="set-perl-shebangs" inheritAll="true" />
1119
1120 <filter token="gsdlhome" value="${gs2build.home}"/>
1121 <filter token="gsdl3srchome" value="${basedir}"/>
1122 <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
1123 <filter token="gsdl3writablehome" value="${src.gsdl3.writablehome.unix}"/>
1124 <filter token="gsdl3version" value="${app.version}"/>
1125 <filter token="tomcat.server" value="${tomcat.server}"/>
1126 <filter token="tomcat.port" value="${tomcat.port}"/>
1127 <filter token="perlpath" value="${escaped.perl.path}"/>
1128 <filter token="disable.collection.building" value="${disable.collection.building}"/>
1129 <copy file="${web.home}/WEB-INF/cgi/gsdl3site.cfg.in" tofile="${web.writablehome}/WEB-INF/cgi/gsdl3site.cfg" filtering="true" overwrite="true"/>
1130
1131 <copy file="${basedir}/resources/java/global.properties.in" tofile="${web.writableclasses}/global.properties" filtering="true" overwrite="true"/>
1132 <copy file="${basedir}/resources/java/log4j.properties.in" tofile="${web.writableclasses}/log4j.properties" filtering="true" overwrite="true"/>
1133 <if><bool><istrue value="${gsdl3home.isreadonly}"/></bool>
1134 <!-- uncomment the writablehome properties -->
1135 <rsr file="${web.writableclasses}/global.properties" pattern="^#gsdl3\.(writable{1})?home" replacement="gsdl3.$1home" />
1136 </if>
1137 <chmod file="${web.writableclasses}/global.properties" perm="644"/>
1138 <chmod file="${web.writableclasses}/log4j.properties" perm="644"/>
1139 </target>
1140
1141 <target name="compile-web" depends="init">
1142 <javac srcdir="${web.classes}"
1143 destdir="${web.classes}"
1144 debug="${compile.debug}"
1145 deprecation="${compile.deprecation}"
1146 optimize="${compile.optimize}">
1147 <classpath><path refid="compile.classpath"/></classpath>
1148 </javac>
1149 </target>
1150
1151 <target name="compile-classpath-jars" depends="init">
1152 <if><bool><available file="admin/cp.mf"/></bool>
1153 <jar destfile="admin/cp.jar" manifest="admin/cp.mf"/>
1154 </if>
1155 <if><bool><available file="${lib.java}/cp.mf"/></bool>
1156 <jar destfile="${lib.java}/cp.jar" manifest="${lib.java}/cp.mf"/>
1157 </if>
1158 <if><bool><available file="${lib.jni}/cp.mf"/></bool>
1159 <jar destfile="${lib.jni}/cp.jar" manifest="${lib.jni}/cp.mf"/>
1160 </if>
1161 <if><bool><available file="${web.lib}/cp.mf"/></bool>
1162 <jar destfile="${web.lib}/cp.jar" manifest="${web.lib}/cp.mf"/>
1163 </if>
1164 <jar destfile="cp.jar">
1165 <manifest>
1166 <attribute name="Class-Path" value="server.jar admin/cp.jar lib/java/cp.jar lib/jni/cp.jar web/WEB-INF/lib/cp.jar"/>
1167 </manifest>
1168 </jar>
1169 </target>
1170
1171 <target name="clean-classpath-jars" depends="init">
1172 <delete file="admin/cp.jar"/>
1173 <delete file="${lib.java}/cp.jar"/>
1174 <delete file="${lib.jni}/cp.jar"/>
1175 <delete file="${web.lib}/cp.jar"/>
1176 <delete file="cp.jar"/>
1177 </target>
1178
1179
1180 <target name="svnupdate-web" unless="nosvn.mode">
1181 <exec executable="svn">
1182 <arg value="update"/>
1183 <arg value="${web.writablehome}"/>
1184 <arg value="-r"/><arg value="${branch.revision}"/>
1185 </exec>
1186 </target>
1187
1188 <target name="update-web" depends="init,svnupdate-web,configure-web"
1189 description="update only the web stuff (config files)"/>
1190
1191 <!-- ======================= Tomcat Targets ========================== -->
1192
1193 <!-- this target downloads and installs Tomcat -->
1194 <!-- we download tomcat (version 7 for Java 1.5 and later, version 5 for Java 1.4 plus the 1.4 compatibility package). -->
1195 <target name="prepare-tomcat" depends="init,setup-proxy" if="tomcat.islocal"
1196 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">
1197 <if>
1198 <bool>
1199 <not><available file="${packages.home}/tomcat/.flagfile"/></not>
1200 </bool>
1201
1202 <!-- check that packages dir is there -->
1203 <mkdir dir="${packages.home}"/>
1204 <get src="http://www.greenstone.org/gs3files/${tomcat.version}.zip"
1205 dest="${packages.home}/${tomcat.version}.zip"
1206 usetimestamp="true"/>
1207 <unzip src="${packages.home}/${tomcat.version}.zip"
1208 dest="${packages.home}"/>
1209
1210 <!-- If we are using Java 1.4, we'd be using tomcat 5.5 in which case
1211 we would need to have the tomcat compat package to work with Java 1.4-->
1212 <if>
1213 <bool><equals arg1="1.4" arg2="${ant.java.version}"/></bool>
1214 <get src="http://www.greenstone.org/gs3files/${tomcat.version}-compat.zip"
1215 dest="${packages.home}/${tomcat.version}-compat.zip"
1216 usetimestamp="true"/>
1217 <unzip src="${packages.home}/${tomcat.version}-compat.zip"
1218 dest="${packages.home}"/>
1219 </if>
1220
1221 <!-- delete any existing tomcat -->
1222 <delete dir="${packages.home}/tomcat"/>
1223 <move todir="${packages.home}/tomcat">
1224 <fileset dir="${packages.home}/${tomcat.version}"/>
1225 </move>
1226 <!--
1227 <copy file="${basedir}/resources/tomcat/setclasspath.bat"
1228 tofile="${packages.home}/tomcat/bin/setclasspath.bat"
1229 overwrite="true"/>
1230 <copy file="${basedir}/resources/tomcat/setclasspath.sh"
1231 tofile="${packages.home}/tomcat/bin/setclasspath.sh"
1232 overwrite="true"/>
1233 -->
1234 <!-- make sure we have execute permission for the .sh files -->
1235 <chmod dir="${packages.home}/tomcat/bin" perm="ugo+rx"
1236 includes="*.sh"/>
1237
1238 <echo file="${packages.home}/tomcat/.flagfile">
1239 the timestamp of this file is the time that tomcat was extracted from the zip files.
1240 it is used to figure out whether the files need to be refreshed or not in `ant prepare-tomcat`
1241 </echo>
1242
1243 <!-- this is not strictly a prepare tomcat thing, but if one changes
1244 Java, then they need to change tomcat as well, so might as well call
1245 it here -->
1246 <antcall target="configure-java-version"/>
1247 <else>
1248 <echo>Tomcat has been prepared, will not prepare</echo>
1249 <echo>Delete ${packages.home}/tomcat/.flagfile to force refresh</echo>
1250 </else>
1251
1252 </if>
1253
1254 </target>
1255
1256 <target name="configure-tomcat" depends="init,configure-tomcat-local,configure-tomcat-external"/>
1257
1258 <target name="configure-tomcat-local" depends="init,perl-for-building" if="tomcat.islocal">
1259 <!-- re-setup the server.xml file -->
1260 <copy file="${basedir}/resources/tomcat/server_tomcat${tomcat.version.major}.xml"
1261 tofile="${packages.home}/tomcat/conf/server.xml" overwrite="true">
1262 <filterset>
1263 <filter token="port" value="${tomcat.port}"/>
1264 <filter token="shutdown-port" value="${tomcat.shutdown.port}"/>
1265 </filterset>
1266 </copy>
1267 <!-- set up the greenstone3 context -->
1268 <copy file="${basedir}/resources/tomcat/greenstone3.xml" tofile="${packages.home}/tomcat/conf/Catalina/localhost/greenstone3.xml" overwrite="true">
1269 <filterset>
1270 <filter token="gsdl3webhome" value="${web.home}"/>
1271 <filter token="gsdl3webwritablehome" value="${web.writablehome}"/>
1272 <filter token="privilegedattribute" value ="${privileged.attribute}"/>
1273 </filterset>
1274 </copy>
1275
1276 <!-- set up the greenstone3 web.xml file -->
1277 <copy file="${basedir}/resources/tomcat/web.xml" tofile="${packages.home}/tomcat/conf/web.xml" overwrite="true">
1278 <filterset>
1279 <filter token="perlpath" value="${perl.path}"/>
1280 </filterset>
1281 </copy>
1282 </target>
1283
1284 <target name="configure-tomcat-external" depends="init" unless="tomcat.islocal">
1285 <!-- re-setup the server.xml file -->
1286 <!-- need to edit the config file, or do we get the user to do this???-->
1287 </target>
1288
1289
1290 <!-- This target runs tomcat's "bin/catalina.bat(.sh) jpda start"
1291 to allow debugging the running GS3 server in Eclipse. See the instructions at
1292 http://www.wikijava.org/wiki/Debugging_a_servlet_with_tomcat_and_Eclipse_tutorial
1293 on how to use this with eclipse
1294 -->
1295 <target name="debug-start-tomcat" description="Startup Tomcat for debugger" depends="init" if="tomcat.islocal">
1296 <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
1297 <property name="tomcat.path" refid="local.tomcat.path"/>
1298
1299 <if><bool>
1300 <isset property="fedora.maxpermsize"/></bool>
1301 <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx400M ${fedora.maxpermsize}"/>
1302 <else>
1303 <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx400M"/>
1304 </else>
1305 </if>
1306
1307 <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
1308 <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
1309
1310 <exec executable="${catalina.home}/bin/catalina.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
1311 <arg value="jpda" />
1312 <arg value="start" />
1313 <env key="JPDA_ADDRESS" value="8000"/> <!-- for debugging Tomcat in Eclipse -->
1314 <env key="JPDA_TRANSPORT" value="dt_socket"/> <!-- for debugging Tomcat in Eclipse -->
1315 <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
1316 <env key="PATH" path="${tomcat.path}"/>
1317 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1318 <env key="CATALINA_HOME" value="${catalina.home}"/>
1319 <env key="CLASSPATH" path="${tomcat.classpath}"/>
1320 <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
1321 <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
1322 <env key="WNHOME" path="${wn.home}"/>
1323 <env key="FEDORA_HOME" path="${fedora.home}"/>
1324 </exec>
1325 <exec executable="${catalina.home}/bin/catalina.bat" os="${os.windows}" dir="${catalina.home}/bin" spawn="true">
1326 <arg value="jpda" />
1327 <arg value="start" />
1328 <env key="JPDA_ADDRESS" value="8000"/> <!-- for debugging Tomcat in Eclipse -->
1329 <env key="JPDA_TRANSPORT" value="dt_socket"/> <!-- for debugging Tomcat in Eclipse -->
1330 <env key="GSDLOS" value="windows"/>
1331 <env key="GSDL3HOME" value="${basedir}"/>
1332 <env key="Path" path="${tomcat.path}"/>
1333 <env key="PATH" path="${tomcat.path}"/>
1334 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1335 <env key="CATALINA_HOME" value="${catalina.home}"/>
1336 <env key="CLASSPATH" path="${tomcat.classpath}"/>
1337 <env key="FEDORA_HOME" path="${fedora.home}"/>
1338 </exec>
1339 <!-- wait for the server to startup in case other targets need it running -->
1340 <waitfor maxwait="5" maxwaitunit="second">
1341 <and>
1342 <socket server="${tomcat.server}" port="${tomcat.port}"/>
1343 <http url="http://${tomcat.server}:${tomcat.port}${app.path}/index.html"/>
1344 </and>
1345 </waitfor>
1346 </target>
1347
1348
1349 <!-- Another way: http://ptrthomas.wordpress.com/2006/03/25/how-to-start-and-stop-tomcat-from-ant/ -->
1350 <target name="start-tomcat" description="Startup only Tomcat" depends="init" if="tomcat.islocal">
1351 <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
1352 <property name="tomcat.path" refid="local.tomcat.path"/>
1353
1354 <if><bool>
1355 <isset property="fedora.maxpermsize"/></bool>
1356 <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx400M ${fedora.maxpermsize}"/>
1357 <else>
1358 <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx400M"/>
1359 </else>
1360 </if>
1361
1362 <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
1363 <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
1364
1365 <exec executable="${catalina.home}/bin/startup.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
1366 <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
1367 <env key="GSDL3HOME" value="${basedir}"/>
1368 <env key="PATH" path="${tomcat.path}"/>
1369 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1370 <env key="CATALINA_HOME" value="${catalina.home}"/>
1371 <env key="CLASSPATH" path="${tomcat.classpath}"/>
1372 <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
1373 <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
1374 <env key="WNHOME" path="${wn.home}"/>
1375 <env key="FEDORA_HOME" path="${fedora.home}"/>
1376 </exec>
1377 <exec executable="${catalina.home}/bin/startup.bat" os="${os.windows}" dir="${catalina.home}/bin" spawn="true">
1378 <env key="GSDLOS" value="windows"/>
1379 <env key="GSDL3HOME" value="${basedir}"/>
1380 <env key="Path" path="${tomcat.path}"/>
1381 <env key="PATH" path="${tomcat.path}"/>
1382 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1383 <env key="CATALINA_HOME" value="${catalina.home}"/>
1384 <env key="CLASSPATH" path="${tomcat.classpath}"/>
1385 <env key="FEDORA_HOME" path="${fedora.home}"/>
1386 </exec>
1387 <!-- wait for the server to startup in case other targets need it running -->
1388 <waitfor maxwait="5" maxwaitunit="second">
1389 <and>
1390 <socket server="${tomcat.server}" port="${tomcat.port}"/>
1391 <http url="http://${tomcat.server}:${tomcat.port}${app.path}/index.html"/>
1392 </and>
1393 </waitfor>
1394 </target>
1395
1396 <!--ant task http: http://www.jajakarta.org/ant/ant-1.6.1/docs/ja/manual/api/org/apache/tools/ant/taskdefs/condition/Http.html-->
1397 <target name="reconfigure" description="Reconfigure the message router">
1398 <waitfor maxwait="5" maxwaitunit="second">
1399 <http url="http://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c"/>
1400 </waitfor>
1401 </target>
1402
1403 <!--Command-line args to Ant: http://www.jguru.com/faq/view.jsp?EID=471794-->
1404 <target name="reconfigure-collection" description="Reconfigure the collection">
1405 <waitfor maxwait="5" maxwaitunit="second">
1406 <http url="http://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c&amp;sc=${collection}"/>
1407 </waitfor>
1408 </target>
1409
1410 <!-- windows: do we want to launch a webrowser?? -->
1411 <!-- shouldn't this test whether anything is running first?
1412 It's safer to always attempt to stop tomcat: that way we won't be dependent on the right time
1413 to check whether the server is stopped or still running before attempting to start again.
1414 This target, which was recently called force-stop-tomcat for a while but is back to being
1415 called stop-tomcat, now hides the Java exception output that appears whenever tomcat is already
1416 stopped as happens when stop-tomcat is called consecutively. -->
1417 <target name="force-stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal">
1418 <exec executable="${catalina.home}/bin/shutdown.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
1419 <env key="FEDORA_HOME" path="${fedora.home}"/>
1420 <env key="CATALINA_HOME" value="${catalina.home}"/>
1421 <arg line=">/dev/null 2>&amp;1"/>
1422 </exec>
1423 <exec executable="${catalina.home}/bin/shutdown.bat" os="${os.windows}" dir="${catalina.home}/bin" spawn="false">
1424 <env key="FEDORA_HOME" path="${fedora.home}"/>
1425 <env key="CATALINA_HOME" value="${catalina.home}"/>
1426 <arg line=">nul 2>&amp;1"/>
1427 </exec>
1428 </target>
1429
1430 <!-- Can also try the "socket" condition in place of the "http" condition
1431 And also use a <waitfor> in place of <condition>, such as:
1432 <waitfor maxwait="5" maxwaitunit="second" timeoutproperty="tomcat.isstopped"><http url="..."/></waitfor>
1433 The http URL resolves to host:port/greenstone3
1434 Condition uses <http/> rather than <socket/> for testing, since if the server was stopped, the socket
1435 might still be in use for some moments. We test the URL with the http condition since it's likelier to
1436 fail sooner if the server has indeed been stopped. -->
1437 <target name="check-tomcat-running">
1438 <condition property="tomcat.isrunning">
1439 <!--<http url="http://${tomcat.server}:${tomcat.port}${app.path}"/>-->
1440 <http url="http://${tomcat.server}:${tomcat.port}"/>
1441 </condition>
1442 </target>
1443
1444 <!-- stop-tomcat checks if the tomcat server is already running. If it appears to be running
1445 (regardless of whether tomcat was just starting to shut down), this target calls force-stop-tomcat
1446 to issue the shutdown command to tomcat. Then it waits for at most 15 seconds for the server to
1447 actually stop by checking the socket at which tomcat listens every second, printing a warning
1448 at the end of the max wait time of 15 seconds if tomcat was still running. -->
1449 <target name="stop-tomcat" description="Shutdown only Tomcat if running" depends="check-tomcat-running" if="tomcat.isrunning">
1450 <antcall target="force-stop-tomcat"/>
1451
1452 <property name="wait.numchecks" value="15"/>
1453 <echo>Waiting for the server to shutdown... (${wait.numchecks} seconds max)</echo>
1454 <waitfor maxwait="${wait.numchecks}" maxwaitunit="second" checkevery="1" checkeveryunit="second" timeoutproperty="tomcat.timedout">
1455 <not><socket server="${tomcat.server}" port="${tomcat.port}"/></not>
1456 </waitfor>
1457
1458 <if>
1459 <bool>
1460 <isset property="${tomcat.timedout}"/>
1461 </bool>
1462 <property name="tomcat.isrunning" value="true"/>
1463 <echo>WARNING: Checked the socket ${wait.numchecks} times, but port ${tomcat.port} is still busy.</echo>
1464 <else>
1465 <echo>Tomcat is stopped.</echo>
1466 <property name="tomcat.isrunning" value="false"/>
1467 </else>
1468 </if>
1469 </target>
1470
1471 <target name="restart-tomcat" description="Shutdown and restart only Tomcat" depends="init,stop-tomcat,start-tomcat"/>
1472
1473 <target name="setup-catalina-ant-tasks">
1474 <!-- Configure the custom Ant tasks for the Tomcat Manager application -->
1475 <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"
1476 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1477 <taskdef name="list" classname="org.apache.catalina.ant.ListTask"
1478 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1479 <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"
1480 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1481 <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"
1482 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1483 <taskdef name="roles" classname="org.apache.catalina.ant.RolesTask"
1484 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1485 <taskdef name="start" classname="org.apache.catalina.ant.StartTask"
1486 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1487 <taskdef name="stop" classname="org.apache.catalina.ant.StopTask"
1488 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1489 <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"
1490 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1491 </target>
1492
1493 <!-- http://blog.andrewbeacock.com/2007/11/how-to-truncate-log-file-using-ubuntu.html
1494 Doing "cat </dev/null > packages/tomcat/logs/catalina.out" doesn't work as an ant target.
1495 It seems to have a problem with cat or </dev/null, with or without the < sign. -->
1496 <target name="reset-logs" description="Empties catalina.out, greenstone.log and contents of web/logs/tmp">
1497 <echo>Truncating catalina.out, greenstone.log and server.log, and emptying ${web.writablehome}/logs/tmp</echo>
1498 <exec executable="rm" os="${os.unix}" dir="${catalina.home}/logs" spawn="false">
1499 <arg value="-f"/>
1500 <arg value="catalina.out"/>
1501 </exec>
1502 <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
1503 <arg value="-f"/>
1504 <arg value="greenstone.log"/>
1505 </exec>
1506 <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
1507 <arg value="-f"/>
1508 <arg value="server.log"/>
1509 </exec>
1510
1511 <exec executable="touch" os="${os.unix}" dir="${catalina.home}/logs"
1512 spawn="false">
1513 <arg value="catalina.out"/>
1514 </exec>
1515 <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
1516 spawn="false">
1517 <arg value="greenstone.log"/>
1518 </exec>
1519 <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
1520 spawn="false">
1521 <arg value="server.log"/>
1522 </exec>
1523
1524 <exec executable="cmd" os="${os.windows}" dir="${catalina.home}/logs" spawn="false">
1525 <arg line="/c echo. > catalina.out"/>
1526 </exec>
1527 <exec executable="cmd" os="${os.windows}" dir="${web.writablehome}/logs" spawn="false">
1528 <arg line="/c echo. > greenstone.log"/>
1529 </exec>
1530 <exec executable="cmd" os="${os.windows}" dir="${web.writablehome}/logs" spawn="false">
1531 <arg line="/c echo. > server.log"/>
1532 </exec>
1533
1534 <if>
1535 <bool><available file="${web.writablehome}/logs/tmp" type="dir"/></bool>
1536 <delete>
1537 <fileset dir="${web.writablehome}/logs/tmp" includes="**/*"/>
1538 </delete>
1539 </if>
1540 </target>
1541
1542 <!-- ======================= ant Targets ============================ -->
1543 <target name="prepare-ant" depends="init">
1544 <if>
1545 <bool>
1546 <not><available file="${packages.home}/ant/.flagfile"/></not>
1547 </bool>
1548
1549 <get src="http://www.greenstone.org/gs3files/apache-ant-1.7.0-bin.zip"
1550 dest="${packages.home}/apache-ant-1.7.0-bin.zip"
1551 usetimestamp="true"/>
1552 <unzip src="${packages.home}/apache-ant-1.7.0-bin.zip"
1553 dest="${packages.home}"/>
1554 <move todir="${packages.home}/ant">
1555 <fileset dir="${packages.home}/apache-ant-1.7.0"/>
1556 </move>
1557 <echo file="${packages.home}/ant/.flagfile">
1558 the timestamp of this file is the time that ant was extracted from the zip files.
1559 it is used to figure out whether the files need to be refreshed or not in `ant prepare-ant`
1560 </echo>
1561
1562 <else>
1563 <echo>Ant has been prepared, will not prepare</echo>
1564 <echo>Delete ${packages.home}/ant/.flagfile to force refresh</echo>
1565 </else>
1566
1567 </if>
1568 </target>
1569
1570 <!-- ======================= Admin Targets ============================ -->
1571
1572 <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
1573 See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
1574 But you can do: echo mypassword | ant config-admin -->
1575 <target name="config-admin" description="Reset admin password">
1576 <input addproperty="admin.password" defaultvalue="admin" message="New admin password (3-8 characters):&gt;">
1577 <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
1578 </input>
1579 <!--<echo>PWD: ${admin.password}</echo>-->
1580 <antcall target="update-userdb">
1581 <param name="user.username" value="admin"/>
1582 <param name="user.password" value="${admin.password}"/>
1583 <param name="user.groups" value=""/>
1584 <param name="user.status" value=""/>
1585 <param name="user.comment" value="Password updated."/>
1586 <param name="user.email" value=""/>
1587 </antcall>
1588 </target>
1589
1590 <target name="config-user" description="Add or modify users" depends="get-user-data,update-userdb"/>
1591
1592 <target name="get-user-data" description="Get user details">
1593 <input addproperty="user.username" message="Username:&gt;"/>
1594 <input addproperty="user.password" defaultvalue="" message="Password (3-8 characters):&gt;">
1595 <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
1596 </input>
1597 <input addproperty="user.groups" defaultvalue="" message="Groups (comma-separated list):&gt;"/>
1598 <input addproperty="user.status" defaultvalue="true" message="Enabled (true/false):&gt;"/>
1599 <input addproperty="user.comment" defaultvalue="" message="Comment:&gt;"/>
1600 <input addproperty="user.email" defaultvalue="" message="Email:&gt;"/>
1601 </target>
1602
1603<!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
1604 See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
1605 But you can do: echo mypassword | ant config-admin -->
1606 <target name="update-userdb" description="Add or modify users" depends="check-tomcat-running">
1607
1608 <!-- stop tomcat if running, since derby db is embedded and only allows connections from one jvm instance at a time
1609 See http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html
1610 The ${tomcat.isrunning} property is set by the depends-target "check-tomcat-running" -->
1611 <if>
1612 <bool>
1613 <istrue value="${tomcat.isrunning}"/>
1614 </bool>
1615 <antcall target="stop-tomcat"/>
1616 </if>
1617
1618 <!--<echo>${admin.password}</echo>--> <!-- for testing -->
1619 <java classname="org.greenstone.gsdl3.util.ModifyUsersDB">
1620 <classpath refid="compile.classpath"/> <!--for ${web.lib}/gsdl3.jar and supporting files-->
1621 <arg file="${web.home}/sites/localsite/etc/usersDB"/>
1622 <arg value="${user.username}"/>
1623 <arg value="password=${user.password}"/>
1624 <arg value="groups=${user.groups}"/>
1625 <arg value="status=${user.status}"/>
1626 <arg value="comment=${user.comment}"/>
1627 <arg value="email=${user.email}"/>
1628 </java>
1629
1630 <!-- run tomcat again if it used to be running -->
1631 <if>
1632 <bool>
1633 <istrue value="${tomcat.isrunning}"/>
1634 </bool>
1635 <antcall target="start-tomcat"/>
1636 </if>
1637 </target>
1638
1639
1640 <!-- ======================= Axis Targets ============================ -->
1641
1642 <target name="prepare-axis" depends="init">
1643
1644 <if>
1645 <bool>
1646 <not><available file="${packages.home}/axis/.flagfile"/></not>
1647 </bool>
1648
1649 <get src="http://www.greenstone.org/gs3files/${axis.zip.version}"
1650 dest="${packages.home}/${axis.zip.version}"
1651 usetimestamp="true"/>
1652 <unzip src="${packages.home}/${axis.zip.version}"
1653 dest="${packages.home}"/>
1654 <move todir="${packages.home}/axis">
1655 <fileset dir="${packages.home}/${axis.dir.version}"/>
1656 </move>
1657 <!-- install axis into greenstone web app -->
1658 <copy todir="${web.lib}">
1659 <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/lib">
1660 <include name="*.jar"/>
1661 </fileset>
1662 </copy>
1663 <copy todir="${web.home}">
1664 <fileset dir="${packages.home}/axis/webapps/axis/">
1665 <include name="*.jsp"/>
1666 <include name="*.jws"/>
1667 </fileset>
1668 </copy>
1669 <copy tofile="${web.home}/axis.html" file="${packages.home}/axis/webapps/axis/index.html"/>
1670 <copy todir="${web.classes}">
1671 <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/classes">
1672 <include name="*.properties"/>
1673 </fileset>
1674 </copy>
1675 <echo file="${packages.home}/axis/.flagfile">
1676 the timestamp of this file is the time that axis was extracted from the zip files.
1677 it is used to figure out whether the files need to be refreshed or not in `ant prepare-axis`
1678 </echo>
1679
1680 <else>
1681 <echo>Axis has been prepared, will not prepare</echo>
1682 <echo>Delete ${packages.home}/axis/.flagfile to force refresh</echo>
1683 </else>
1684
1685 </if>
1686 </target>
1687
1688 <target name="soap-deploy-site" depends="init,get-sitename,get-siteuri,get-webservices,create-deployment-files,deploy-site"
1689 description="Deploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work."/>
1690
1691 <target name="deploy-site">
1692 <java classname="org.apache.axis.client.AdminClient">
1693 <classpath refid="compile.classpath"/>
1694 <arg value="-l"/>
1695 <arg value="http://${tomcat.server}:${tomcat.port}${app.path}/servlet/AxisServlet"/>
1696 <arg file="${basedir}/resources/soap/deploy.wsdd"/>
1697 </java>
1698 <delete file="${basedir}/resources/soap/deploy.wsdd"/> <!--clean up, no longer used-->
1699 </target>
1700
1701 <target name="soap-undeploy-site" depends="get-undeploy-service-name"
1702 description="Undeploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work.">
1703 <filter token="servicesname" value="${axis.undeploy.servicename}"/>
1704 <copy file="${basedir}/resources/soap/undeploy-site.wsdd.template"
1705 tofile="${basedir}/resources/soap/undeploy.wsdd"
1706 filtering="true"
1707 overwrite="true"/>
1708 <java classname="org.apache.axis.client.AdminClient">
1709 <classpath refid="compile.classpath"/>
1710 <arg value="-l"/>
1711 <arg value="http://${tomcat.server}:${tomcat.port}${app.path}/servlet/AxisServlet"/>
1712 <arg file="${basedir}/resources/soap/undeploy.wsdd"/>
1713 </java>
1714 <delete file="${basedir}/resources/soap/undeploy.wsdd"/> <!--clean up, no longer used-->
1715 </target>
1716
1717 <!-- this target used to deploy the default web service SOAPServer (base.webservice.name) on the localsite server
1718 with the default servicename of localsite-->
1719 <target name="deploy-localsite" depends="init"
1720 description="Deploy the SOAP server for localsite. Will start and stop Tomcat.">
1721 <antcall target="start-tomcat"/>
1722 <echo>Deploying ${base.webservice.name} web services for localsite under service name: localsite</echo>
1723 <antcall target="create-deployment-files">
1724 <param name="axis.sitename" value="localsite"/>
1725 <param name="axis.servicesname" value="${base.webservice.name}"/>
1726 <param name="axis.siteuri" value="localsite"/>
1727 </antcall>
1728 <antcall target="deploy-site">
1729 <param name="axis.sitename" value="localsite"/>
1730 <param name="axis.servicesname" value="${base.webservice.name}"/>
1731 <param name="axis.siteuri" value="localsite"/>
1732 </antcall>
1733 <echo>The Greenstone server has been started up. If you do not want it running, please type: ant stop.</echo>
1734 </target>
1735
1736 <target name="get-sitename" unless="axis.sitename">
1737 <input addproperty="axis.sitename" defaultvalue="localsite">What site do you want to deploy services for?
1738Press Enter for default:localsite</input>
1739 </target>
1740
1741 <target name="get-undeploy-service-name" unless="axis.undeploy.servicename">
1742 <input addproperty="axis.undeploy.servicename" defaultvalue="localsite">Please enter the full name of the service you wish to undeploy.
1743To find out which web services you've got deployed, point your browser to http://HOST:PORT/greenstone3/services
1744Or press Enter for undeploying the default:localsite /&gt;</input>
1745 <echo>Name of service to undeploy: ${axis.undeploy.servicename}</echo>
1746 </target>
1747
1748 <target name="get-webservices" unless="axis.servicesname">
1749 <input addproperty="axis.servicesname" defaultvalue="${base.webservice.name}">Which set of web services do you want to deploy?
1750Choose from: ${web.services.list}
1751Or press Enter for default:${base.webservice.name} /&gt;</input>
1752 <echo>${axis.servicesname}</echo>
1753 </target>
1754
1755 <target name="get-siteuri" depends="get-sitename,get-webservices" unless="axis.siteuri">
1756 <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>
1757 <echo>Site: ${axis.sitename}, services: ${axis.servicesname}, servicesname: ${axis.siteuri}</echo>
1758 </target>
1759
1760 <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">
1761 <condition property="soap.method" value="provider='java:MSG' style='message' use='literal'">
1762 <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
1763 </condition>
1764
1765 <!--everything else defaults to java:RPC at present-->
1766 <condition property="soap.method" value="provider='java:RPC'">
1767 <not>
1768 <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
1769 </not>
1770 </condition>
1771 </target>
1772
1773 <target name="create-deployment-files" depends="set-soapmethod" if="axis.sitename">
1774 <filter token="sitename" value="${axis.sitename}"/>
1775 <filter token="siteuri" value="${axis.siteuri}"/>
1776 <filter token="servicesname" value="${axis.servicesname}"/>
1777 <filter token="soapmethod" value="${soap.method}"/>
1778 <copy file="${basedir}/resources/soap/site.wsdd.template"
1779 tofile="${basedir}/resources/soap/deploy.wsdd"
1780 filtering="true"
1781 overwrite="true"/>
1782 <!-- create the java files and compile them -->
1783 <copy file="${basedir}/resources/java/${axis.servicesname}.java.in"
1784 tofile="${src.gsdl3.home}/${axis.servicesname}${axis.sitename}.java"
1785 filtering="true"
1786 overwrite="true"/>
1787 <mkdir dir="${build.home}"/>
1788 <javac srcdir="${src.home}"
1789 destdir="${build.home}"
1790 debug="${compile.debug}"
1791 deprecation="${compile.deprecation}"
1792 optimize="${compile.optimize}">
1793 <classpath refid="compile.classpath"/>
1794 <include name="org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.java" />
1795 </javac>
1796 <mkdir dir="${web.classes}/org/greenstone/gsdl3"/>
1797 <copy file="${build.home}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
1798 tofile="${web.classes}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
1799 overwrite="true" />
1800 </target>
1801
1802
1803 <!-- ====================== Core targets ============================== -->
1804 <!-- core targets refer to the core gsdl3 java src -->
1805
1806 <target name="prepare-core"/>
1807
1808 <target name="configure-core"/>
1809
1810 <target name="update-core" depends="init,svnupdate-core,clean-core,compile-core"
1811 description="Update only the Greenstone core" />
1812
1813 <target name="svnupdate-core" unless="nosvn.mode">
1814 <exec executable="svn">
1815 <arg value="update"/>
1816 <arg value="${basedir}"/>
1817 <arg value="-r"/><arg value="${branch.revision}"/>
1818 </exec>
1819 </target>
1820
1821 <target name="clean-core"
1822 description="Clean only the Greenstone core">
1823 <!-- should this delete the gsdl3.jar from web/WEB-INF?? -->
1824 <delete dir="${build.home}"/>
1825 </target>
1826
1827 <target name="compile-core" depends="init"
1828 description="Compile only the Greenstone core">
1829 <mkdir dir="${build.home}"/>
1830
1831 <if><bool><isset property="with.jni"/></bool>
1832 <javac srcdir="${src.home}"
1833 destdir="${build.home}"
1834 debug="${compile.debug}"
1835 deprecation="${compile.deprecation}"
1836 optimize="${compile.optimize}">
1837 <classpath>
1838 <path refid="compile.classpath"/>
1839 </classpath>
1840 </javac>
1841 <else>
1842 <property name="gsprefix" value=""/>
1843 <javac srcdir="${src.home}"
1844 destdir="${build.home}"
1845 debug="${compile.debug}"
1846 deprecation="${compile.deprecation}"
1847 optimize="${compile.optimize}">
1848 <classpath>
1849 <path refid="compile.classpath"/>
1850 </classpath>
1851 <exclude name="org/greenstone/gsdl3/service/GS2MGPPRetrieve.java"/>
1852 <exclude name="org/greenstone/gsdl3/service/GS2MGPPSearch.java"/>
1853 <exclude name="org/greenstone/gsdl3/service/GS2MGSearch.java"/>
1854 <exclude name="org/greenstone/gsdl3/service/GS2MGRetrieve.java"/>
1855 <exclude name="org/greenstone/gsdl3/service/GoogleNgramMGPPSearch.java"/>
1856 <exclude name="org/greenstone/gsdl3/service/PhindPhraseBrowse.java"/>
1857 <exclude name="org/greenstone/gsdl3/util/GDBMWrapper.java"/>
1858 </javac>
1859 </else>
1860 </if>
1861 <jar destfile="${build.home}/gsdl3.jar">
1862 <fileset dir="${build.home}">
1863 <include name="org/greenstone/gsdl3/**"/>
1864 <include name="org/flax/**"/>
1865 <exclude name="**/Test.class"/>
1866 </fileset>
1867 <manifest>
1868 <attribute name="Built-By" value="${user.name}" />
1869 </manifest>
1870 </jar>
1871 <copy file="${build.home}/gsdl3.jar" todir="${web.lib}"/>
1872
1873 <jar destfile="${build.home}/gutil.jar">
1874 <fileset dir="${build.home}">
1875 <include name="org/greenstone/util/**"/>
1876 </fileset>
1877 <manifest>
1878 <attribute name="Built-By" value="${user.name}" />
1879 </manifest>
1880 </jar>
1881 <copy file="${build.home}/gutil.jar" todir="${web.lib}"/>
1882
1883 <!-- copy the localsite server in case we need it -->
1884 <copy file="${build.home}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" tofile="${web.classes}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" />
1885
1886 <!-- Greenstone Administrator Interface -->
1887 <jar destfile="${build.home}/GAI.jar">
1888 <fileset dir="${build.home}">
1889 <include name="org/greenstone/admin/**"/>
1890 </fileset>
1891 <manifest>
1892 <attribute name="Built-By" value="${user.name}" />
1893 </manifest>
1894 </jar>
1895 <copy file="${build.home}/GAI.jar" todir="${web.lib}"/>
1896 <copy file="${build.home}/GAI.jar" todir="${admin.dir}"/>
1897 <jar destfile="${build.home}/phind.jar">
1898 <fileset dir="${build.home}">
1899 <include name="org/greenstone/applet/phind/**"/>
1900 </fileset>
1901 <manifest>
1902 <attribute name="Built-By" value="${user.name}" />
1903 </manifest>
1904 </jar>
1905 <mkdir dir="${web.applet}"/>
1906 <copy file="${build.home}/phind.jar" todir="${web.applet}"/>
1907 <!-- phind also needs xercesImpl.jar and xml-apis.jar to be in web/applet -->
1908 <if>
1909 <bool><istrue value="${tomcat.islocal}"/></bool>
1910 <copy file="${web.lib}/xercesImpl.jar" todir="${web.applet}"/>
1911 <copy file="${web.lib}/xml-apis.jar" todir="${web.applet}"/>
1912 </if>
1913
1914
1915 <!-- skip anttasks for now
1916 <jar destfile="${build.home}/anttasks.jar">
1917 <fileset dir="${build.home}">
1918 <include name="org/greenstone/anttasks/**"/>
1919 </fileset>
1920 <manifest>
1921 <attribute name="Built-By" value="${user.name}" />
1922 </manifest>
1923 </jar>
1924 <copy file="${build.home}/anttasks.jar" todir="${basedir}/lib/java"/>-->
1925 <jar destfile="${build.home}/gsdl3test.jar">
1926 <fileset dir="${build.home}">
1927 <include name="org/greenstone/gsdl3/**/*Test.class"/>
1928 <include name="org/greenstone/testing/**"/>
1929 </fileset>
1930 <manifest>
1931 <attribute name="Built-By" value="${user.name}" />
1932 </manifest>
1933 </jar>
1934 <jar destfile="${build.home}/server.jar">
1935 <fileset dir="${build.home}">
1936 <include name="org/greenstone/server/**"/>
1937 <include name="org/greenstone/util/**"/>
1938 </fileset>
1939 <fileset file="${basedir}/resources/java/server.properties"/>
1940 <manifest>
1941 <attribute name="Built-By" value="${user.name}"/>
1942 </manifest>
1943 </jar>
1944 <copy file="${build.home}/server.jar" todir="${basedir}"/>
1945 </target>
1946
1947 <!-- === Eclipse targets == -->
1948 <target name="setup-for-eclipse">
1949
1950 <filter token="gsdlhome" value="${gs2build.home}"/>
1951 <filter token="gsdl3srchome" value="${basedir}"/>
1952 <filter token="gsdl3home" value="${basedir}/web"/>
1953
1954 <if>
1955 <bool><not><available file="${basedir}/TransformingLibrary.launch"/></not></bool>
1956 <copy file="${basedir}/TransformingLibrary.launch.in" tofile="${basedir}/TransformingLibrary.launch" filtering="true" overwrite="true"/>
1957 </if>
1958<!--
1959 <if>
1960 <bool><not><available file="${basedir}/LibraryCommandline.launch"/></not></bool>
1961 <copy file="${basedir}/LibraryCommandline.launch.in" tofile="${basedir}/LibraryCommandline.launch" filtering="true" overwrite="true"/>
1962 </if>
1963-->
1964 </target>
1965
1966 <!-- ================== Packages targets ================================ -->
1967 <!-- these targets refer to the greenstone source packages - these need
1968 updating less often, so are in separate targets to the core -->
1969 <target name="prepare-packages" depends="init"/>
1970
1971 <target name="update-packages" depends="init,svnupdate-packages,configure-packages,clean-packages,compile-packages"
1972 description="Update only the source packages"/>
1973
1974 <target name="svnupdate-packages" unless="nosvn.mode">
1975 <exec executable="svn">
1976 <arg value="update"/>
1977 <arg value="${src.packages.home}"/>
1978 <arg value="-r"/><arg value="${branch.revision}"/>
1979 </exec>
1980 </target>
1981
1982
1983 <target name="configure-packages" depends="init,configure-javagdbm"
1984 description="Configure only the packages."/>
1985
1986 <target name="configure-javagdbm" if="with.jni">
1987 <echo>
1988 Configuring JavaGDBM
1989 </echo>
1990
1991 <exec executable="${javagdbm.home}/configure" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
1992 <arg value="--prefix=${basedir}"/>
1993 <arg value="--libdir=${lib.jni}"/>
1994 <arg value="--with-gdbm=${gdbm.home}"/>
1995 <arg line="${cross.configure.args}"/>
1996 </exec>
1997 </target>
1998
1999 <target name="clean-packages" depends="init,clean-javagdbm" description="Clean only the packages"/>
2000
2001 <target name="clean-javagdbm" depends="init">
2002 <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
2003 <exec executable="make" os="${os.unix}"
2004 dir="${javagdbm.home}" failonerror="true">
2005 <arg value="clean"/>
2006 </exec>
2007 </if>
2008 </target>
2009
2010 <target name="distclean-packages" depends="init,distclean-javagdbm" description="Distclean only the packages"/>
2011
2012 <target name="distclean-javagdbm" depends="init">
2013 <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
2014 <exec executable="make" os="${os.unix}"
2015 dir="${javagdbm.home}" failonerror="true">
2016 <arg value="distclean"/>
2017 </exec>
2018 </if>
2019 </target>
2020
2021 <target name="compile-packages" description="Compile only the source packages">
2022 <!-- javagdbm -->
2023 <antcall target="compile-javagdbm"/>
2024 <!-- Search4j -->
2025 <antcall target="compile-search4j"/>
2026 </target>
2027
2028 <target name="compile-javagdbm" description="Compile JavaGDBM" if="with.jni">
2029
2030 <!-- unix: -->
2031 <echo>compile javagdbm</echo>
2032 <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true"/>
2033 <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
2034 <arg value="install"/>
2035 </exec>
2036
2037 <!-- windows: Calling without the "compile" argument first will run winMake.bat with
2038 "all" which will then perform both the compile AND link targets in jni/win32.mak
2039 (thereby also generating gdbmjava.dll). Then we run the same command with
2040 the "install" argument to copy the gdbmjava.dll into the correct location. -->
2041 <echo>Windows: compile javagdbm</echo>
2042 <exec executable="${javagdbm.home}/winMake.bat" os="${os.windows}" dir="${javagdbm.home}" failonerror="true">
2043 <env key="GSDL3SRCHOME" path="${basedir}"/>
2044 </exec>
2045 <exec executable="${javagdbm.home}/winMake.bat" os="${os.windows}" dir="${javagdbm.home}" failonerror="true">
2046 <env key="GSDL3SRCHOME" path="${basedir}"/>
2047 <arg value="install"/>
2048 </exec>
2049
2050 <!-- install the jar file -->
2051 <echo>Install the javagdbm jar file ${javagdbm.home}/javagdbm.jar ${lib.jni}</echo>
2052 <copy file="${javagdbm.home}/javagdbm.jar" todir="${lib.jni}"/>
2053 </target>
2054
2055 <target name="compile-search4j">
2056
2057 <!-- windows -->
2058 <if><bool><istrue value="${current.os.iswindows}"/></bool>
2059 <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
2060 <arg value="/f"/>
2061 <arg value="win32.mak"/>
2062 <arg value='BINDIR="${basedir}\bin"'/>
2063 </exec>
2064 <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
2065 <arg value="/f"/>
2066 <arg value="win32.mak"/>
2067 <arg value="install"/>
2068 <arg value='BINDIR="${basedir}\bin"'/>
2069 </exec>
2070
2071 <!-- unix -->
2072 <else><if><bool><istrue value="${current.os.isunix}"/></bool>
2073 <exec executable="${src.packages.home}/search4j/configure" dir="${src.packages.home}/search4j" failonerror="true">
2074 <arg value="--bindir=${basedir}/bin"/>
2075 <arg value="${static.arg}"/>
2076 <arg line="${cross.configure.args}"/>
2077 </exec>
2078 <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true"/>
2079 <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true">
2080 <arg value="install"/>
2081 </exec>
2082
2083 <!-- else warn -->
2084 <else>
2085 <fail>this target does not support the current os</fail>
2086
2087 </else></if></else></if>
2088
2089 </target>
2090
2091 <target name="install-auxiliary-jar-files" depends="init">
2092
2093 <if>
2094 <bool><available file="${mg.home}/mg.jar"/></bool>
2095 <copy file="${mg.home}/mg.jar" todir="${lib.jni}"/>
2096 </if>
2097
2098 <if>
2099 <bool><available file="${mgpp.home}/mgpp.jar"/></bool>
2100 <copy file="${mgpp.home}/mgpp.jar" todir="${lib.jni}"/>
2101 </if>
2102
2103 <copy file="${lucene.home}/LuceneWrapper3.jar" todir="${web.lib}"/>
2104 </target>
2105
2106 <target name="install-jni-files" depends="init" if="with.jni">
2107 <antcall target="install-jni-files-linux"/>
2108 <antcall target="install-jni-files-windows"/>
2109 <antcall target="install-jni-files-macos"/>
2110 </target>
2111
2112 <target name="install-jni-files-linux" depends="init" if="current.os.isunixnotmac">
2113
2114 <if>
2115
2116 <bool><equals arg1="${os.bin.dir}" arg2="windows"/></bool>
2117 <!-- cross compiling to windows -->
2118 <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
2119 <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
2120 <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
2121 <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
2122 <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
2123 <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
2124
2125 <else>
2126 <!-- otherwise do the usual Unix copies -->
2127 <copy file="${mg.home}/jni/libmgretrievejni.so" todir="${lib.jni}"/>
2128 <copy file="${mg.home}/jni/libmgsearchjni.so" todir="${lib.jni}"/>
2129 <copy file="${mg.home}/jni/libmgpassjni.so" todir="${lib.jni}"/>
2130 <copy file="${mgpp.home}/jni/libmgppretrievejni.so" todir="${lib.jni}"/>
2131 <copy file="${mgpp.home}/jni/libmgppsearchjni.so" todir="${lib.jni}"/>
2132 <copy file="${mgpp.home}/jni/libmgpppassjni.so" todir="${lib.jni}"/>
2133 </else>
2134 </if>
2135
2136
2137 </target>
2138 <target name="install-jni-files-windows" depends="init" if="current.os.iswindows">
2139 <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
2140 <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
2141 <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
2142 <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
2143 <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
2144 <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
2145 </target>
2146 <target name="install-jni-files-macos" depends="init" if="current.os.ismac">
2147 <copy file="${mg.home}/jni/libmgretrievejni.jnilib" todir="${lib.jni}"/>
2148 <copy file="${mg.home}/jni/libmgsearchjni.jnilib" todir="${lib.jni}"/>
2149 <copy file="${mg.home}/jni/libmgpassjni.jnilib" todir="${lib.jni}"/>
2150 <copy file="${mgpp.home}/jni/libmgppretrievejni.jnilib" todir="${lib.jni}"/>
2151 <copy file="${mgpp.home}/jni/libmgppsearchjni.jnilib" todir="${lib.jni}"/>
2152 <copy file="${mgpp.home}/jni/libmgpppassjni.jnilib" todir="${lib.jni}"/>
2153 </target>
2154
2155 <!-- ========common-src targets =================================-->
2156 <!-- these are used to get common-src (for indexers, gdbm, sqlite etc) when
2157 collection building is not enabled -->
2158
2159 <target name="update-common-src" depends="init" if="collection.building.disabled">
2160 </target>
2161
2162 <target name="svnupdate-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
2163 <exec executable="svn">
2164 <arg value="update"/>
2165 <arg value="${common.src.home}"/>
2166 <arg value="-r"/><arg value="${branch.revision}"/>
2167 </exec>
2168 </target>
2169
2170 <target name="prepare-common-src" depends="init" if="collection.building.disabled" unless="common.src.present">
2171 <antcall target="checkout-common-src"/>
2172 <antcall target="unzip-windows-packages"/>
2173 </target>
2174
2175 <target name="checkout-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
2176 <echo>checking out common-src</echo>
2177 <exec executable="svn">
2178 <arg value="checkout"/>
2179 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src"/>
2180 <arg value="common-src"/>
2181 <arg value="-r"/><arg value="${branch.revision}"/>
2182 </exec>
2183 </target>
2184
2185 <target name="configure-common-src" depends="init">
2186<!--
2187 <echo>cross configure args: ${cross.configure.args}</echo>
2188-->
2189 <exec executable="${common.src.home}/configure" os="${os.unix}"
2190 dir="${common.src.home}" failonerror="true">
2191 <arg value="--prefix=${gs2build.home}"/> <!-- what value to use?? -->
2192 <arg value="--bindir=${gs2build.home}/bin/${os.bin.dir}"/> <!-- what value to use?? -->
2193 <arg line="${gs2.opt.args}"/>
2194 <arg line="${static.arg}"/>
2195 <arg line="${cross.configure.args}"/>
2196 <arg line="${allargs}"/>
2197 </exec>
2198 </target>
2199
2200 <target name="clean-common-src" depends="init">
2201 <!-- unix: -->
2202 <if><bool><available file="${common.src.home}/Makefile"/></bool>
2203 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2204 <arg value="clean"/>
2205 </exec>
2206 </if>
2207 <!-- windows: -->
2208 <exec executable="nmake" dir="${common.src.home}" os="${os.windows}" failonerror="true">
2209 <arg value="/f"/>
2210 <arg value="win32.mak"/>
2211 <arg value="clean"/>
2212 <arg value="GSDLHOME=${gs2build.home}"/>
2213 </exec>
2214 </target>
2215 <target name="distclean-common-src" depends="init">
2216 <!-- unix: -->
2217 <if><bool><available file="${common.src.home}/Makefile"/></bool>
2218 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2219 <arg value="distclean"/>
2220 </exec>
2221 </if>
2222 <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->
2223 <exec executable="nmake" dir="${common.src.home}" os="${os.windows}" failonerror="true">
2224 <arg value="/f"/>
2225 <arg value="win32.mak"/>
2226 <arg value="clean"/>
2227 <arg value="GSDLHOME=${gs2build.home}"/>
2228 </exec>
2229 </target>
2230 <target name="compile-common-src" depends="init">
2231 <!-- unix: -->
2232 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2233 <arg value="${gs2.compile.target}"/>
2234 </exec>
2235 <!-- windows: -->
2236 <exec executable="nmake" dir="${common.src.home}" os="${os.windows}" failonerror="true">
2237 <arg value="/f"/>
2238 <arg value="win32.mak"/>
2239 <arg value="GSDLHOME=${gs2build.home}"/>
2240 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
2241 <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
2242 <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
2243 <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
2244 <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
2245 </exec>
2246 </target>
2247
2248 <!-- ======= collection-building targets ===========================-->
2249
2250 <target name="update-collection-building" if="collection.building.enabled"
2251 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"
2252 description="Update (SVN update, configure, compile etc) only the collection building components"/>
2253
2254 <target name="svnupdate-collection-building" if="collection.building.enabled" depends="init,svnupdate-gs2build,svnupdate-cgi,svnupdate-gli" unless="nosvn.mode"
2255 description="SVN update the collection building components">
2256 </target>
2257
2258 <target name="prepare-collection-building" depends="init,prepare-gs2build,svnupdate-cgi,prepare-gli" if="collection.building.enabled">
2259 </target>
2260
2261 <target name="configure-collection-building" depends="init,configure-build-src" if="collection.building.enabled"
2262 description="Configure the collection building components">
2263 </target>
2264
2265 <target name="clean-collection-building" depends="init,clean-gli,clean-build-src"
2266 description="Clean only the collection building components"
2267 if="collection.building.enabled"/>
2268
2269 <target name="distclean-collection-building" depends="init,clean-build-src,distclean-build-src"
2270 description="Distclean only the collection building components"
2271 if="collection.building.enabled"/>
2272
2273 <target name="compile-collection-building" depends="init,compile-build-src,compile-gli" if="collection.building.enabled"
2274 description="Compile only the collection building components">
2275 <!-- make install for common-src -->
2276 <!-- unix: -->
2277 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2278 <arg value="${gs2.install.target}"/>
2279 </exec>
2280
2281 <!-- windows: -->
2282 <exec executable="nmake" dir="${common.src.home}" os="${os.windows}" failonerror="true">
2283 <arg value="/f"/>
2284 <arg value="win32.mak"/>
2285 <arg value="install"/>
2286 <arg value="GSDLHOME=${gs2build.home}"/>
2287 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
2288 <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
2289 <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
2290 <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
2291 <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
2292 <!--
2293 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
2294 <arg value="USE_SQLITE=0"/>--> <!-- why is this not on by default? -->
2295 </exec>
2296
2297 <!-- install gs2build indexers for windows -->
2298 <if>
2299 <bool><istrue value="${current.os.iswindows}"/></bool>
2300 <copy todir="${gs2build.home}/bin/windows">
2301 <fileset dir="${gs2build.home}/common-src/indexers/bin">
2302 <include name="*.*"/>
2303 </fileset>
2304 </copy>
2305 </if>
2306
2307 <!-- LuceneWrapper jar file not installed by default -->
2308 <mkdir dir="${gs2build.home}/bin/java"/>
2309 <copy file="${lucene.home}/LuceneWrapper3.jar" todir="${gs2build.home}/bin/java"/>
2310
2311 </target>
2312
2313 <!-- ============== gli targets ================================= -->
2314
2315 <!-- gliserver.pl, gsdlCGI.pm, metadata-server.pl and checksum.pl are updated alongside
2316 this in target svnupdate-collection-building -->
2317 <target name="svnupdate-gli" if="collection.building.enabled" depends="init" unless="nosvn.mode">
2318
2319 <exec executable="svn">
2320 <arg value="update"/>
2321 <arg value="${gli.home}"/>
2322 <arg value="-r"/><arg value="${branch.revision}"/>
2323 </exec>
2324
2325 </target>
2326
2327 <!-- gliserver.pl, gsdlCGI.pm, metadata-server.pl and checksum.pl are updated
2328 alongside this prepare-gli target in target prepare-collection-building -->
2329 <target name="prepare-gli" depends="init" if="collection.building.enabled" unless="gli.present">
2330 <!-- checkout -->
2331 <if><bool><and><not><istrue value="${nosvn.mode}"/></not><isset property="with.gli.and.gems"/></and></bool>
2332
2333 <exec executable="svn">
2334 <arg value="checkout"/>
2335 <arg value="${svn.root}/main/${branch.path}/gli"/>
2336 <arg value="-r"/><arg value="${branch.revision}"/>
2337 </exec>
2338
2339 </if>
2340 </target>
2341
2342 <!-- svn checkout gliserver.pl, gsdlCGI.pm for gli applet, as well as gsdlCGI.pm-dependent metadata-server.pl
2343 (checksum.pl is used by GS2 for depositdspace.dm and may eventually be used by GS3 too) -->
2344 <target name="svnupdate-cgi">
2345
2346 <exec executable="svn" dir="web/WEB-INF/cgi">
2347 <arg value="export"/>
2348 <arg value="-r"/><arg value="${branch.revision}"/>
2349 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/gliserver.pl"/>
2350 </exec>
2351 <exec executable="svn" dir="web/WEB-INF/cgi">
2352 <arg value="export"/>
2353 <arg value="-r"/><arg value="${branch.revision}"/>
2354 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/gsdlCGI.pm"/>
2355 </exec>
2356 <exec executable="svn" dir="web/WEB-INF/cgi">
2357 <arg value="export"/>
2358 <arg value="-r"/><arg value="${branch.revision}"/>
2359 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/metadata-server.pl"/>
2360 </exec>
2361 <exec executable="svn" dir="web/WEB-INF/cgi">
2362 <arg value="export"/>
2363 <arg value="-r"/><arg value="${branch.revision}"/>
2364 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/checksum.pl"/>
2365 </exec>
2366 </target>
2367
2368
2369 <target name="clean-gli" depends="init" if="collection.building.enabled">
2370 <!-- gli -->
2371 <property name="gli.home" value="${basedir}/gli"/>
2372 <!-- linux -->
2373 <exec executable="clean.sh" os="${os.unix}" dir="${gli.home}"
2374 resolveExecutable="true" failonerror="true"/>
2375 <!-- windows -->
2376 <exec executable="clean.bat" os="${os.windows}" dir="${gli.home}"
2377 resolveExecutable="true" failonerror="true"/>
2378 </target>
2379
2380 <target name="compile-gli" depends="init" if="collection.building.enabled">
2381 <if><bool><isset property="with.gli.and.gems"/></bool>
2382 <!-- gli -->
2383 <property name="gli.home" value="${basedir}/gli"/>
2384
2385 <!-- linux -->
2386 <exec executable="makegli.sh" os="${os.unix}" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
2387 <!--remote gli-->
2388 <exec executable="makejar.sh" os="${os.unix}" dir="${gli.home}"
2389 resolveExecutable="true" failonerror="true"/>
2390 <!-- windows -->
2391 <exec executable="makegli.bat" os="${os.windows}" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
2392 <!--remote gli-->
2393 <exec executable="makejar.bat" os="${os.windows}" dir="${gli.home}"
2394 resolveExecutable="true" failonerror="true"/>
2395 <copy file="${gli.home}/GLIServer.jar" todir="${gs2build.home}/bin/java" />
2396 </if>
2397 </target>
2398
2399 <target name="gli" description="Run the Greenstone Librarian Interface" depends="init" if="collection.building.enabled">
2400 <exec executable="${basedir}/gli/gli.sh" os="${os.linux},${os.solaris}" dir="${basedir}/gli" spawn="true">
2401 <env key="gsdl3path" path="${basedir}"/>
2402 <env key="gsdlpath" path="${gs2build.home}"/>
2403 </exec>
2404 <exec executable="${basedir}/gli/gli.sh" os="${os.mac}" dir="${basedir}/gli" spawn="true">
2405 <env key="gsdl3path" path="${basedir}"/>
2406 <env key="gsdlpath" path="${gs2build.home}"/>
2407 <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${gdbm.home}/lib"/>
2408 </exec>
2409 <exec executable="${basedir}/gli/gli.bat" os="${os.windows}" dir="${basedir}/gli" spawn="true">
2410 <env key="GSDL3PATH" path="${basedir}"/>
2411 <env key="GSDLPATH" path="${gs2build.home}"/>
2412 </exec>
2413 <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.
2414 </echo>
2415 </target>
2416
2417 <!-- ================ gs2build targets =========================== -->
2418
2419 <target name="svnupdate-gs2build" if="collection.building.enabled" depends="init" unless="nosvn.mode">
2420 <echo>svn updating gs2build</echo>
2421 <exec executable="svn">
2422 <arg value="update"/>
2423 <arg value="${gs2build.home}"/>
2424 <arg value="-r"/><arg value="${branch.revision}"/>
2425 </exec>
2426 </target>
2427
2428 <target name="prepare-gs2build" depends="init" if="collection.building.enabled" unless="gs2build.present">
2429 <antcall target="checkout-gs2build"/>
2430 <antcall target="prepare-imagemagick"/> <!-- has to be done before calling prepare-gnome-lib -->
2431 <antcall target="prepare-gnome-lib"/>
2432 <antcall target="unzip-windows-packages"/>
2433 <antcall target="checkout-winbin"/>
2434 <antcall target="get-windows-binaries"/>
2435 <antcall target="delete-winbin"/>
2436 </target>
2437
2438 <target name="checkout-gs2build" depends="init" if="collection.building.enabled" unless="nosvn.mode">
2439 <echo>checking out gs2build</echo>
2440 <exec executable="svn">
2441 <arg value="checkout"/>
2442 <arg value="${svn.root}/main/${branch.path}/gs2build"/>
2443 <arg value="-r"/><arg value="${branch.revision}"/>
2444 </exec>
2445 </target>
2446
2447
2448 <target name="prepare-imagemagick" depends="init" if="collection.building.enabled">
2449 <if>
2450 <bool>
2451 <istrue value="${checkout.imagemagick.ext}"/>
2452 </bool>
2453
2454 <antcall target="checkout-imagemagick"/>
2455 <antcall target="compile-imagemagick"/>
2456
2457 <else>
2458 <echo>**** Not preparing imagemagick:</echo>
2459 <echo>property checkout.imagemagick.ext in build.properties was not set or was set to false</echo>
2460 </else>
2461 </if>
2462 </target>
2463
2464 <target name="checkout-imagemagick" depends="init" if="collection.building.enabled" unless="nosvn.mode">
2465
2466 <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
2467 <condition property="imagemagick.src.present">
2468 <available file="${imagemagick.src.dir}" type="dir" />
2469 </condition>
2470
2471 <if>
2472 <bool>
2473 <not><istrue value="${imagemagick.src.present}"/></not>
2474 </bool>
2475
2476 <echo>checking out imagemagick source into the extension area</echo>
2477
2478 <exec executable="svn">
2479 <arg value="checkout"/>
2480 <arg value="${svn.root}/gs2-extensions/imagemagick/trunk/src"/>
2481 <arg value="${imagemagick.src.dir}"/>
2482 </exec>
2483
2484 <else>
2485 <echo>imagemagick source code already exists at ${imagemagick.src.dir}</echo>
2486 </else>
2487 </if>
2488 </target>
2489
2490 <!-- 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. -->
2491 <target name="compile-imagemagick" if="checkout.imagemagick.ext">
2492
2493 <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
2494 <property name="imagemagick.compiled.dir" value="${gs2build.home}/ext/imagemagick/${os.bin.dir}"/>
2495
2496 <condition property="imagemagick.src.present">
2497 <available file="${imagemagick.src.dir}" type="dir" />
2498 </condition>
2499 <condition property="imagemagick.compiled.present">
2500 <available file="${imagemagick.compiled.dir}" type="dir"/>
2501 </condition>
2502 <!--<condition property="imagemagick.bin.present">
2503 <available file="${basedir}/wherever/the/imgmagick/binary/is/to/be/found" type="dir" />
2504 </condition>-->
2505
2506 <if>
2507 <bool>
2508 <and>
2509 <istrue value="${imagemagick.src.present}"/> <!-- imagemagick src code is present -->
2510 <not><istrue value="${imagemagick.compiled.present}"/></not> <!-- imagemagick src not compiled yet, so no imagemagick/os subfolder yet -->
2511 </and>
2512 </bool>
2513 <!-- then compile it. Only necessary for mac/linux, since windows has a stable working binary of imagemagick -->
2514 <exec executable="/bin/bash" dir="${imagemagick.src.dir}" failonerror="true">
2515 <arg value="CASCADE-MAKE.sh"/>
2516 </exec>
2517 </if>
2518 </target>
2519
2520
2521 <!-- Compile up gnome-lib src folder if: checkout.gnomelib.ext is turned on, and if not using the binary
2522 version (gnome-lib-minimal), and if the gnome-lib src folder is not already compiled up. -->
2523 <target name="compile-gnome-lib" if="checkout.gnomelib.ext">
2524
2525 <!-- http://stackoverflow.com/questions/3290307/sourcing-a-shell-profile-in-an-ant-build-file
2526 TODO: CASCADE-MAKE already sources devel.bash, but we still want to source it more globally,
2527 so that the rest of the GS3 compilation process also has access to those env variables -->
2528
2529 <property name="gnome.lib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
2530 <property name="gnome.lib.compiled.dir" value="${basedir}/gs2build/ext/gnome-lib/${os.bin.dir}"/>
2531
2532 <condition property="gnome.src.lib.present">
2533 <available file="${gnome.lib.src.dir}" type="dir" />
2534 </condition>
2535 <condition property="gnome.compiled.lib.present">
2536 <available file="${gnome.lib.compiled.dir}" type="dir"/>
2537 </condition>
2538 <condition property="gnome.lib.min.present">
2539 <available file="${basedir}/gs2build/ext/gnome-lib-minimal" type="dir" />
2540 </condition>
2541
2542 <if>
2543 <bool>
2544 <and>
2545 <!-- <istrue value="${checkout.gnomelib.ext}"/> make sure user wants gnome-lib -->
2546 <not><isset property="${gnome.lib.min.present}"/></not> <!-- no gnome-lib-minimal binary present -->
2547 <istrue value="${gnome.src.lib.present}"/> <!-- gnome-lib folder for compilation is present-->
2548 <not><istrue value="${gnome.compiled.lib.present}"/></not> <!-- gnome-lib not yet compiled, so no gnome-lib/os subfolder yet -->
2549 </and>
2550 </bool>
2551
2552 <!-- then compile it. Only necessary for mac/linux, since windows doesn't need gnome lib -->
2553 <exec executable="/bin/bash" dir="${gnome.lib.src.dir}" failonerror="true">
2554 <arg value="CASCADE-MAKE.sh"/>
2555 </exec>
2556 </if>
2557 </target>
2558
2559
2560 <target name="prepare-gnome-lib" depends="init" if="collection.building.enabled" unless="gnome-lib.present">
2561 <if>
2562 <bool>
2563 <istrue value="${checkout.gnomelib.ext}"/>
2564 </bool>
2565
2566 <antcall target="checkout-gnome-lib"/>
2567 <antcall target="compile-gnome-lib"/>
2568
2569 <else>
2570 <echo>**** Not preparing gnome-lib:</echo>
2571 <echo>property checkout.gnomelib.ext in build.properties was not set or was set to false</echo>
2572 </else>
2573 </if>
2574 </target>
2575
2576
2577 <target name="checkout-gnome-lib" depends="init" if="collection.building.enabled" unless="nosvn.mode">
2578
2579 <property name="gnomelib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
2580 <condition property="gnome.src.present">
2581 <available file="${gnomelib.src.dir}" type="dir" />
2582 </condition>
2583
2584 <if>
2585 <bool>
2586 <not><istrue value="${gnome.src.present}"/></not>
2587 </bool>
2588
2589 <echo>checking out gnome-lib extension</echo>
2590 <exec executable="svn">
2591 <arg value="checkout"/>
2592 <arg value="${svn.root}/gs2-extensions/gnome-lib/trunk/src"/>
2593 <arg value="${gs2build.home}/ext/gnome-lib"/>
2594 </exec>
2595
2596 <else>
2597 <echo>gnomelib source code already exists at ${gnomelib.src.dir}</echo>
2598 </else>
2599 </if>
2600
2601 </target>
2602
2603 <target name="checkout-winbin" depends="init" if="current.os.iswindows"
2604 unless="nosvn.mode">
2605
2606 <exec executable="svn">
2607 <arg value="checkout"/>
2608 <arg value="${svn.root}/main/${branch.path}/binaries/windows"/>
2609 <arg value="-r"/><arg value="${branch.revision}"/>
2610 <arg value="winbin"/>
2611 </exec>
2612
2613 </target>
2614
2615 <target name="update-winbin" depends="init" if="current.os.iswindows" unless="nosvn.mode">
2616 <exec executable="svn">
2617 <arg value="update"/>
2618 <arg value="winbin"/>
2619 <arg value="-r"/><arg value="${branch.revision}"/>
2620 </exec>
2621
2622 </target>
2623
2624 <target name="get-windows-binaries" depends="init" if="collection.building.enabled.windows">
2625 <move todir="${gs2build.home}/bin/windows" failonerror="false">
2626 <fileset dir="${basedir}/winbin/bin"/>
2627 </move>
2628 </target>
2629
2630 <target name="delete-winbin" depends="init" if="collection.building.enabled.windows">
2631 <delete dir="${basedir}/winbin"/>
2632 </target>
2633
2634 <target name="unzip-windows-packages" depends="init" if="current.os.iswindows">
2635 <unzip src="${common.src.home}/packages/windows/crypt/crypt.zip"
2636 dest="${common.src.home}/packages/windows/crypt"/>
2637 <untar compression="gzip"
2638 src="${common.src.home}/packages/sqlite/${sqlite.targz.version}"
2639 dest="${common.src.home}/packages/sqlite"/>
2640 <unzip src="${common.src.home}/indexers/packages/windows/iconv/iconv.zip"
2641 dest="${common.src.home}/indexers/packages/windows/iconv"/>
2642 </target>
2643
2644 <target name="gs2build-edit-setup-bat" if="collection.building.enabled.windows">
2645 <!-- we want a windows path in the setup.bat file -->
2646 <pathconvert targetos="windows" property="gs2build.home.windows">
2647 <path path="${gs2build.home}"/>
2648 </pathconvert>
2649 <move file="${gs2build.home}/setup.bat" tofile="${gs2build.home}/setup-tmp.bat">
2650 <filterset>
2651 <filter token="gsdlhome" value="${gs2build.home.windows}"/>
2652 </filterset>
2653 </move>
2654 <move file="${gs2build.home}/setup-tmp.bat" tofile="${gs2build.home}/setup.bat" />
2655 </target>
2656
2657
2658 <target name="clean-build-src" depends="init" if="collection.building.enabled">
2659 <!-- unix: -->
2660 <if><bool><available file="${build.src.home}/Makefile"/></bool>
2661 <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
2662 <arg value="clean"/>
2663 </exec>
2664 </if>
2665 <!-- windows: -->
2666 <exec executable="nmake" dir="${build.src.home}" os="${os.windows}" failonerror="true">
2667 <arg value="/f"/>
2668 <arg value="win32.mak"/>
2669 <arg value="clean"/>
2670 <arg value="GSDLHOME=${gs2build.home}"/>
2671 </exec>
2672 </target>
2673
2674
2675 <target name="distclean-build-src" depends="init,clean-build-src" if="collection.building.enabled">
2676 <!-- unix: -->
2677 <if><bool><available file="${build.src.home}/Makefile"/></bool>
2678 <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
2679 <arg value="distclean"/>
2680 </exec>
2681 </if>
2682 <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->
2683 <exec executable="nmake" dir="${build.src.home}" os="${os.windows}" failonerror="true">
2684 <arg value="/f"/>
2685 <arg value="win32.mak"/>
2686 <arg value="clean"/>
2687 <arg value="GSDLHOME=${gs2build.home}"/>
2688 </exec>
2689 </target>
2690
2691 <target name="configure-build-src" depends="init" if="collection.building.enabled"
2692 description="Configure the build-src component">
2693 <exec executable="${build.src.home}/configure" os="${os.unix}"
2694 dir="${build.src.home}" failonerror="true">
2695 <arg value="--prefix=${gs2build.home}"/>
2696 <arg line="${gs2.opt.args} ${static.arg} ${cross.configure.args} ${allargs}"/>
2697 </exec>
2698 </target>
2699
2700 <!-- common-src is done separately and needs to be compiled first -->
2701 <target name="compile-build-src" depends="init" if="collection.building.enabled">
2702
2703 <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
2704 <arg line="${ldlpath.arg}"/>
2705 </exec>
2706
2707 <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
2708 <arg value="install"/>
2709 </exec>
2710
2711 <!-- run the setup script -->
2712 <!-- <exec executable="${compile.windows.c++.setup}" os="${os.windows}" failonerror="true"/>-->
2713 <!--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-->
2714 <exec executable="nmake" dir="${build.src.home}" os="${os.windows}" failonerror="true">
2715 <arg value="/f"/>
2716 <arg value="win32.mak"/>
2717 <arg value="GSDLHOME=${gs2build.home}"/>
2718 </exec>
2719 <exec executable="nmake" dir="${build.src.home}" os="${os.windows}" failonerror="true">
2720 <arg value="/f"/>
2721 <arg value="win32.mak"/>
2722 <arg value="install"/>
2723 <arg value="GSDLHOME=${gs2build.home}"/>
2724 </exec>
2725 </target>
2726
2727
2728 <!-- ======================== TESTING Targets ========================= -->
2729
2730 <target name="test" description="Run the (incomplete) JUnit test suite "
2731 depends="init">
2732 <mkdir dir="${basedir}/test"/>
2733 <junit printsummary="withOutAndErr"
2734 errorproperty="test.failed"
2735 failureproperty="test.failed"
2736 fork="${junit.fork}">
2737 <formatter type="plain"/>
2738 <classpath>
2739 <pathelement location="${build.home}/gsdl3test.jar"/>
2740 <path refid="compile.classpath"/>
2741 </classpath>
2742 <test name="${testcase}" if="testcase"/>
2743 <batchtest todir="${basedir}/test" unless="testcase">
2744 <fileset dir="${build.home}" includes="**/*Test.class" />
2745 </batchtest>
2746 </junit>
2747 <echo>
2748 *********************************************
2749 Test output can be found in directory 'test'
2750 *********************************************
2751 </echo>
2752 </target>
2753
2754 <!-- ======================== FLAX Targets ========================= -->
2755 <target name="prepare-flax" description="check out flax source code from another repository" if="install.flax">
2756 <echo>checking out flax ...</echo>
2757 <mkdir dir="${basedir}/src/java/org/flax"/>
2758 <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/flax"/>
2759 <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/action/flax"/>
2760 <mkdir dir="${web.home}/WEB-INF/classes/flax"/>
2761 <mkdir dir="${web.home}/interfaces/flax"/>
2762 <mkdir dir="${web.home}/sites/flax"/>
2763 <mkdir dir="${basedir}/flax-resources"/>
2764 <mkdir dir="${basedir}/flax-lib"/>
2765 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/flax"/>
2766 <arg value="src/java/org/flax"/></exec>
2767 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/flax"/>
2768 <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
2769 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/action/flax"/>
2770 <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
2771 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/WEB-INF/classes/flax"/>
2772 <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
2773 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/interfaces/flax"/>
2774 <arg value="${web.home}/interfaces/flax"/></exec>
2775 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/sites/flax"/>
2776 <arg value="${web.home}/sites/flax"/></exec>
2777 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/flax-resources"/>
2778 <arg value="flax-resources"/></exec>
2779 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/lib"/>
2780 <arg value="flax-lib"/></exec>
2781 <antcall target="flax-copy-del-files" />
2782 </target>
2783
2784 <target name="flax-copy-del-files" description="copy some flax files into the appropriate greenstone3 directories and delete some unwanted greenstone stuff">
2785 <copy file="${web.home}/WEB-INF/classes/flax/web.xml" todir="${web.home}/WEB-INF" overwrite="true" />
2786 <copy todir="${web.home}/WEB-INF/lib">
2787 <fileset dir="${basedir}/flax-lib">
2788 <include name="*.jar"/>
2789 </fileset>
2790 </copy>
2791 <!--<delete dir="${web.home}/sites/gateway"/>
2792 <delete dir="${web.home}/sites/localsite"/>-->
2793 </target>
2794
2795 <target name="update-flax" description="update flax from repository">
2796 <echo>updating flax ...</echo>
2797 <exec executable="svn"><arg value="update"/>
2798 <arg value="src/java/org/flax"/></exec>
2799 <exec executable="svn"><arg value="update"/>
2800 <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
2801 <exec executable="svn"><arg value="update"/>
2802 <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
2803 <exec executable="svn"><arg value="update"/>
2804 <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
2805 <exec executable="svn"><arg value="update"/>
2806 <arg value="${web.home}/interfaces/flax"/></exec>
2807 <exec executable="svn"><arg value="update"/>
2808 <arg value="${web.home}/web/sites/flax"/></exec>
2809 <exec executable="svn"><arg value="update"/>
2810 <arg value="flax-resources"/></exec>
2811 <exec executable="svn"><arg value="update"/>
2812 <arg value="flax-lib"/></exec>
2813 <antcall target="compile-core" />
2814 </target>
2815
2816 <!-- ========================End of FLAX Targets ========================= -->
2817
2818 <target name="compile-javadocs">
2819 <javadoc packagenames="org.greenstone.*"
2820 sourcepath="src/java"
2821 defaultexcludes="yes"
2822 destdir="docs/javadoc"
2823 author="true"
2824 version="true"
2825 use="true"
2826 windowtitle="Greenstone3 API">
2827 <doctitle><![CDATA[<h1>Greenstone3 API</h1>]]></doctitle>
2828 </javadoc>
2829 </target>
2830
2831<!-- ========== Some distribution targets ======================== -->
2832 <target name="remove-source">
2833 <if><bool><isset property="with.gli.and.gems"/></bool>
2834 <delete includeEmptyDirs="true">
2835 <fileset dir="." defaultexcludes="false">
2836 <patternset refid="greenstone3.source.component"/>
2837 </fileset>
2838 </delete>
2839
2840 <else>
2841 <delete includeEmptyDirs="true">
2842 <fileset dir="." defaultexcludes="false">
2843 <patternset refid="greenstone3.source.no.gli.component"/>
2844 </fileset>
2845 </delete>
2846 </else>
2847 </if>
2848 </target>
2849
2850 <target name="dist-tidy"
2851 description="'tidies-up' a greenstone3 installation for distribution.">
2852
2853 <!-- delete unneeded things -->
2854 <delete dir="${packages.home}/axis"/>
2855 <delete><fileset dir="${packages.home}" includes="*.zip"/></delete>
2856 <delete file="README-SVN.txt"/>
2857 <delete file="build.properties.in"/>
2858
2859 <!-- delete source files -->
2860 <antcall target="remove-source"/>
2861
2862 <!-- create empty directories -->
2863 <mkdir dir="${web.writablehome}/applet"/>
2864 <mkdir dir="${web.writablehome}/logs"/>
2865 <mkdir dir="${web.writablehome}/logs/tmp"/>
2866
2867 <!-- os specific tidy-ups -->
2868 <!-- linux, mac -->
2869 <if><bool><istrue value="${current.os.isunix}"/></bool>
2870 <delete><fileset dir="." includes="*.bat"/></delete>
2871 <if><bool><isset property="with.gli.and.gems"/></bool>
2872 <delete><fileset dir="gli" includes="*.bat"/></delete>
2873 </if>
2874 <delete><fileset dir="gs2build" includes="*.bat"/></delete>
2875 <delete><fileset dir="bin/script" includes="*.bat"/></delete>
2876 <delete file="${basedir}/gs2build/win32cfg.h"/>
2877 <delete file="${basedir}/gs2build/win32.mak"/>
2878 <delete dir="${basedir}/winutil"/>
2879 <delete failonerror="false"><fileset dir="${lib.jni}" includes="*.dll"/></delete>
2880
2881 <!-- windows -->
2882 <else><if><bool><istrue value="${current.os.iswindows}"/></bool>
2883 <delete><fileset dir="." includes="*.sh,*.bash,*.csh"/></delete>
2884 <if><bool><isset property="with.gli.and.gems"/></bool>
2885 <delete><fileset dir="gli" includes="*.sh,*.bash,*.csh"/></delete>
2886 </if>
2887 <delete><fileset dir="gs2build" includes="*.sh,*.bash,*.csh"/></delete>
2888 <delete><fileset dir="bin/script" includes="*.sh,*.bash,*.csh"/></delete>
2889 </if></else></if>
2890
2891 </target>
2892
2893 <!-- fix up executable permissions for binary release -->
2894 <target name="fix-execute-permissions">
2895 <echo>Setting binaries to executable</echo>
2896 <chmod perm="775">
2897 <fileset dir="."><patternset refid="greenstone3.executables"/></fileset>
2898 </chmod>
2899 </target>
2900
2901 <!-- fix up executable permissions for source code release -->
2902 <target name="fix-execute-permissions-source">
2903 <chmod perm="775">
2904 <fileset dir="."><patternset refid="greenstone3.source.executables"/></fileset>
2905 </chmod>
2906 </target>
2907
2908 <!-- for macs, set up the .app shortcuts to gsi, gli, client-gli and gems -->
2909 <target name="gen-mac-shortcuts">
2910 <if><bool><istrue value="${current.os.ismac}"/></bool>
2911 <filter token="gsdl3srchome" value="${basedir}"/>
2912 <copy file="${basedir}/gs3-server.app/Contents/document.wflow.in" tofile="${basedir}/gs3-server.app/Contents/document.wflow" filtering="true" overwrite="true"/>
2913 <copy file="${basedir}/gli.app/Contents/document.wflow.in" tofile="${basedir}/gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
2914 <copy file="${basedir}/client-gli.app/Contents/document.wflow.in" tofile="${basedir}/client-gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
2915 <copy file="${basedir}/gems.app/Contents/document.wflow.in" tofile="${basedir}/gems.app/Contents/document.wflow" filtering="true" overwrite="true"/>
2916 </if>
2917 </target>
2918
2919 <!-- ============= tweaks for making compilation static ========== -->
2920 <target name="tweak-makefiles" depends="init" if="compile.static">
2921 <antcall target="rtftohtml-add-static" />
2922 </target>
2923
2924 <target name="rtftohtml-add-static" depends="init" if="collection.building.enabled">
2925 <rsr file="${gs2build.home}/build-src/packages/rtftohtml/rtftohtml_src/Makefile" pattern="-o rtftohtml(.{2})EXEEXT(.{1})" replacement="-o rtftohtml$1EXEEXT$2 -static" />
2926 </target>
2927
2928 <target name="run-collection-tests">
2929 <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
2930 <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>
2931 </if>
2932 <for param="testjar">
2933 <path>
2934 <fileset dir="${basedir}" includes="web/sites/*/collect/*/tests/tests.jar"/>
2935 </path>
2936 <sequential>
2937 <echo>Testing @{testjar}</echo>
2938 <java classname="org.junit.runner.JUnitCore" fork="true">
2939 <arg value="gstests.TestClass"/>
2940 <jvmarg value="-DSERVERURL=http://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet} "/>
2941 <classpath>
2942 <fileset dir="${basedir}/ext/testing/lib/java">
2943 <include name="*.jar"/>
2944 </fileset>
2945 <files includes="@{testjar}"/>
2946 </classpath>
2947 </java>
2948 </sequential>
2949 </for>
2950 </target>
2951
2952 <target name="build-collection-tests">
2953 <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
2954 <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>
2955 </if>
2956 <for param="compiledir">
2957 <path>
2958 <dirset dir="${basedir}" includes="web/sites/*/collect/*/tests/src"/>
2959 </path>
2960 <sequential>
2961 <echo>Compiling @{compiledir}</echo>
2962 <if><bool><not><available file="@{compiledir}/../build" type="dir"/></not></bool>
2963 <mkdir dir="@{compiledir}/../build"/>
2964 </if>
2965 <javac
2966 srcdir="@{compiledir}"
2967 destdir="@{compiledir}/../build"
2968 debug="${compile.debug}"
2969 deprecation="${compile.deprecation}"
2970 optimize="${compile.optimize}">
2971 <classpath>
2972 <fileset dir="${basedir}/ext/testing/lib/java">
2973 <include name="*.jar"/>
2974 </fileset>
2975 </classpath>
2976 <include name="gstests/*.java"/>
2977 </javac>
2978 <jar destfile="@{compiledir}/../tests.jar">
2979 <fileset dir="@{compiledir}/../build">
2980 <include name="gstests/**"/>
2981 </fileset>
2982 <manifest>
2983 <attribute name="Built-By" value="${user.name}" />
2984 </manifest>
2985 </jar>
2986 </sequential>
2987 </for>
2988 </target>
2989</project>
Note: See TracBrowser for help on using the repository browser.