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

Last change on this file since 31121 was 31121, checked in by kjdon, 4 years ago

to get online document editing to work, gs3-setup.sh needs to be sourced/run before starting tomcat otherwise incremental-rebuild cannot find buildcol.pl. There was a test in init for this, commented out ages ago as releasekit stuff didn't like it. We have put this test into its own target which gets called when running 'ant start'.

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