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

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

Update to previous two commits which broke release compilation on Linux. Putting the linux part back.

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