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

Last change on this file since 31704 was 31508, checked in by ak19, 7 years ago

Tiny but important change (bugfix), that I confirmed with Kathy today. The app.path in build.xml should not be hardcoded to greenstone3 but should use the gs3 context, whatever that is (default greenstone3), as specified in build.properties. I thought this was a bug when I inspected and changed build.xml and build.props on Fri to add in the new get-solr-servlet target. Kathy confirmed this was a bug that struck when the gs3 context name is changed and activate.pl still gets the usual greenstone3 context name from calling the get-default-servlet-url.

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