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

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

gs2mgdemo, gs2mgppdemo and lucene-jdbm-demo are meant to work out of the box (the first 2 are only present in svn checked out GS3s). To this end, these collections now need the archives folder as well for doc editing to work, as archives is now used by doc editing and no longer index. Also needed to rebuild the index folder for these 3 collections for everything to be up to date (without rebuilding index, in doc editing mode I just see the nav bar followed by footer instead of doc content). Have not updated the gutenberg collection yet as it's different.

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