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

Last change on this file since 30793 was 30793, checked in by ak19, 6 years ago

Still experimenting. Adding debug statements to see DYLD_LIB_PATH during release-kit execution.

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