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

Last change on this file since 30234 was 30234, checked in by ak19, 9 years ago

Adding in debugging for installer

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