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

Last change on this file since 37723 was 37723, checked in by davidb, 12 months ago

New target introduced to untar the usersDB.tar.gz file. Changing to this setup to avoid 'svn co' always reporting their are changes in usersDB/ as a result of creating/changing the users away from the default ones

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