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

Last change on this file since 38567 was 37759, checked in by anupama, 12 months ago

Forgot to take out a debug antcall that generated environment.txt after the bug for which the ant target was created and called was resolved.

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 <echo>Property derby.server.classpath.prop is set to: ${derby.server.classpath.prop}</echo>
1393
1394 <if>
1395 <bool><not><available file="${web.writablelib}/derbynet.jar" type="file"/></not></bool>
1396 <echo>File needed on classpath to start derby server: ${web.writablelib}/derbynet.jar not available</echo>
1397 </if>
1398 <if>
1399 <bool><not><available file="${web.writablelib}/derby.jar" type="file"/></not></bool>
1400 <echo>File needed on classpath to start derby server: ${web.writablelib}/derby.jar not available</echo>
1401 </if>
1402 </target>
1403
1404 <target name="force-stop-derby">
1405 <java classname="org.apache.derby.drda.NetworkServerControl">
1406 <arg value="shutdown"/>
1407 <arg value="-p"/>
1408 <arg value="${derby.server.port}"/>
1409 <classpath refid="derby.server.classpath"/>
1410 </java>
1411 </target>
1412
1413 <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 -->
1414 <if><bool><istrue value="${derby.isrunning}"/></bool>
1415 <!--<echo>Derby is |${derby.isrunning}| running</echo>-->
1416 <antcall target="force-stop-derby"/>
1417 <else>
1418 <echo>Derby is not running</echo>
1419 </else>
1420 </if>
1421 </target>
1422
1423 <target name="start" depends="needs-gs3-setup,init,configure-tomcat,configure-web,configure-solr-ext,configure-webswing-ext,start-derby,start-tomcat"
1424 description="Startup the Tomcat server." >
1425 <echo>${app.name} (${app.version}) server running using Apache Tomcat and Java</echo>
1426 <echo>Tomcat: ${catalina.home}</echo>
1427 <echo>Java : ${java.home}</echo>
1428 <if><bool><available file="${build.src.home}"/></bool>
1429 <echo>Perl : ${full.perl.path}</echo>
1430 </if>
1431 <if><bool><isset property="install.flax"/></bool>
1432 <property name="url" value="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/flax"/>
1433 <else>
1434 <property name="url" value="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/"/>
1435 </else>
1436 </if>
1437 <echo>URL : ${url}</echo>
1438 <!-- assuming that index.html is not needed here -->
1439
1440 <!--Now write out the url with /oaiserver suffix as the baseURL property in OAIConfig.xml-->
1441 <antcall target="init-oaiconfigs">
1442 <param name="url" value="${url}"/>
1443 </antcall>
1444
1445 <!--Now write out the url with /gs-cantaloupe suffix as the baseURL property in IIIFConfig.xml-->
1446 <available file="${basedir}/resources/iiif/IIIFConfig.xml.in" property="iiifconfig.present"/>
1447 <antcall target="init-iiifconfig">
1448 <param name="url" value="${url}"/>
1449 </antcall>
1450
1451 </target>
1452
1453 <target name="status" depends="check-derbyserver-running,verbose-check-tomcat-running">
1454 </target>
1455
1456 <available file="${basedir}/resources/oai/OAIConfig.xml.in" property="oaiconfig.present"/>
1457
1458 <target name="init-oaiconfigs" if="oaiconfig.present">
1459 <echo>Generating new oaiconfigs for servlets ${oai.servlets} </echo>
1460 <foreach list="${oai.servlets}" delimiter="," target="init-oaiconfig" param="servlet_name"/>
1461 </target>
1462
1463 <target name="init-oaiconfig">
1464 <if><bool><not><available file="${basedir}/resources/oai/OAIConfig-${servlet_name}.xml.in"/></not></bool>
1465 <echo>Copying file ${basedir}/resources/oai/OAIConfig.xml.in to ${basedir}/resources/oai/OAIConfig-${servlet_name}.xml.in</echo>
1466 <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>
1467 <copy file="${basedir}/resources/oai/OAIConfig.xml.in" tofile="${basedir}/resources/oai/OAIConfig-${servlet_name}.xml.in"/>
1468 </if>
1469 <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>
1470 <copy file="${basedir}/resources/oai/OAIConfig-${servlet_name}.xml.in" tofile="${web.writableclasses}/OAIConfig-${servlet_name}.xml"/>
1471 <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;" />
1472 </target>
1473
1474 <target name="init-iiifconfig" if="iiifconfig.present">
1475 <echo>Writing out baseURL ${url}gs-cantaloupe to ${web.writableclasses}/IIIFConfig.xml</echo>
1476 <copy file="${basedir}/resources/iiif/IIIFConfig.xml.in" tofile="${web.writableclasses}/IIIFConfig.xml"/>
1477 <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;" />
1478 </target>
1479
1480 <target name="stop" depends="init,stop-tomcat,stop-derby"
1481 description="Shutdown the Tomcat server."/>
1482
1483 <target name="restart" description="Shutdown and restart Tomcat" depends="init,stop,start"/>
1484
1485 <!-- =========== Help targets =================================== -->
1486
1487 <property name="install-command" value="ant [options] prepare install"/>
1488
1489 <target name="usage" description="Print a help message">
1490 <echo message=" Execute 'ant -projecthelp' for a list of targets."/>
1491 <echo message=" Execute 'ant -help' for Ant help."/>
1492 <echo>
1493 To install Greenstone3, run '${install-command}'.
1494 There are properties defined in build.properties. The install
1495 process will ask you if these properties are set correctly.
1496 To avoid this prompt, use the '-Dproperties.accepted=yes'
1497 option.
1498 To log the output, use the '-logfile build.log' option.
1499 The README.txt file has more information about the ant targets
1500 and install process.
1501 </echo>
1502 </target>
1503
1504 <target name="help" depends="usage" description="Print a help message"/>
1505
1506 <target name="debug" depends="init" description="Display all the currently used properties">
1507 <echoproperties/>
1508 </target>
1509
1510 <!-- ====== initialization and setup targets ================== -->
1511
1512 <target name="accept-properties" unless="properties.accepted">
1513 <input addproperty="properties.ok" validargs="y,n">The following properties (among others) are being used from a build.properties file found in this directory:
1514 server.protocols=${server.protocols}
1515 tomcat.server=${tomcat.server}
1516 tomcat.port.https=${tomcat.port.https}
1517 localhost.port.http=${localhost.port.http}
1518
1519 default.server.protocol=${default.server.protocol}
1520 default.tomcat.port=${default.tomcat.port}
1521 Local base HTTP URL used by Greenstone: ${local.http.url}
1522
1523 tomcat.installed.path=${tomcat.installed.path} (this is the location of Tomcat's base dir if it is already installed)
1524 proxy.host=${proxy.host}
1525 proxy.port=${proxy.port}
1526 disable.collection.building=${disable.collection.building}
1527 If these are not acceptable, please change them and rerun this target. Continue [y/n]?
1528 </input>
1529 <condition property="do.abort">
1530 <equals arg1="n" arg2="${properties.ok}"/>
1531 </condition>
1532 <fail if="do.abort">Build aborted by user. Please change your properties settings and re-run the target</fail>
1533 </target>
1534
1535 <!-- this sets up some initial properties -->
1536 <target name="init">
1537
1538 <condition property="java.too.old">
1539 <or>
1540 <equals arg1="1.1" arg2="${java.specification.version}"/>
1541 <equals arg1="1.2" arg2="${java.specification.version}"/>
1542 <equals arg1="1.3" arg2="${java.specification.version}"/>
1543 <equals arg1="1.4" arg2="${java.specification.version}"/>
1544 <equals arg1="1.5" arg2="${java.specification.version}"/>
1545 <equals arg1="1.6" arg2="${java.specification.version}"/>
1546 <equals arg1="1.7" arg2="${java.specification.version}"/>
1547 </or>
1548 </condition>
1549 <fail if="java.too.old" message="You need Java 1.8 or greater to run Greenstone 3"/>
1550
1551 <available file="${basedir}/gli" property="gli.present"/>
1552 <available file="${basedir}/common-src" property="common.src.present"/>
1553 <available file="${basedir}/gs2build" property="gs2build.present"/>
1554 <available file="${gnome-lib-dir}" property="gnome-lib.present"/>
1555
1556 <condition property="tomcat.islocal">
1557 <or>
1558 <not><isset property="tomcat.installed.path"/></not>
1559 <equals arg1="" arg2="${tomcat.installed.path}"/>
1560 </or>
1561 </condition>
1562
1563 <condition property="proxy.present">
1564 <and>
1565 <isset property="proxy.host"/>
1566 <not><equals arg1="" arg2="${proxy.host}"/></not>
1567 </and>
1568 </condition>
1569
1570 <!--
1571 the next block checks if the bundled tomcat is present in the 'packages' directory,
1572 and checks for the lethal combination of tomcat 8 and java 1.4. Test for
1573 tomcat6 is based on the presence of a file inserted by greenstone into the tomcat6
1574 download, as there is no other surefire way to check tomcat version under java 1.4
1575 -->
1576 <condition property="packages.tomcat.ispresent" value="true" else="false">
1577 <available file="packages/tomcat"/>
1578 </condition>
1579 <condition property="packages.tomcat.istomcat8" value="true" else="false">
1580 <available file="packages/tomcat/tomcat8.txt"/>
1581 </condition>
1582 <if>
1583 <bool>
1584 <and>
1585 <istrue value="${packages.tomcat.ispresent}"/>
1586 <istrue value="${packages.tomcat.istomcat8}"/>
1587 <equals arg1="1.4" arg2="${java.specification.version}"/>
1588 </and>
1589 </bool>
1590 <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>
1591 </if>
1592
1593 </target>
1594
1595 <target name="setup-proxy" depends="init" if="proxy.present">
1596 <condition property="ask.user">
1597 <or>
1598 <equals arg1="" arg2="${proxy.user}"/>
1599 <equals arg1="" arg2="${proxy.password}"/>
1600 </or>
1601 </condition>
1602
1603 <getuserandpassword message="Using proxy: ${proxy.host}:${proxy.port}" if="ask.user" username="${proxy.user}" userproperty="proxy.username" pwordproperty="proxy.password"/>
1604 <mysetproxy proxyhost="${proxy.host}" proxyport="${proxy.port}" proxyuser="${proxy.username}" proxypassword="${proxy.password}"/>
1605 </target>
1606
1607 <target name="copy-dot-svn-files" depends="init"
1608 description="Copies all resources .svn files to .in versions - which are used during configure to generate the runtime versions." >
1609 <if>
1610 <bool><available file="${basedir}/resources/tomcat/greenstone3.xml.in"/></bool>
1611 <copy file="${basedir}/resources/tomcat/greenstone3.xml.in" tofile="${basedir}/resources/tomcat/greenstone3.xml.in.backup" overwrite="true"/>
1612 </if>
1613 <copy file="${basedir}/resources/tomcat/greenstone3.xml.svn" tofile="${basedir}/resources/tomcat/greenstone3.xml.in" overwrite="true"/>
1614
1615 <if>
1616 <bool><available file="${basedir}/resources/tomcat/server_tomcat5.xml.in"/></bool>
1617 <copy file="${basedir}/resources/tomcat/server_tomcat5.xml.in" tofile="${basedir}/resources/tomcat/server_tomcat5.xml.in.backup" overwrite="true"/>
1618 </if>
1619 <copy file="${basedir}/resources/tomcat/server_tomcat5.xml.svn" tofile="${basedir}/resources/tomcat/server_tomcat5.xml.in" overwrite="true"/>
1620
1621 <if>
1622 <bool><available file="${basedir}/resources/tomcat/server_tomcat7.xml.in"/></bool>
1623 <copy file="${basedir}/resources/tomcat/server_tomcat7.xml.in" tofile="${basedir}/resources/tomcat/server_tomcat7.xml.in.backup" overwrite="true"/>
1624 </if>
1625 <copy file="${basedir}/resources/tomcat/server_tomcat8.xml.svn" tofile="${basedir}/resources/tomcat/server_tomcat8.xml.in" overwrite="true"/>
1626
1627 <if>
1628 <bool><available file="${basedir}/resources/tomcat/server_tomcat8.xml.in"/></bool>
1629 <copy file="${basedir}/resources/tomcat/server_tomcat8.xml.in" tofile="${basedir}/resources/tomcat/server_tomcat8.xml.in.backup" overwrite="true"/>
1630 </if>
1631 <copy file="${basedir}/resources/tomcat/server_tomcat8.xml.svn" tofile="${basedir}/resources/tomcat/server_tomcat8.xml.in" overwrite="true"/>
1632
1633 <if>
1634 <bool><available file="${basedir}/resources/tomcat/web8.xml.in"/></bool>
1635 <copy file="${basedir}/resources/tomcat/web8.xml.in" tofile="${basedir}/resources/tomcat/web8.xml.in.backup" overwrite="true"/>
1636 </if>
1637 <copy file="${basedir}/resources/tomcat/web8.xml.svn" tofile="${basedir}/resources/tomcat/web8.xml.in" overwrite="true"/>
1638
1639 <if>
1640 <bool><available file="${basedir}/resources/oai/OAIConfig.xml.in"/></bool>
1641 <copy file="${basedir}/resources/oai/OAIConfig.xml.in" tofile="${basedir}/resources/oai/OAIConfig.xml.in.backup" overwrite="true"/>
1642 </if>
1643 <copy file="${basedir}/resources/oai/OAIConfig.xml.svn" tofile="${basedir}/resources/oai/OAIConfig.xml.in" overwrite="true"/>
1644
1645 <if>
1646 <bool><available file="${basedir}/resources/iiif/IIIFConfig.xml.in"/></bool>
1647 <copy file="${basedir}/resources/iiif/IIIFConfig.xml.in" tofile="${basedir}/resources/iiif/IIIFConfig.xml.in.backup" overwrite="true"/>
1648 </if>
1649 <copy file="${basedir}/resources/iiif/IIIFConfig.xml.svn" tofile="${basedir}/resources/iiif/IIIFConfig.xml.in" overwrite="true"/>
1650
1651 <if>
1652 <bool><available file="${basedir}/resources/iiif/cantaloupe.properties.in"/></bool>
1653 <copy file="${basedir}/resources/iiif/cantaloupe.properties.in" tofile="${basedir}/resources/iiif/cantaloupe.properties.in.backup" overwrite="true"/>
1654 </if>
1655 <copy file="${basedir}/resources/iiif/cantaloupe.properties.svn" tofile="${basedir}/resources/iiif/cantaloupe.properties.in" overwrite="true"/>
1656
1657 <if>
1658 <bool><available file="${basedir}/resources/cgi/gsdl3site.cfg.in"/></bool>
1659 <copy file="${basedir}/resources/cgi/gsdl3site.cfg.in" tofile="${basedir}/resources/cgi/gsdl3site.cfg.in.backup" overwrite="true"/>
1660 </if>
1661 <copy file="${basedir}/resources/cgi/gsdl3site.cfg.svn" tofile="${basedir}/resources/cgi/gsdl3site.cfg.in" overwrite="true"/>
1662
1663 <if>
1664 <bool><available file="${basedir}/resources/web/servlets.xml.in"/></bool>
1665 <copy file="${basedir}/resources/web/servlets.xml.in" tofile="${basedir}/resources/web/servlets.xml.in.backup" overwrite="true"/>
1666 </if>
1667 <copy file="${basedir}/resources/web/servlets.xml.svn" tofile="${basedir}/resources/web/servlets.xml.in" overwrite="true"/>
1668
1669 <if>
1670 <bool><available file="${basedir}/resources/web/global.properties.in"/></bool>
1671 <copy file="${basedir}/resources/web/global.properties.in" tofile="${basedir}/resources/web/global.properties.in.backup" overwrite="true"/>
1672 </if>
1673 <copy file="${basedir}/resources/web/global.properties.svn" tofile="${basedir}/resources/web/global.properties.in" overwrite="true"/>
1674
1675 <if>
1676 <bool><available file="${basedir}/resources/web/log4j.properties.in"/></bool>
1677 <copy file="${basedir}/resources/web/log4j.properties.in" tofile="${basedir}/resources/web/log4j.properties.in.backup" overwrite="true"/>
1678 </if>
1679 <copy file="${basedir}/resources/web/log4j.properties.svn" tofile="${basedir}/resources/web/log4j.properties.in" overwrite="true"/>
1680
1681</target>
1682
1683 <!-- ========== Web app Targets ================================ -->
1684
1685 <target name="prepare-web" depends="init">
1686 <mkdir dir="${web.writablehome}/applet"/>
1687 <mkdir dir="${web.writablehome}/logs"/>
1688 <mkdir dir="${web.writablehome}/logs/tmp"/>
1689 </target>
1690
1691 <!-- 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.
1692 The test for whether we need it assumes we won't be trying to compile GS3 against Java versions less than 1.4. -->
1693 <target name="configure-java-version" depends="init"
1694 description="Activates or deactivates some jar libraries as needed depending on your java version">
1695
1696 <available property="have.xalan.jar" file="${web.lib}/xalan.jar"/>
1697 <condition property="need.xalan.jar">
1698 <or>
1699 <not><equals arg1="1.4" arg2="${java.specification.version}"/></not>
1700 </or>
1701 </condition>
1702
1703 <!-- if they have xalan.jar but dont need it -->
1704 <if>
1705 <bool>
1706 <and>
1707 <isset property="have.xalan.jar"/>
1708 <not><isset property="need.xalan.jar"/></not>
1709 </and>
1710 </bool>
1711 <antcall target="deactivate-xalan-jar"/>
1712 </if>
1713
1714 <!-- if they need xalan.jar but dont have it -->
1715 <if>
1716 <bool>
1717 <and>
1718 <not><isset property="have.xalan.jar"/></not>
1719 <isset property="need.xalan.jar"/>
1720 </and>
1721 </bool>
1722 <antcall target="activate-xalan-jar"/>
1723 </if>
1724
1725 </target>
1726
1727 <target name="activate-xalan-jar">
1728 <echo>activating xalan.jar</echo>
1729 <copy file="${web.lib}/xalan.jar.tmp" tofile="${web.lib}/xalan.jar"/>
1730 <if>
1731 <bool>
1732 <and>
1733 <isset property="current.os.ismac"/>
1734 <available file="${catalina.home}/common/endorsed" type="dir"/>
1735 </and>
1736 </bool>
1737 <copy file="${web.lib}/xalan.jar.tmp" tofile="${catalina.home}/common/endorsed/xalan.jar"/>
1738 </if>
1739 </target>
1740
1741 <target name="deactivate-xalan-jar">
1742 <echo>deactivating xalan.jar</echo>
1743 <delete file="${web.lib}/xalan.jar"/>
1744 <!-- should we be deleting common/endorsed/xalan.jar on mac?? -->
1745 </target>
1746
1747
1748 <target name="prepare-collections" depends="init"
1749 description="Unpack all the collections from their svn zipped versions">
1750 <property name="collect.dir" value="${web.home}/sites/localsite/collect"/>
1751 <property name="index-and-archives.zip" value="index-and-archives.zip"/>
1752
1753 <echo message="Installing collections ..."/>
1754 <!-- collections requiring jni -->
1755 <echo message="checkpt NEXT"/>
1756 <if>
1757 <bool>
1758 <istrue value="${with.jni}"/>
1759 </bool>
1760 <antcall target="gs2mgdemo-install"/>
1761 </if>
1762 <echo message="checkpt 1"/>
1763 <if>
1764 <bool>
1765 <istrue value="${with.jni}"/>
1766 </bool>
1767 <antcall target="gs2mgppdemo-install"/>
1768 </if>
1769 <!-- pure java ones -->
1770 <echo message="checkpt 1"/>
1771 <antcall target="gberg-install"/>
1772 <echo message="checkpt 1"/>
1773 <antcall target="lucene-jdbm-demo-install"/>
1774 </target>
1775
1776 <target name="gs2mgdemo-prepare" if="collect.dir">
1777 <property name="gs2mgdemo.dir" value="${collect.dir}/gs2mgdemo"/>
1778
1779 <condition property="gs2mgdemo.present">
1780 <and>
1781 <available file="${gs2mgdemo.dir}/${index-and-archives.zip}"/>
1782 </and>
1783 </condition>
1784 </target>
1785
1786 <target name="gs2mgdemo-install" if="gs2mgdemo.present" depends="gs2mgdemo-prepare">
1787 <unzip dest="${gs2mgdemo.dir}" src="${gs2mgdemo.dir}/${index-and-archives.zip}" />
1788 <echo>collection gs2mgdemo installed</echo>
1789 </target>
1790
1791 <target name="gs2mgppdemo-prepare" if="collect.dir">
1792 <property name="gs2mgppdemo.dir" value="${collect.dir}/gs2mgppdemo"/>
1793
1794 <condition property="gs2mgppdemo.present">
1795 <and>
1796 <available file="${gs2mgppdemo.dir}/${index-and-archives.zip}"/>
1797 </and>
1798 </condition>
1799 </target>
1800
1801 <target name="gs2mgppdemo-install" if="gs2mgppdemo.present" depends="gs2mgppdemo-prepare">
1802 <unzip dest="${gs2mgppdemo.dir}" src="${gs2mgppdemo.dir}/${index-and-archives.zip}" />
1803 <echo>collection gs2mgppdemo installed</echo>
1804 </target>
1805
1806 <target name="gberg-prepare" if="collect.dir">
1807 <property name="gberg.dir" value="${collect.dir}/gberg"/>
1808 <available file="${gberg.dir}/index/index.zip" property="gberg.present"/>
1809 </target>
1810
1811 <target name="gberg-install" if="gberg.present" depends="gberg-prepare">
1812 <unzip dest="${gberg.dir}/index" src="${gberg.dir}/index/index.zip"/>
1813 <echo>collection gberg installed</echo>
1814 </target>
1815
1816 <target name="lucene-jdbm-demo-prepare" if="collect.dir">
1817 <property name="lucene-jdbm-demo.dir" value="${collect.dir}/lucene-jdbm-demo"/>
1818 <available file="${lucene-jdbm-demo.dir}/${index-and-archives.zip}" property="lucene-jdbm-demo.present"/>
1819 </target>
1820
1821 <target name="lucene-jdbm-demo-install" if="lucene-jdbm-demo.present" depends="lucene-jdbm-demo-prepare">
1822 <unzip dest="${lucene-jdbm-demo.dir}" src="${lucene-jdbm-demo.dir}/${index-and-archives.zip}"/>
1823 <echo>collection lucene-jdbm-demo installed</echo>
1824 </target>
1825
1826
1827 <target name="install-solr-ext" depends="init" >
1828 <exec executable="ant.bat" osfamily="windows" dir="${solr-ext.home}" spawn="false" failonerror="true">
1829 <arg value="add-service"/>
1830 </exec>
1831 <exec executable="ant" os="${os.unix}" dir="${solr-ext.home}" spawn="false" failonerror="true">
1832 <arg value="add-service"/>
1833 </exec>
1834 <antcall target="solr-jdbm-demo-install"/>
1835 </target>
1836
1837 <target name="solr-jdbm-demo-prepare" if="collect.dir">
1838 <property name="solr-jdbm-demo.dir" value="${collect.dir}/solr-jdbm-demo"/>
1839 <available file="${solr-jdbm-demo.dir}/${index.zip}" property="solr-jdbm-demo.present"/>
1840 </target>
1841
1842 <target name="solr-jdbm-demo-install" if="solr-jdbm-demo.present" depends="solr-jdbm-demo-prepare">
1843 <unzip dest="${solr-jdbm-demo.dir}" src="${solr-jdbm-demo.dir}/${index.zip}"/>
1844 <echo>collection solr-jdbm-demo installed</echo>
1845 </target>
1846
1847 <target name="install-webswing-ext" depends="init" >
1848 <exec executable="ant.bat" osfamily="windows" dir="${webswing-ext.home}" spawn="false" failonerror="true">
1849 <arg value="-Dweb.home=${web.home}"/>
1850 <arg value="-Dweb.writablehome=${web.writablehome}"/>
1851 <arg value="add-extension"/>
1852 </exec>
1853 <exec executable="ant" os="${os.unix}" dir="${webswing-ext.home}" spawn="false" failonerror="true">
1854 <arg value="-Dweb.home=${web.home}"/>
1855 <arg value="-Dweb.writablehome=${web.writablehome}"/>
1856 <arg value="add-extension"/>
1857 </exec>
1858 </target>
1859
1860 <target name="install-usersDB">
1861 <property name="updateDB.dir" value="${web.home}/updateDB"/>
1862 <condition property="updateDB.dir.exists">
1863 <available file="${updateDB.dir}" type="dir" />
1864 </condition>
1865
1866 <if>
1867 <bool>
1868 <not><istrue value="${updateDb.dir.exists}"/></not>
1869 </bool>
1870
1871 <untar compression="gzip"
1872 src="${web.home}/etc/usersDB.tar.gz"
1873 dest="${web.home}/etc"/>
1874 </if>
1875 </target>
1876
1877 <!-- Until 64 bit Linux and Mac (Lion) machines can generate a working IsisGdl,
1878 use the ones generated on a 32 bit Linux and Mac (Leopard), respectively
1879 -->
1880 <target name="get-isisgdl" if="${current.os.isunix}">
1881 <exec executable="uname" dir="${basedir}" failonerror="false"
1882 outputproperty="uname.val">
1883 <arg value="-m"/>
1884 </exec>
1885
1886 <if>
1887 <!-- as the syntax below copies the IsidGdl binary into the gs2build directory
1888 only want to run the commend if collection.building.enabled -->
1889 <bool>
1890 <and>
1891 <istrue value="${collection.building.enabled}" />
1892 <equals arg1="${uname.val}" arg2="x86_64"/>
1893 </and>
1894 </bool>
1895 <echo>Bitness: ${uname.val}</echo>
1896 <if><bool><contains string="${os.bin.dir}" substring="darwin" casesensitive="false"/></bool>
1897 <exec executable="uname" dir="${basedir}" failonerror="false"
1898 outputproperty="darwin.kernel.version">
1899 <arg value="-r"/>
1900 </exec>
1901
1902 <echo>darwin kernel version: ${darwin.kernel.version}</echo>
1903 <!-- up to high sierra/kernel (version 17.x) us IsisGdl.macleopard
1904 From Mojave onwards, we can use the Mojave generated IsisGdl.mac64mojave -->
1905 <if>
1906 <bool><matches string="${darwin.kernel.version}" pattern="^([0-9]|1[0-7])\."/></bool>
1907 <property name="mac.isisgdl.suffix" value="macleopard"/>
1908 <else>
1909 <property name="mac.isisgdl.suffix" value="mac64mojave"/>
1910 </else>
1911 </if>
1912
1913
1914 <!--<get src="${gsorg.root}/caveat-emptor/IsisGdl.macleopard"
1915 dest="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl"/>-->
1916 <exec executable="wget" failonerror="true">
1917 <arg value="-P"/>
1918 <arg value="${basedir}/gs2build/bin/${os.bin.dir}"/>
1919 <arg value="--no-check-certificate"/>
1920 <arg value="${gsorg.root}/caveat-emptor/IsisGdl.${mac.isisgdl.suffix}"/>
1921 </exec>
1922 <move file="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl.${mac.isisgdl.suffix}"
1923 tofile="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl"/>
1924 </if>
1925 <if><bool><contains string="${os.bin.dir}" substring="linux" casesensitive="false"/></bool>
1926 <!--<get src="${gsorg.root}/caveat-emptor/IsisGdl.bin32"
1927 dest="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl"/>-->
1928 <exec executable="wget" failonerror="true">
1929 <arg value="-P"/>
1930 <arg value="${basedir}/gs2build/bin/${os.bin.dir}"/>
1931 <arg value="--no-check-certificate"/>
1932 <arg value="${gsorg.root}/caveat-emptor/IsisGdl.bin32"/>
1933 </exec>
1934 <move file="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl.bin32"
1935 tofile="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl"/>
1936 </if>
1937 <chmod file="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl" perm="755"/>
1938 </if>
1939 </target>
1940
1941 <target name="set-perl-shebangs" depends="perl-for-building">
1942 <if>
1943 <bool>
1944 <and><isset property="perl.path"/>
1945 <not><equals arg1="${perl.path}" arg2=""/></not>
1946 </and>
1947 </bool>
1948
1949 <if><bool><istrue value="${current.os.iswindows}"/></bool>
1950 <property name="perl.exec" value="${perl.path}perl.exe"/>
1951 <else>
1952 <property name="perl.exec" value="${perl.path}perl"/>
1953 </else>
1954 </if>
1955
1956 <!--<echo>**** PERLPATH: ${perl.path}</echo>-->
1957 <echo>Setting perl shebangs to Perl Exec: ${perl.exec}</echo>
1958
1959 <!-- set the shebangs in the cgi files to point to the correct perlpath -->
1960 <if>
1961 <bool><not><equals arg1="${web.home}" arg2="${web.writablehome}"></equals></not></bool>
1962 <mkdir dir="${web.writablehome}"/>
1963 <copy file="${full.web.dir}/WEB-INF/cgi/gliserver.pl" tofile="${web.writablehome}/WEB-INF/cgi/gliserver.pl" overwrite="true"/>
1964 <copy file="${full.web.dir}/WEB-INF/cgi/metadata-server.pl" tofile="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" overwrite="true"/>
1965 <copy file="${full.web.dir}/WEB-INF/cgi/checksum.pl" tofile="${web.writablehome}/WEB-INF/cgi/checksum.pl" overwrite="true"/>
1966 </if>
1967
1968 <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/gliserver.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1969 <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1970 <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/checksum.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1971 <else>
1972 <echo>WARNING: perl.path is empty. Unable to set the shebangs in the perl files in ${web.writablehome}/WEB-INF/cgi</echo>
1973 </else>
1974 </if>
1975 </target>
1976
1977 <target name="configure-web" depends="init,perl-for-building"
1978 description="Configure only the web app config files">
1979 <!-- we want a unix path in the global.properties file -->
1980 <pathconvert targetos="unix" property="src.gsdl3.home.unix">
1981 <path path="${web.home}"/>
1982 </pathconvert>
1983 <pathconvert targetos="unix" property="src.gsdl3.writablehome.unix">
1984 <path path="${web.writablehome}"/>
1985 </pathconvert>
1986
1987 <antcall target="set-perl-shebangs" inheritAll="true" />
1988
1989 <filter token="gsdlhome" value="${gs2build.home}"/>
1990 <filter token="gsdlhomequoted" value="&quot;${gs2build.home}&quot;"/>
1991 <filter token="gsdl3srchome" value="${basedir}"/>
1992 <filter token="gsdl3srchomequoted" value="&quot;${basedir}&quot;"/>
1993 <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
1994 <filter token="gsdl3homequoted" value="&quot;${src.gsdl3.home.unix}&quot;"/>
1995 <filter token="gsdl3writablehome" value="${src.gsdl3.writablehome.unix}"/>
1996 <filter token="gsdl3version" value="${app.version}"/>
1997 <filter token="revproxy.protocol" value="${revproxy.protocol}"/>
1998 <filter token="revproxy.domain" value="${revproxy.domain}"/>
1999 <filter token="revproxy.opt_port" value="${revproxy.opt_port}"/>
2000 <filter token="revproxy.context" value="${revproxy.context}"/>
2001 <filter token="server.protocols" value="${server.protocols}"/>
2002 <filter token="default.server.protocol" value="${default.server.protocol}"/>
2003 <filter token="tomcat.server" value="${tomcat.server}"/>
2004 <filter token="default.tomcat.port" value="${default.tomcat.port}"/>
2005 <filter token="localhost.server.http" value="${localhost.server.http}"/>
2006 <filter token="localhost.port.http" value="${localhost.port.http}"/>
2007 <filter token="tomcat.port.https" value="${tomcat.port.https}"/>
2008 <filter token="restrict.http.to.local" value="${restrict.http.to.local}"/>
2009 <filter token="tomcat.server.IPregex" value="${tomcat.server.IPregex}"/>
2010
2011 <filter token="greenstone.context" value="${greenstone.context}"/>
2012 <filter token="solr.context" value="${solr.context}"/>
2013 <filter token="derbyserver" value="${derby.server}"/>
2014 <filter token="derbyserver.port" value="${derby.server.port}"/>
2015 <filter token="perlpath" value="${escaped.perl.path}"/>
2016 <filter token="defaultservletpath" value="${greenstone.default.servlet}"/>
2017 <filter token="disable.collection.building" value="${disable.collection.building}"/>
2018 <copy file="${basedir}/resources/cgi/gsdl3site.cfg.in" tofile="${web.writablehome}/WEB-INF/cgi/gsdl3site.cfg" filtering="true" overwrite="true"/>
2019 <copy file="${basedir}/resources/web/global.properties.in" tofile="${web.writableclasses}/global.properties" filtering="true" overwrite="true"/>
2020 <copy file="${basedir}/resources/web/log4j.properties.in" tofile="${web.writableclasses}/log4j.properties" filtering="true" overwrite="true"/>
2021 <if>
2022 <bool><istrue value="${gsdl3home.isreadonly}"/></bool>
2023 <!-- uncomment the writablehome properties -->
2024 <rsr verbosity="1" file="${web.writableclasses}/global.properties" pattern="^#gsdl3\.(writable{1})?home" replacement="gsdl3.$1home" />
2025 </if>
2026 <chmod file="${web.writableclasses}/global.properties" perm="664"/>
2027 <chmod file="${web.writableclasses}/log4j.properties" perm="664"/>
2028
2029 <copy file="${basedir}/resources/iiif/cantaloupe.properties.in" tofile="${basedir}/cantaloupe.properties" filtering="true" overwrite="true"/>
2030 <chmod file="${basedir}/cantaloupe.properties" perm="664"/>
2031 </target>
2032
2033 <target name="compile-web" depends="needs-gs3-devel,init">
2034 <javac srcdir="${web.classes}"
2035 destdir="${web.classes}"
2036 includeantruntime="${compile.includeantruntime}"
2037 debug="${compile.debug}"
2038 deprecation="${compile.deprecation}"
2039 optimize="${compile.optimize}"
2040 encoding="${compile.encoding}">
2041 <compilerarg line="${compile.javac.flags}"/>
2042 <classpath><path refid="compile.classpath"/></classpath>
2043 </javac>
2044 </target>
2045
2046 <target name="compile-classpath-jars" depends="needs-gs3-devel,init">
2047 <if><bool><available file="admin/cp.mf"/></bool>
2048 <jar destfile="admin/cp.jar" manifest="admin/cp.mf"/>
2049 </if>
2050 <if><bool><available file="${lib.java}/cp.mf"/></bool>
2051 <jar destfile="${lib.java}/cp.jar" manifest="${lib.java}/cp.mf"/>
2052 </if>
2053 <if><bool><available file="${lib.jni}/cp.mf"/></bool>
2054 <jar destfile="${lib.jni}/cp.jar" manifest="${lib.jni}/cp.mf"/>
2055 </if>
2056 <if><bool><available file="${web.lib}/cp.mf"/></bool>
2057 <jar destfile="${web.lib}/cp.jar" manifest="${web.lib}/cp.mf"/>
2058 </if>
2059 <jar destfile="cp.jar">
2060 <manifest>
2061 <attribute name="Class-Path" value="server.jar admin/cp.jar lib/java/cp.jar lib/jni/cp.jar web/WEB-INF/lib/cp.jar"/>
2062 </manifest>
2063 </jar>
2064 </target>
2065
2066 <target name="clean-classpath-jars" depends="init">
2067 <delete file="admin/cp.jar"/>
2068 <delete file="${lib.java}/cp.jar"/>
2069 <delete file="${lib.jni}/cp.jar"/>
2070 <delete file="${web.lib}/cp.jar"/>
2071 <delete file="cp.jar"/>
2072 </target>
2073
2074
2075 <target name="svnupdate-web" unless="nosvn.mode">
2076 <exec executable="svn">
2077 <arg line="${global-svn-args}"/>
2078 <arg value="update"/>
2079 <arg value="${web.writablehome}"/>
2080 <arg value="-r"/><arg value="${branch.revision}"/>
2081 </exec>
2082 </target>
2083
2084 <target name="update-web" depends="init,svnupdate-web,configure-web"
2085 description="update only the web stuff (config files)"/>
2086
2087
2088 <!--
2089 Newer versions of perl need CGI.pm placed in web/WEB-INF/cgi.
2090 We have a CGIModule.tar.gz in common-src/cgi-bin, that we can use for linux (unix) systems.
2091
2092 - from perl5.22, CGI.pm is not included, but GS3 needs it:
2093 https://stackoverflow.com/questions/45434990/why-does-this-code-have-issues-with-the-cgi-module
2094 - bash line to get perl version: https://www.unix.com/shell-programming-and-scripting/18267-version-perl-installed-my-system.html
2095 - run bash command using pipes with ant: https://stackoverflow.com/questions/1187402/ant-run-command-with-pipes
2096 - single quotes in XML use &apos; https://stackoverflow.com/questions/7388695/how-can-i-escape-double-quotes-in-ant
2097 - islessthan and isgreaterthan ant bool conditionals: https://stackoverflow.com/questions/7616159/apache-ant-less-than
2098 -->
2099 <condition property="cgimodule.exists">
2100 <and>
2101 <available file="${web.home}/WEB-INF/cgi" type="dir"/> <!--Unavailable for custom web.home-->
2102 <available file="${web.home}/WEB-INF/cgi/CGI.pm" type="file"/>
2103 <available file="${web.home}/WEB-INF/cgi/Fh.pm" type="file"/>
2104 <available file="${web.home}/WEB-INF/cgi/CGI" type="dir"/>
2105 </and>
2106 </condition>
2107
2108 <target name="unpack-cgimodule" if="current.os.isunix" unless="cgimodule.exists">
2109 <exec executable="bash" outputproperty="perl.major.version">
2110 <arg value="-c"/>
2111 <arg line='"perl -v | awk &apos;/This/ {print $4}&apos; | sed -e &apos;s/,//&apos;"'/>
2112 </exec>
2113 <exec executable="bash" outputproperty="perl.min.version">
2114 <arg value="-c"/>
2115 <arg line='"perl -v | awk &apos;/This/ {print $6}&apos; | sed -e &apos;s/,//&apos;"'/>
2116 </exec>
2117
2118 <if>
2119 <bool>
2120 <or>
2121 <isgreaterthan arg1="${perl.major.version}" arg2="5"/>
2122 <and>
2123 <equals arg1="${perl.major.version}" arg2="5" trim="true"/>
2124 <islessthan arg1="${perl.minor.version}" arg2="22"/>
2125 </and>
2126 </or>
2127 </bool>
2128 <echo message="Unpacking the CGIModule needed for your perl version: ${perl.major.version}.${perl.min.version}" />
2129
2130 <untar compression="gzip"
2131 src="${common.src.home}/cgi-bin/CGIModule.tar.gz"
2132 dest="${web.home}/WEB-INF/cgi"/>
2133 <move todir="${web.home}/WEB-INF/cgi" failonerror="false">
2134 <!-- This fileset moves *contents* of directory CGIModule into destination dir web.home -->
2135 <fileset dir="${web.home}/WEB-INF/cgi/CGIModule"/>
2136 </move>
2137 <delete dir="${web.home}/WEB-INF/cgi/CGIModule"/>
2138
2139 </if>
2140 </target>
2141
2142 <!-- ============ Targets concerned with https certification ================ -->
2143
2144 <target name="setup-https-cert-info">
2145 <echo>
2146 *********************************************************************
2147 NOTE TO OBTAINING A TLS (SSL) CERTIFICATE FOR HTTPS
2148 *********************************************************************
2149 A signed certificate is needed for your GS server to serve pages over https.
2150 This target will attempt to obtain a certificate for you from the official and free Certificate Authority Lets Encrypt.
2151 However, a certificate can only be obtained if you have admin/sudo permissions on this machine that you are installing Greenstone on.
2152
2153 Note that:
2154 * 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.
2155 * 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.
2156 </echo>
2157 </target>
2158
2159
2160 <target name="https-conditions-set">
2161 <input addproperty="https.conditions.ok" validargs="y,n">
2162 To run this target, ensure you have:
2163 * (if on unix) sudo permissions. Enter the sudo password if prompted.
2164 * (if on windows) sufficient privileges to run the included tomcat on port 80.
2165 * nothing running on port 80 when you run this target
2166 * edited the build.properties file with
2167 - tomcat.server set to the/a domain name of your server
2168 - 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)
2169 - tomcat.port.https set to a valid port number not yet in use
2170 - keystore.pass set to a password for the certification process
2171 * read the Lets Encrypt Subscriber Agreement at https://letsencrypt.org/repository/
2172 If any of the above is not possible, quit this target. Continue [y/n]?
2173 </input>
2174
2175 <condition property="quit.https.setup">
2176 <equals arg1="n" arg2="${https.conditions.ok}"/>
2177 </condition>
2178
2179 <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>
2180 </target>
2181
2182
2183 <target name="setup-https-cert" depends="setup-https-cert-info,https-conditions-set">
2184 <if><bool><not><matches string="${server.protocols}" pattern="https"/></not></bool>
2185 <fail>To setup https certification, the server.protocols property in file build.properties must contain 'https'</fail>
2186 </if>
2187
2188 <input addproperty="https.cert.email">Enter an email that Let's Encrypt, the certification authority, can send any important notifications to</input>
2189 <input addproperty="https.other.domains">Besides tomcat.server=${tomcat.server}, enter a comma separated list of additional domains to support, if any</input>
2190 <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>
2191 <if>
2192 <bool><equals arg1="y" arg2="${https.cert.agree}"/></bool>
2193
2194 <condition property="https.cert.domains" value="${tomcat.server},${https.other.domains}" else="${tomcat.server}">
2195 <and>
2196 <isset property="https.other.domains" />
2197 <not><matches string="${https.other.domains}" pattern="^\s*$"/></not>
2198 </and>
2199 </condition>
2200
2201 <input addproperty="https.do.cert" validargs="y,n">
2202 You've agreed to the Let's Encrypt TOS with
2203 - email: ${https.cert.email}
2204 - domains: ${https.cert.domains}
2205 Looks okay? [y/n]
2206 </input>
2207 </if>
2208
2209 <if><bool><equals arg1="n" arg2="${https.do.cert}"/></bool>
2210 <echo>Not proceeding with https certification for the Greenstone 3 web server</echo>
2211 <else>
2212 <echo>Proceeding...</echo>
2213 <if><bool><istrue value="${current.os.iswindows}"/></bool>
2214 <antcall target="setup-https-cert-windows">
2215 <param name="https.cert.renewal" value=""/><!-- for cert issuance, there are none of the additional parameters specific to cert renewal -->
2216 </antcall>
2217 </if>
2218 <if><bool><istrue value="${current.os.isunixnotmac}"/></bool>
2219 <antcall target="setup-https-cert-linux"/>
2220 </if>
2221 <if><bool><istrue value="${current.os.ismac}"/></bool>
2222 <antcall target="setup-https-cert-mac"/>
2223 </if>
2224 </else>
2225 </if>
2226
2227 </target>
2228
2229
2230 <target name="setup-https-cert-windows">
2231
2232 <echo>********** The included tomcat will be stopped, then restarted on port 80 and stopped again</echo>
2233
2234 <!-- create folder packages\tomcat\webapps\ROOT\.well-known\acme-challenge -->
2235 <mkdir dir="${packages.home}/tomcat/webapps/ROOT/.well-known/acme-challenge"/>
2236 <mkdir dir="${packages.home}/tomcat/conf/https_cert"/>
2237
2238 <!--
2239 For Windows, Greenstone can generate the account and domain keys with the openSSL we compiled up ourselves
2240 and put on SVN (at GS3/bin/windows/openssl) rather than let ZeroSSL generate these keys for the user.
2241 Letting Greenstone generate the keys may be considered more trustworthy by the user than letting a 3rd
2242 party do so. See https://zerossl.com/usage.html#First_time_run_and_regular_use for OpenSSL commands
2243 If we don't generate the keys ourselves with our OpenSSL, then ZeroSSL will do so automatically in the
2244 call to le64/32.exe further below, as it's passed in the flag generate-missing.
2245 -->
2246 <!-- We generate the account key named "privkey.key" in ${packages.home}\tomcat\conf\https_cert -->
2247 <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
2248 <arg value="/c" />
2249 <arg value="openssl.exe" />
2250 <arg value="genrsa" />
2251 <arg value="-out" /><arg value="${packages.home}\tomcat\conf\https_cert\privkey.key" /><arg value="4096" />
2252 </exec>
2253
2254 <!-- Also generate the domain key (for csr-key parameter to zeroSSL's le.exe)
2255 ${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key
2256 Using 2048 instead of 4096 bits for this. See https://zerossl.com/usage.html#First_time_run_and_regular_use
2257 -->
2258 <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
2259 <arg value="/c" />
2260 <arg value="openssl.exe" />
2261 <arg value="genrsa" />
2262 <arg value="-out" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key" /><arg value="2048" />
2263 </exec>
2264
2265 <!-- stop the included tomcat (also stopping derby and solr) -->
2266 <antcall target="stop" />
2267
2268 <!-- rerun tomcat on port 80
2269 See https://ant.apache.org/manual/Tasks/antcall.html -->
2270 <antcall target="start">
2271 <param name="localhost.port.http" value="80"/>
2272 <param name="default.tomcat.port" value="80"/>
2273 <param name="local.http.url" value="http://${localhost.server.http}"/><!-- For port 80 over http, leave out port number in URL -->
2274 <param name="http.address.restriction" value=""/><!-- don't prevent public access over http of port 80 -->
2275 <param name="https.comment.out.start" value="${comment.start}"/>
2276 <param name="https.comment.out.end" value="${comment.end}"/>
2277 </antcall>
2278
2279 <!-- get the certificate: use zerossl for windows
2280 Download from https://github.com/do-know/Crypt-LE/releases,
2281 For licence see https://github.com/do-know/Crypt-LE/
2282 Usage instructions at https://zerossl.com/usage.html
2283
2284 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}"
2285
2286 which generates a .pfx file with the same name as the PEM certificate (.crt param below)
2287 .pfx vs .p12: https://stackoverflow.com/questions/6819079/convert-pfx-format-to-p12
2288
2289 In this case "fullchain_and_prvtkey.pfx" is generated, which is the windows value of ${keystore.file} property
2290
2291 Helpful for debugging: https://stackoverflow.com/questions/10302489/ant-script-have-exec-tag-dump-out-entire-command-line
2292 -->
2293 <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}" spawn="false">
2294 <arg value="/c" />
2295 <arg value="le${os.bitness}" />
2296 <arg value="--key" /><arg value="${packages.home}\tomcat\conf\https_cert\privkey.key" />
2297 <arg value="--csr" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.csr" />
2298 <arg value="--csr-key" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key" />
2299 <!--<arg value="==crt" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.crt" />-->
2300 <arg value="--crt" /><arg value="${packages.home}\tomcat\conf\https_cert\fullchain_and_prvtkey.crt" />
2301 <arg value="--domains" /><arg value="${https.cert.domains}" />
2302 <arg value="--path" /><arg value="${packages.home}\tomcat\webapps\ROOT\.well-known\acme-challenge" />
2303 <arg value="--generate-missing" />
2304 <arg value="--unlink" />
2305 <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 -->
2306 <!--<arg value="==export-pfx" /><arg value="${keystore.pass}" />
2307 <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-->
2308 <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. -->
2309 </exec>
2310
2311 <!-- stop the tomcat running on port 80 -->
2312 <antcall target="stop">
2313 <param name="localhost.port.http" value="80"/>
2314 <param name="default.tomcat.port" value="80"/>
2315 <param name="local.http.url" value="http://${localhost.server.http}"/><!-- For port 80 over http, leave out port number in URL -->
2316 <param name="http.address.restriction" value=""/>
2317 <param name="https.comment.out.start" value="${comment.start}"/>
2318 <param name="https.comment.out.end" value="${comment.end}"/>
2319 </antcall>
2320
2321 <!-- Use OpenSSL instead of ZeroSSL to convert the certificate to the .pfx format that tomcat likes, using this cmd:
2322 GS3/bin/windows/openssl/bin/openssl.exe pkcs12 -inkey domain.key -in domain.crt -passin pass:pwd -passout pass:pwd -export -out ${keystore.file}
2323 GS3/bin/windows/openssl/bin/openssl.exe pkcs12 -inkey domain.key -in domain.crt -password pass:pwd -export -out ${keystore.file}
2324 where on windows, keystore.file = fullchain_and_prvtkey.pfx
2325 -->
2326 <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
2327 <arg value="/c" />
2328 <arg value="openssl.exe" />
2329 <arg value="pkcs12" />
2330 <arg value="-inkey" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key" />
2331 <arg value="-in" /><arg value="${packages.home}\tomcat\conf\https_cert\fullchain_and_prvtkey.crt" />
2332 <arg value="-export" />
2333 <arg value="-out" /><arg value="${packages.home}\tomcat\conf\https_cert\${keystore.file}" />
2334 <arg value="-name"/><arg value="greenstone3-tomcat"/><!-- See https://stackoverflow.com/questions/808669/convert-a-cert-pem-certificate-to-a-pfx-certificate -->
2335 <arg value="-password"/><arg value="pass:${keystore.pass}"/>
2336 </exec>
2337
2338 </target>
2339
2340
2341 <!-- On Mac as on Linux, we need sudo permissions to setup https certification.
2342 But unlike on Linux, on Mac we only need to sudo when running tomcat on port 80
2343 and when stopping tomcat running on port 80. But we don't need to sudo on a Mac when calling le.pl.
2344 This also means all the files in https_cert have the correct (user, not root) permissions.
2345 -->
2346 <target name="setup-https-cert-mac">
2347
2348 <echo>********** The included tomcat will be stopped, then restarted on port 80 and stopped again</echo>
2349
2350 <!-- create folder packages\tomcat\webapps\ROOT\.well-known\acme-challenge -->
2351 <mkdir dir="${packages.home}/tomcat/webapps/ROOT/.well-known/acme-challenge"/>
2352 <mkdir dir="${packages.home}/tomcat/conf/https_cert"/>
2353
2354 <!--
2355 See comments under setup-https-cert-WINDOWS
2356 -->
2357 <!-- We generate the account key named "privkey.key" in ${packages.home}\tomcat\conf\https_cert -->
2358 <if><bool><not><available file="${packages.home}/tomcat/conf/https_cert/privkey.key"/></not></bool>
2359 <exec executable="openssl" osfamily="mac" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
2360 <arg value="genrsa" />
2361 <arg value="-out" /><arg value="${packages.home}/tomcat/conf/https_cert/privkey.key" /><arg value="4096" />
2362 </exec>
2363 </if>
2364
2365 <!-- Also generate the domain key (for csr-key parameter to zeroSSL's le.pl)
2366 ${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key
2367 Using 2048 instead of 4096 bits for this. See https://zerossl.com/usage.html#First_time_run_and_regular_use
2368 -->
2369 <if><bool><not><available file="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.key"/></not></bool>
2370 <exec executable="openssl" osfamily="mac" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
2371 <arg value="genrsa" />
2372 <arg value="-out" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.key" /><arg value="2048" />
2373 </exec>
2374 </if>
2375
2376 <!-- stop the included tomcat (also stopping derby and solr) -->
2377 <antcall target="stop" />
2378
2379 <!-- rerun tomcat on port 80
2380 See https://ant.apache.org/manual/Tasks/antcall.html -->
2381 <antcall target="start">
2382 <param name="sudo.or.not" value="/usr/bin/sudo" />
2383 <param name="localhost.port.http" value="80"/>
2384 <param name="default.tomcat.port" value="80"/>
2385 <param name="local.http.url" value="http://${localhost.server.http}"/><!-- For port 80 over http, leave out port number in URL -->
2386 <param name="http.address.restriction" value=""/><!-- don't prevent public access over http of port 80 -->
2387 <param name="https.comment.out.start" value="${comment.start}"/>
2388 <param name="https.comment.out.end" value="${comment.end}"/>
2389 </antcall>
2390
2391 <!-- get the certificate: use zerossl's le.pl compiled up for Mac.
2392 For further notes, see under setup-https-cert-WINDOWS
2393 -->
2394
2395 <exec executable="perl" osfamily="mac" dir="${gs2build.home}/perllib/cpan/Crypt/LE/bin" spawn="false">
2396 <env key="PERL5LIB" value="${gs2build.home}/perllib/cpan${path.separator}${gs2build.home}/perllib/cpan/perl-5.18"/>
2397 <arg value="-S" />
2398 <arg value="${gs2build.home}/perllib/cpan/Crypt/LE/bin/le.pl" />
2399 <arg value="--key" /><arg value="${packages.home}/tomcat/conf/https_cert/privkey.key" />
2400 <arg value="--csr" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.csr" />
2401 <arg value="--csr-key" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.key" />
2402 <!--<arg value="==crt" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.crt" />-->
2403 <arg value="--crt" /><arg value="${packages.home}/tomcat/conf/https_cert/fullchain_and_prvtkey.crt" />
2404 <arg value="--domains" /><arg value="${https.cert.domains}" />
2405 <arg value="--path" /><arg value="${packages.home}/tomcat/webapps/ROOT/.well-known/acme-challenge" />
2406 <arg value="--generate-missing" />
2407 <arg value="--unlink" />
2408 <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 -->
2409 <!--<arg value="==export-pfx" /><arg value="${keystore.pass}" />
2410 <arg value="==tag-pfx" /><arg value="greenstone3-tomcat" />--><!-- not sure if this generates a keystore filename with ext .p12 or .pfx for Macs -->
2411 <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. -->
2412 </exec>
2413
2414 <!-- stop the tomcat running on port 80 -->
2415 <antcall target="stop">
2416 <param name="sudo.or.not" value="/usr/bin/sudo" />
2417 <param name="localhost.port.http" value="80"/>
2418 <param name="default.tomcat.port" value="80"/>
2419 <param name="local.http.url" value="http://${localhost.server.http}"/>
2420 <param name="http.address.restriction" value=""/>
2421 <param name="https.comment.out.start" value="${comment.start}"/>
2422 <param name="https.comment.out.end" value="${comment.end}"/>
2423 </antcall>
2424
2425 <!-- Use OpenSSL instead of ZeroSSL to convert the certificate to the .pfx format that tomcat likes, using this cmd:
2426 GS3/bin/windows/openssl/bin/openssl.exe pkcs12 -inkey domain.key -in domain.crt -passin pass:pwd -passout pass:pwd -export -out ${keystore.file}
2427 GS3/bin/windows/openssl/bin/openssl.exe pkcs12 -inkey domain.key -in domain.crt -password pass:pwd -export -out ${keystore.file}
2428 where on windows, keystore.file = fullchain_and_prvtkey.pfx
2429 -->
2430 <exec executable="openssl" osfamily="mac" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
2431 <arg value="pkcs12" />
2432 <arg value="-inkey" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.key" />
2433 <arg value="-in" /><arg value="${packages.home}/tomcat/conf/https_cert/fullchain_and_prvtkey.crt" />
2434 <arg value="-export" />
2435 <arg value="-out" /><arg value="${packages.home}/tomcat/conf/https_cert/${keystore.file}" />
2436 <arg value="-name"/><arg value="greenstone3-tomcat"/><!-- See https://stackoverflow.com/questions/808669/convert-a-cert-pem-certificate-to-a-pfx-certificate -->
2437 <arg value="-password"/><arg value="pass:${keystore.pass}"/>
2438 </exec>
2439
2440 </target>
2441
2442
2443
2444 <target name="setup-https-cert-linux">
2445 <!-- Running as
2446 ./certbot-auto certonly ==standalone ==preferred-challenges http ==email EMAIL -d DOMAINS
2447 expects input from stdin to accept (A) ToS and say Yes (Y) to sharing email.
2448 We can run in non-interactive mode as the user has at this stage already agreed
2449 to LetsEncrypt's Terms of Service and provided an email address.
2450 -->
2451 <exec executable="/bin/bash" dir="${basedir}/bin/${os.bin.dir}" failonerror="true">
2452 <arg value="./certbot-auto"/>
2453 <arg value="certonly"/>
2454 <arg line="${https.testing}"/><!-- https://stackoverflow.com/questions/11840284/pass-arguments-to-apache-ant-exec-task-based-on-the-variables-value -->
2455 <arg value="--standalone"/>
2456 <arg value="--non-interactive"/>
2457 <arg value="--agree-tos"/>
2458 <arg value="--preferred-challenges"/><arg value="http"/>
2459 <arg value="--email"/><arg value="${https.cert.email}"/>
2460 <arg value="--domains"/><arg value="${https.cert.domains}"/>
2461 </exec>
2462
2463 <!-- sudo openssl pkcs12 -export -out /tmp/DOMAIN_fullchain_and_key.p12 \
2464 -in /etc/letsencrypt/live/DOMAIN/fullchain.pem \
2465 -inkey /etc/letsencrypt/live/DOMAIN/privkey.pem \
2466 -name tomcat
2467 Must run as sudo because only admin has access to the pem files that admin
2468 generated in /etc/letsencrypt
2469 See https://computingforgeeks.com/tomcat-7-with-letsencrypt-ssl-certificate/
2470 but also https://community.letsencrypt.org/t/using-lets-encrypt-with-tomcat/41082
2471 which bypasses the step to generate the java keystore jks file
2472 and uses openssl to generate a pfx file instead of a p12 file
2473 -->
2474
2475 <exec executable="sudo" dir="/tmp" failonerror="true">
2476 <arg value="${basedir}/bin/${os.bin.dir}/openssl/bin/openssl"/>
2477 <arg value="pkcs12"/>
2478 <arg value="-export"/>
2479 <arg value="-out"/><arg value="/tmp/${tomcat.server}_fullchain_and_key.p12"/>
2480 <arg value="-in"/><arg value="/etc/letsencrypt/live/${tomcat.server}/fullchain.pem"/>
2481 <arg value="-inkey"/><arg value="/etc/letsencrypt/live/${tomcat.server}/privkey.pem"/>
2482 <arg value="-name"/><arg value="greenstone3-tomcat"/>
2483 <arg value="-password"/><arg value="pass:${keystore.pass}"/>
2484 </exec>
2485
2486 <!-- Finally, mkdir ${packages.home}/tomcat/conf/https_cert
2487 and copy the file /tmp/${tomcat.server}_fullchain_and_key.p12 into it
2488 and rename to a slightly shorter and simpler name,
2489 see https://stackoverflow.com/questions/8971187/ant-renaming-while-copying-file
2490 The file in tmp has root permissions. But copying it from tmp into
2491 the local account will give the copy local account permissions.
2492 Then sudo to remove the original copy in /tmp
2493 -->
2494 <mkdir dir="${packages.home}/tomcat/conf/https_cert"/>
2495 <!--<copy file="/tmp/${tomcat.server}_fullchain_and_key.p12" todir="${packages.home}/tomcat/conf/https_cert"/>-->
2496 <copy todir="${packages.home}/tomcat/conf/https_cert">
2497 <fileset file="/tmp/${tomcat.server}_fullchain_and_key.p12"/>
2498 <globmapper from="${tomcat.server}_fullchain_and_key.p12" to="${keystore.file}"/>
2499 </copy>
2500
2501 <exec executable="sudo" dir="/tmp" failonerror="true">
2502 <arg line="rm -f /tmp/${tomcat.server}_fullchain_and_key.p12" />
2503 </exec>
2504
2505 </target>
2506
2507
2508 <!-- Revoke the certificate and remove it, including folders.
2509 See https://certbot.eff.org/docs/using.html#revoking-certificates
2510 which also states "if a certificate is a test certificate obtained via the
2511 ==staging or ==test-cert flag, that flag must be passed to the revoke subcommand."
2512 -->
2513 <target name="remove-https-cert">
2514 <echo>
2515 NOTE: If you're on Linux, you need to have sudo permissions to execute this target.
2516 Enter the sudo password if prompted.
2517 </echo>
2518 <!--
2519 On linux, we use certbot-auto.
2520 It says at https://github.com/certbot/certbot/issues/1741
2521 "you shouldn't run letsencrypt-auto [now called certbot-auto] as superuser,
2522 because the program will invoke sudo when it needs to automatically."
2523 We need to send Y(es) as inputstring to confirm that the
2524 /etc/letsencrypt/live/${tomcat.server} folder can be deleted.
2525 Note osfamily="unix" is separate from osfamily="mac", which comes out handy here as we haven't set up certbot-auto for mac (yet).
2526 -->
2527 <exec executable="./certbot-auto" os="${os.linux},${os.solaris}" dir="${basedir}/bin/${os.bin.dir}" failonerror="true" inputstring="Y">
2528 <arg value="revoke"/>
2529 <arg line="${https.testing}"/>
2530 <arg value="--cert-path"/><arg value="/etc/letsencrypt/live/${tomcat.server}/cert.pem"/>
2531 </exec>
2532 <!-- The above command already deletes the folder when Y(es) was passed in. Explicitly deleting:
2533 <exec executable="./certbot-auto" dir="${basedir}/bin/${os.bin.dir}" failonerror="true">
2534 <arg value="delete"/>
2535 <arg value="==cert-name"/><arg value="${tomcat.server}"/>
2536 </exec>
2537 -->
2538
2539 <!-- On Windows and Mac, we use zeroSSl. For the revoke command, see https://zerossl.com/usage.html#Certificate_revocation -->
2540 <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}" spawn="false">
2541 <arg value="/c" />
2542 <arg value="le${os.bitness}" />
2543 <arg value="--key" /><arg value="${packages.home}\tomcat\conf\https_cert\privkey.key" />
2544 <arg value="--crt" /><arg value="${packages.home}\tomcat\conf\https_cert\fullchain_and_prvtkey.crt"/>
2545 <arg value="--revoke"/>
2546 <arg line="${https.testing}"/>
2547 </exec>
2548
2549 <!-- On Mac, we use the le.pl we compiled up (Crypt::LE) and which needs to have PERL5LIB set correctly to run -->
2550 <exec executable="perl" osfamily="mac" dir="${gs2build.home}/perllib/cpan/Crypt/LE/bin" spawn="false">
2551 <env key="PERL5LIB" value="${gs2build.home}/perllib/cpan${path.separator}${gs2build.home}/perllib/cpan/perl-5.18"/>
2552 <arg value="-S" />
2553 <arg value="${gs2build.home}/perllib/cpan/Crypt/LE/bin/le.pl" />
2554 <arg value="--key" /><arg value="${packages.home}/tomcat/conf/https_cert/privkey.key" />
2555 <arg value="--crt" /><arg value="${packages.home}/tomcat/conf/https_cert/fullchain_and_prvtkey.crt"/>
2556 <arg value="--revoke"/>
2557 <arg line="${https.testing}"/>
2558 </exec>
2559
2560 <!-- And remove the https_cert folder -->
2561 <delete dir="${packages.home}/tomcat/conf/https_cert"/>
2562 </target>
2563
2564
2565 <!-- Renewing existing https certificate
2566 Linux:
2567 https://certbot.eff.org/docs/using.html#renewing-certificates
2568 ./path/to/GS3/bin/linux/certbot-auto renew ==quiet ==no-self-upgrade
2569 Windows: reuse Windows issuance target
2570 see https://zerossl.com/usage.html#Certificate_renewal
2571 -->
2572 <target name="renew-existing-https-cert">
2573 <echo>
2574 NOTE: To run this target,
2575 * ensure nothing is running on port 80
2576 * if you're on Linux or Mac, you need to have sudo permissions. Enter the sudo password if prompted.
2577
2578 If you want your cronjob to renew a certificate, you can add pre and post hooks
2579 refer to https://certbot.eff.org/docs/using.html#renewing-certificates
2580 For more information run:
2581 ./path/to/GS3/bin/linux/certbot-auto --help renew
2582 </echo>
2583 <exec executable="./certbot-auto" os="${os.linux},${os.solaris}" dir="${basedir}/bin/${os.bin.dir}" failonerror="true">
2584 <arg value="renew"/>
2585 <arg value="--quiet"/>
2586 <arg value="--no-self-upgrade"/>
2587 </exec>
2588
2589 <!-- For renewal on Windows or Mac, we use ZeroSSL as intermediary between GS3 and Let's Encrypt.
2590 And when using ZeroSSL we need to re-run the original (issuance) command and append "min-min-renew XX" to it,
2591 where if it's within XX days of expiry, the certificate will get renewed.
2592 See https://zerossl.com/usage.html#Certificate_renewal -->
2593 <if><bool><or>
2594 <istrue value="${current.os.iswindows}"/>
2595 <istrue value="${current.os.ismac}"/>
2596 </or></bool>
2597
2598 <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>
2599 <condition property="https.cert.domains" value="${tomcat.server},${https.other.domains}" else="${tomcat.server}">
2600 <and>
2601 <isset property="https.other.domains" />
2602 <not><matches string="${https.other.domains}" pattern="^\s*$"/></not>
2603 </and>
2604 </condition>
2605 <if><bool><istrue value="${current.os.iswindows}"/></bool>
2606 <antcall target="setup-https-cert-windows">
2607 <param name="https.cert.renewal" value="--renew 10"/>
2608 </antcall>
2609 <else>
2610 <antcall target="setup-https-cert-mac">
2611 <param name="https.cert.renewal" value="--renew 10"/>
2612 </antcall>
2613 </else>
2614 </if>
2615 </if>
2616 </target>
2617
2618 <!-- ======================= Tomcat Targets ========================== -->
2619
2620 <!-- this target downloads and installs Tomcat -->
2621 <!-- we download tomcat (version 7 for Java 1.5 and later, version 5 for Java 1.4 plus the 1.4 compatibility package). -->
2622 <target name="prepare-tomcat" depends="init,setup-proxy" if="tomcat.islocal"
2623 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">
2624 <echo>Checking for existence of: ${packages.home}/tomcat/.flagfile</echo>
2625 <if>
2626 <bool>
2627 <not><available file="${packages.home}/tomcat/.flagfile"/></not>
2628 </bool>
2629
2630 <!-- check that packages dir is there -->
2631 <mkdir dir="${packages.home}"/>
2632 <!--
2633 <get src="${gsorg.root}/gs3files/${tomcat.version}.zip"
2634 dest="${packages.home}/${tomcat.version}.zip"
2635 usetimestamp="true"/>
2636 -->
2637 <if>
2638 <bool>
2639 <os family="mac" />
2640 </bool>
2641 <exec executable="curl" failonerror="true">
2642 <arg value="--insecure"/>
2643 <arg value="-o"/>
2644 <arg value="${packages.home}/${tomcat.version}.zip"/>
2645 <arg value="${gsorg.root}/gs3files/${tomcat.version}.zip"/>
2646 </exec>
2647 <else>
2648 <exec executable="${wget}" failonerror="true">
2649 <arg value="-P"/><!-- specifying output dir, also: minus-minus-directory-prefix -->
2650 <arg value="${packages.home}"/>
2651 <arg value="--no-check-certificate"/>
2652 <arg value="${gsorg.root}/gs3files/${tomcat.version}.zip"/>
2653 </exec>
2654 </else>
2655 </if>
2656
2657 <unzip src="${packages.home}/${tomcat.version}.zip"
2658 dest="${packages.home}"/>
2659
2660 <!-- If we are using Java 1.4, we'd be using tomcat 5.5 in which case
2661 we would need to have the tomcat compat package to work with Java 1.4-->
2662 <if>
2663 <bool><equals arg1="1.4" arg2="${java.specification.version}"/></bool>
2664 <!--
2665 <get src="${gsorg.root}/gs3files/${tomcat.version}-compat.zip"
2666 dest="${packages.home}/${tomcat.version}-compat.zip"
2667 usetimestamp="true"/>
2668 -->
2669
2670 <if>
2671 <bool><os family="mac" /></bool>
2672 <exec executable="curl" failonerror="true">
2673 <arg value="--insecure"/>
2674 <arg value="-o"/>
2675 <arg value="${packages.home}/${tomcat.version}-compat.zip"/>
2676 <arg value="${gsorg.root}/gs3files/${tomcat.version}-compat.zip"/>
2677 </exec>
2678 <else>
2679 <exec executable="${wget}" failonerror="true">
2680 <arg value="-P"/>
2681 <arg value="${packages.home}"/>
2682 <arg value="--no-check-certificate"/>
2683 <arg value="${gsorg.root}/gs3files/${tomcat.version}-compat.zip"/>
2684 </exec>
2685 </else>
2686 </if>
2687
2688 <unzip src="${packages.home}/${tomcat.version}-compat.zip"
2689 dest="${packages.home}"/>
2690 </if>
2691
2692 <!-- delete any existing tomcat -->
2693 <delete dir="${packages.home}/tomcat"/>
2694 <move todir="${packages.home}/tomcat">
2695 <fileset dir="${packages.home}/${tomcat.version}"/>
2696 </move>
2697
2698 <!-- To avoid the CGI permissions error appearing continuously in the (localhost) log,
2699 need privileged=true set in the root context.xml file too, not just greenstone context file.
2700 See http://stackoverflow.com/questions/9845936/tomcat-v7-0-load-exception-marking-servlet-ssi-as-unavailable/10305471#10305471
2701 For usage of IfTask IsLessThan: http://antelope.stage.tigris.org/nonav/docs/manual/bk03ch05s02.html -->
2702 <if><bool><not><islessthan arg1="${tomcat.version.major}" arg2="7"/></not></bool>
2703 <copy file="${basedir}/resources/tomcat/root_context.xml.in" tofile="${packages.home}/tomcat/conf/context.xml" overwrite="true" />
2704 </if>
2705
2706
2707 <!--
2708 <copy file="${basedir}/resources/tomcat/setclasspath.bat"
2709 tofile="${packages.home}/tomcat/bin/setclasspath.bat"
2710 overwrite="true"/>
2711 <copy file="${basedir}/resources/tomcat/setclasspath.sh"
2712 tofile="${packages.home}/tomcat/bin/setclasspath.sh"
2713 overwrite="true"/>
2714 -->
2715 <!-- make sure we have execute permission for the .sh files -->
2716 <chmod dir="${packages.home}/tomcat/bin" perm="ugo+rx"
2717 includes="*.sh"/>
2718
2719 <echo file="${packages.home}/tomcat/.flagfile">
2720 the timestamp of this file is the time that tomcat was extracted from the zip files.
2721 it is used to figure out whether the files need to be refreshed or not in `ant prepare-tomcat`
2722 </echo>
2723
2724 <!-- this is not strictly a prepare tomcat thing, but if one changes
2725 Java, then they need to change tomcat as well, so might as well call
2726 it here -->
2727 <antcall target="configure-java-version"/>
2728 <else>
2729 <echo>Tomcat has been prepared, will not prepare</echo>
2730 <echo>Delete ${packages.home}/tomcat/.flagfile to force refresh</echo>
2731 </else>
2732
2733 </if>
2734
2735 </target>
2736
2737 <target name="configure-tomcat" depends="init,configure-tomcat-local,configure-tomcat-external"/>
2738
2739 <target name="configure-tomcat-local" depends="init,perl-for-building" if="tomcat.islocal">
2740 <!-- re-setup the server.xml file -->
2741 <copy file="${basedir}/resources/tomcat/server_tomcat${tomcat.version.major}.xml.in"
2742 tofile="${packages.home}/tomcat/conf/server.xml" overwrite="true">
2743 <filterset>
2744 <filter token="shutdown-port" value="${tomcat.shutdown.port}"/>
2745 <filter token="tomcat.ajp.port" value="${tomcat.ajp.port}"/>
2746 <filter token="https.redirect.port" value="${https.redirect.port}"/>
2747 <filter token="localhost.port.http" value="${localhost.port.http}"/>
2748 <filter token="tomcat.port.https" value="${tomcat.port.https}"/>
2749 <!-- Relative path preferred for keystore.file, in case tomcat is moved elsewhere -->
2750 <!--<filter token="keystore.file" value="conf/https_cert/${tomcat.server}.jks" />-->
2751 <!--ON UNIX: <filter token="keystore.file" value="conf/https_cert/fullchain_and_prvtkey.p12" />-->
2752 <!--ON WINDOWS: <filter token="keystore.file" value="conf/https_cert/fullchain_and_prvtkey.pfx" />-->
2753 <filter token="keystore.file" value="conf/https_cert/${keystore.file}" />
2754 <!-- tomcat Connector's keystoreType param defaults to JKS (Java keystore), see https://tomcat.apache.org/tomcat-7.0-doc/config/http.html
2755 We'll follow the instructions at https://community.letsencrypt.org/t/using-lets-encrypt-with-tomcat/41082,
2756 https://www.ssl.com/how-to/create-a-pfx-p12-certificate-file-using-openssl/
2757 and https://computingforgeeks.com/tomcat-7-with-letsencrypt-ssl-certificate/
2758 (minus the keytool step) and use the PKCS12 file generated by openssl directly,
2759 instead of an additional step to generate the java keystore file from that -->
2760 <filter token="keystore.type" value="PKCS12"/>
2761 <filter token="keystore.pass" value="${keystore.pass}"/>
2762 <!--
2763 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)
2764 In that case, see https://serverfault.com/questions/218666/how-to-configure-tomcat-to-only-listen-to-127-0-0-1
2765 -->
2766 <filter token="http.address.restriction" value="${http.address.restriction}"/>
2767 <filter token="https.comment.out.start" value="${https.comment.out.start}"/>
2768 <filter token="https.comment.out.end" value="${https.comment.out.end}"/>
2769 </filterset>
2770 </copy>
2771
2772 <!-- set up the solr context -->
2773
2774 <!-- First work out the IPv4 address for this machine -->
2775 <exec executable="${basedir}/bin/script/IPv4.sh" os="${os.unix}" failonerror="false" outputproperty="ipv4.val">
2776 <arg value="-format-for-tomcat-context"/>
2777 </exec>
2778 <exec executable="${basedir}/bin/script/IPv4.bat" osfamily="windows" failonerror="false" outputproperty="ipv4.val">
2779 <arg value="-format-for-tomcat-context"/>
2780 </exec>
2781
2782 <copy file="${basedir}/resources/web/servlets.xml.in" tofile="${web.home}/WEB-INF/servlets.xml" overwrite="true">
2783 <filterset>
2784 <filter token="googlesigninclientid" value="${tomcat.googlesigninJDBCRealm.clientid}"/>
2785 <!-- the following might be useful, but not currently included, as not currently used -->
2786 <!--
2787 <filter token="gsdl3webhome" value="${web.home}"/>
2788 <filter token="gsdl3webwritablehome" value="${web.writablehome}"/>
2789 <filter token="tomcathome" value="${basedir}/packages/tomcat"/>
2790 -->
2791 </filterset>
2792 </copy>
2793
2794 <copy file="${basedir}/ext/solr/solr-tomcat-context.xml.in" tofile="${packages.home}/tomcat/conf/Catalina/localhost/solr.xml" overwrite="true">
2795 <filterset>
2796 <filter token="solr.context" value="${solr.context}"/>
2797 <filter token="gsdl3webhome" value="${web.writablehome}"/>
2798 <filter token="tomcathome" value="${basedir}/packages/tomcat"/>
2799 <filter token="IPv4" value="${ipv4.val}"/>
2800 </filterset>
2801 </copy>
2802
2803 <!-- set up the greenstone3 context, it may have a custom name specified in build.properties -->
2804 <if><bool><not><equals arg1="greenstone3" arg2="${greenstone.context}"></equals></not></bool>
2805 <copy file="${basedir}/resources/tomcat/greenstone3.xml.in" tofile="${basedir}/resources/tomcat/${greenstone.context}.xml.in" overwrite="true"/>
2806 </if>
2807 <copy file="${basedir}/resources/tomcat/${greenstone.context}.xml.in" tofile="${packages.home}/tomcat/conf/Catalina/localhost/${greenstone.context}.xml" overwrite="true">
2808 <filterset>
2809 <filter token="gsdl3webhome" value="${web.home}"/>
2810 <filter token="gsdl3webwritablehome" value="${web.writablehome}"/>
2811 <filter token="privilegedattribute" value="${privileged.attribute}"/>
2812 <filter token="allowlinking" value="${tomcat.allowLinking}"/>
2813 <filter token="allowedIPs" value="${allowed.IPs}"/>
2814 <filter token="derbyserver" value="${derby.server}"/>
2815 <filter token="derbyserverport" value="${derby.server.port}"/>
2816 <filter token="googlesigninclientid" value="${tomcat.googlesigninJDBCRealm.clientid}"/>
2817 </filterset>
2818 </copy>
2819 <if>
2820 <bool>
2821 <and>
2822 <available file="${packages.home}/tomcat/conf/Catalina/localhost/greenstone3.xml"/>
2823 <not><equals arg1="greenstone3" arg2="${greenstone.context}"></equals></not>
2824 </and>
2825 </bool>
2826 <delete file="${packages.home}/tomcat/conf/Catalina/localhost/greenstone3.xml"/>
2827 </if>
2828
2829 <!-- set up the greenstone3 web.xml file -->
2830 <copy file="${basedir}/resources/tomcat/web8.xml.in" tofile="${packages.home}/tomcat/conf/web.xml" overwrite="true">
2831 <filterset>
2832 <filter token="perlpath" value="${perl.path}"/>
2833 </filterset>
2834 </copy>
2835 </target>
2836
2837 <target name="configure-tomcat-external" depends="init" unless="tomcat.islocal">
2838 <!-- re-setup the server.xml file -->
2839 <!-- need to edit the config file, or do we get the user to do this???-->
2840 </target>
2841
2842 <target name="configure-solr-ext" depends="init" >
2843 <!-- re-setup the web/ext/solr/solr.xml file -->
2844 <copy file="${web.home}/ext/solr/solr.xml.in"
2845 tofile="${gsdl3.writablehome}/ext/solr/solr.xml" filtering="true" overwrite="true">
2846 <filterset>
2847 <filter token="gsdl3.home" value="${src.gsdl3.home.unix}"/>
2848 <filter token="gsdl3.writablehome" value="${src.gsdl3.writablehome.unix}"/>
2849 </filterset>
2850 </copy>
2851 </target>
2852
2853 <target name="configure-webswing-ext" depends="needs-gs3-setup,init" description="Configure the webswing extension (regenerates the config files)">
2854 <exec executable="ant.bat" osfamily="windows" dir="${webswing-ext.home}" spawn="false" failonerror="true">
2855 <arg value="-Dweb.home=${web.home.unix}"/>
2856 <arg value="-Dweb.writablehome=${web.writablehome.unix}"/>
2857 <arg value="-Dgsdlos=${env.GSDLOS}"/>
2858 <arg value="-Dinternal.websocket-baseurl=${local.ws.url}"/>
2859 <arg value="-Dinternal.servlet-url=${internal.servlet-url}"/>
2860 <arg value="-Dexternal.servlet-url=${external.servlet-url}"/>
2861 <arg value="-Dexternal.webswing-url=${external.webswing-url}"/>
2862 <arg value="configure-extension"/>
2863 </exec>
2864 <exec executable="ant" os="${os.unix}" dir="${webswing-ext.home}" spawn="false" failonerror="true">
2865 <arg value="-Dweb.home=${web.home}"/>
2866 <arg value="-Dweb.writablehome=${web.writablehome}"/>
2867 <arg value="-Dgsdlos=${env.GSDLOS}"/>
2868 <arg value="-Dinternal.websocket-baseurl=${local.ws.url}"/>
2869 <arg value="-Dinternal.servlet-url=${internal.servlet-url}"/>
2870 <arg value="-Dexternal.servlet-url=${external.servlet-url}"/>
2871 <arg value="-Dexternal.webswing-url=${external.webswing-url}"/>
2872 <arg value="configure-extension"/>
2873 </exec>
2874
2875 <if>
2876 <bool><available file="${web.writablehome}/ext/webswing/etc/catalina-opts-extra.args"/></bool>
2877 <loadfile property="webswing.catalina.opts" srcfile="${web.writablehome}/ext/webswing/etc/catalina-opts-extra.args" failonerror="true"/>
2878 <else>
2879 <property name="webswing.catalina.opts" value=""/>
2880 </else>
2881 </if>
2882 </target>
2883
2884 <!-- This target runs tomcat's "bin/catalina.bat(.sh) jpda start"
2885 to allow debugging the running GS3 server in Eclipse. See the instructions at
2886 http://www.wikijava.org/wiki/Debugging_a_servlet_with_tomcat_and_Eclipse_tutorial
2887 on how to use this with eclipse
2888 -->
2889 <target name="debug-start-tomcat" description="Startup Tomcat for debugger" depends="envbased-localtomcat-path,configure-webswing-ext,init" if="tomcat.islocal">
2890 <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
2891 <property name="tomcat.path" refid="local.tomcat.path"/>
2892
2893 <if><bool>
2894 <isset property="fedora.maxpermsize"/></bool>
2895 <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}"/>
2896 <else>
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; ${webswing.catalina.opts} ${readonly.catalina.opts}"/>
2898 </else>
2899 </if>
2900
2901 <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
2902 <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
2903
2904 <exec executable="${catalina.home}/bin/catalina.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
2905 <env key="JPDA_ADDRESS" value="8000"/> <!-- for debugging Tomcat in Eclipse -->
2906 <env key="JPDA_TRANSPORT" value="dt_socket"/> <!-- for debugging Tomcat in Eclipse -->
2907 <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
2908 <env key="PATH" path="${tomcat.path}"/>
2909 <!-- Based on:
2910 https://jfrog.com/knowledge-base/tomcat-takes-forever-to-start-what-can-i-do/
2911 consider controlling Tomcat to use the psuedo random number generator '/dev/urandom'
2912 raher than the default '/dev/random' which while cryptographically stronger is
2913 also slower when demand is high
2914
2915 -Djava.security.egd=file:/dev/urandom
2916 -->
2917 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
2918 <env key="CATALINA_HOME" value="${catalina.home}"/>
2919 <env key="CLASSPATH" path="${tomcat.classpath}"/>
2920 <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
2921 <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
2922 <env key="WNHOME" path="${wn.home}"/>
2923 <env key="FEDORA_HOME" path="${fedora.home}"/>
2924
2925 <env key="_RUNJAVA" value="${env.CATALINA_START_RUNJAVA}"/>
2926 <arg value="jpda" />
2927 <arg value="start" />
2928 </exec>
2929 <exec executable="${catalina.home}/bin/catalina.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="true">
2930 <env key="JPDA_ADDRESS" value="8000"/> <!-- for debugging Tomcat in Eclipse -->
2931 <env key="JPDA_TRANSPORT" value="dt_socket"/> <!-- for debugging Tomcat in Eclipse -->
2932 <env key="GSDLOS" value="windows"/>
2933 <env key="GSDL3HOME" value="${web.home}"/>
2934 <env key="Path" path="${tomcat.path}"/>
2935 <env key="PATH" path="${tomcat.path}"/>
2936 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
2937 <env key="CATALINA_HOME" value="${catalina.home}"/>
2938 <env key="CLASSPATH" path="${tomcat.classpath}"/>
2939 <env key="FEDORA_HOME" path="${fedora.home}"/>
2940
2941 <arg value="jpda" />
2942 <arg value="start" />
2943 </exec>
2944 <!-- wait for the server to startup in case other targets need it running -->
2945 <waitfor maxwait="5" maxwaitunit="second">
2946 <and>
2947 <socket server="${tomcat.server}" port="${default.tomcat.port}"/>
2948 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/index.html"/>-->
2949 <http url="${local.http.url}${app.path}/index.html"/>
2950 </and>
2951 </waitfor>
2952 </target>
2953
2954 <target name="start-tomcat" description="Startup only Tomcat" depends="check-tomcat-started">
2955
2956 <if><bool><istrue value="${tomcat.isstarted}"/></bool>
2957 <echo>**************************************</echo>
2958 <echo>A WEB SERVER IS ALREADY RUNNING ON ${default.server.protocol}://${tomcat.server}:${default.tomcat.port} (${local.http.url}). NOT STARTING.</echo>
2959 <echo>**************************************</echo>
2960 <else>
2961 <antcall target="force-start-tomcat"/>
2962 </else>
2963 </if>
2964 </target>
2965
2966 <!-- Another way: http://ptrthomas.wordpress.com/2006/03/25/how-to-start-and-stop-tomcat-from-ant/ -->
2967 <target name="force-start-tomcat" description="Startup only Tomcat" depends="envbased-localtomcat-path,configure-webswing-ext,init" if="tomcat.islocal">
2968
2969 <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
2970 <property name="tomcat.path" refid="local.tomcat.path"/>
2971
2972 <if><bool>
2973 <isset property="fedora.maxpermsize"/></bool>
2974 <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}"/>
2975 <else>
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}"/>
2977 </else>
2978 </if>
2979
2980 <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
2981 <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
2982
2983 <!-- using osfamily instead of testing os against os.windows list of recognised windows versions
2984 so that future windows versions are included. See http://simonharrer.wordpress.com/tag/osfamily/
2985 Can't use the osfamily test for linux-type machines as a group since osfamily=unix is separate from osfamily=mac,
2986 see http://ant-contrib.sourceforge.net/tasks/tasks/osfamily.html -->
2987
2988 <exec executable="${sudo.or.not}" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
2989 <!--<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-->
2990 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
2991 <env key="CATALINA_HOME" value="${catalina.home}"/>
2992 <env key="CLASSPATH" path="${tomcat.classpath}"/>
2993 <env key="PATH" path="${tomcat.path}"/>
2994
2995 <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
2996 <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
2997
2998 <!-- Webswing servlet needs the following enviornent variables to be set to be able to run GLI -->
2999 <env key="GSDL3SRCHOME" value="${env.GSDL3SRCHOME}"/>
3000 <env key="GSDL3HOME" value="${web.home}"/> <!-- consider changing to env.GSDL3HOME to be more consistent? -->
3001 <env key="GSDLHOME" value="${env.GSDLHOME}"/> <!-- i.e., gs2build.home -->
3002 <env key="GSDL3EXTS" value="${env.GSDL3EXTS}"/>
3003 <env key="GSDLEXTS" value="${env.GSDLEXTS}"/>
3004 <env key="GEXT_SOLR" value="${env.GEXT_SOLR}"/>
3005 <env key="GSDLOS" value="${env.GSDLOS}"/>
3006
3007 <env key="WNHOME" path="${wn.home}"/>
3008 <env key="FEDORA_HOME" path="${fedora.home}"/>
3009
3010 <env key="_RUNJAVA" value="${env.CATALINA_START_RUNJAVA}"/>
3011 <arg value="${catalina.home}/bin/startup.sh"/>
3012 </exec>
3013 <exec executable="${catalina.home}/bin/startup.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="true">
3014 <!--<env key="JAVA_TOOL_OPTIONS" value="-Dfile.encoding=UTF-8"/>-->
3015 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
3016 <env key="CATALINA_HOME" value="${catalina.home}"/>
3017 <env key="CLASSPATH" path="${tomcat.classpath}"/>
3018
3019 <env key="PATH" path="${tomcat.path}"/>
3020 <env key="Path" path="${tomcat.path}"/>
3021 <!-- Should the equivalent LD_LIBRARY_PATH line above for Unix, be turned into an equivalent PATH update, as this is what Windows uses? -->
3022
3023 <!-- Webswing servlet needs the following enviornent variables to be set to be able to run GLI -->
3024 <env key="GSDL3SRCHOME" value="${env.GSDL3SRCHOME}"/>
3025 <env key="GSDL3HOME" value="${web.home}"/> <!-- consider changing to env.GSDL3HOME to be more consistent? -->
3026 <env key="GSDLHOME" value="${env.GSDLHOME}"/> <!-- i.e., gs2build.home -->
3027 <env key="GSDL3EXTS" value="${env.GSDL3EXTS}"/>
3028 <env key="GSDLEXTS" value="${env.GSDLEXTS}"/>
3029 <env key="GEXT_SOLR" value="${env.GEXT_SOLR}"/>
3030 <env key="GSDLOS" value="${env.GSDLOS}"/> <!-- used to be hardwired to 'windows', but now gs3-setup.sh run, GSDLOS should be set -->
3031
3032 <env key="WNHOME" path="${wn.home}"/>
3033 <env key="FEDORA_HOME" path="${fedora.home}"/>
3034 </exec>
3035 <!-- wait for the server to startup in case other targets need it running -->
3036 <waitfor maxwait="5" maxwaitunit="second">
3037 <and>
3038 <socket server="${tomcat.server}" port="${default.tomcat.port}"/>
3039 <!-- The following is time-consuming to wait for: uncomment for extra thoroughness
3040 For now, chosing to have it commented out in svn checked out version of code
3041 Also leaving the <and> element in, even though it is now just one test to
3042 make it easier to return to the double test
3043 Note: the 'debug-start-tomcat' target does still include this test
3044 -->
3045 <!-- <http url="${local.http.url}${app.path}/index.html"/> -->
3046 </and>
3047 </waitfor>
3048
3049 </target>
3050
3051 <!--ant task http: http://www.jajakarta.org/ant/ant-1.6.1/docs/ja/manual/api/org/apache/tools/ant/taskdefs/condition/Http.html-->
3052 <target name="reconfigure" description="Reconfigure the message router">
3053 <waitfor maxwait="5" maxwaitunit="second">
3054 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c"/>-->
3055 <http url="${local.http.url}${app.path}${server.default.servlet}?a=s&amp;sa=c"/>
3056 </waitfor>
3057 </target>
3058
3059 <!--Command-line args to Ant: http://www.jguru.com/faq/view.jsp?EID=471794-->
3060 <target name="reconfigure-collection" description="Reconfigure the collection">
3061 <waitfor maxwait="5" maxwaitunit="second">
3062 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c&amp;sc=${collection}"/>-->
3063 <http url="${local.http.url}${app.path}${server.default.servlet}?a=s&amp;sa=c&amp;sc=${collection}"/>
3064 </waitfor>
3065 </target>
3066
3067 <!-- windows: do we want to launch a webrowser?? -->
3068 <!-- shouldn't this test whether anything is running first?
3069 It's safer to always attempt to stop tomcat: that way we won't be dependent on the right time
3070 to check whether the server is stopped or still running before attempting to start again.
3071 This target, which was recently called force-stop-tomcat for a while but is back to being
3072 called stop-tomcat, now hides the Java exception output that appears whenever tomcat is already
3073 stopped as happens when stop-tomcat is called consecutively. -->
3074 <target name="force-stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal">
3075 <!--<exec executable="${catalina.home}/bin/shutdown.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">-->
3076 <exec executable="${sudo.or.not}" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
3077 <!--<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-->
3078 <env key="FEDORA_HOME" path="${fedora.home}"/>
3079 <env key="CATALINA_HOME" value="${catalina.home}"/>
3080 <arg value="${catalina.home}/bin/shutdown.sh"/>
3081 <arg line=">/dev/null 2>&amp;1"/>
3082 </exec>
3083 <exec executable="${catalina.home}/bin/shutdown.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="false">
3084 <!--<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? -->
3085 <env key="FEDORA_HOME" path="${fedora.home}"/>
3086 <env key="CATALINA_HOME" value="${catalina.home}"/>
3087 <arg line=">nul 2>&amp;1"/>
3088 </exec>
3089 </target>
3090
3091 <!-- Can also try the "socket" condition in place of the "http" condition
3092 And also use a <waitfor> in place of <condition>, such as:
3093 <waitfor maxwait="5" maxwaitunit="second" timeoutproperty="tomcat.isstopped"><http url="..."/></waitfor>
3094 The http URL resolves to host:port/greenstone3
3095 Condition uses <http/> rather than <socket/> for testing, since if the server was stopped, the socket
3096 might still be in use for some moments. We test the URL with the http condition since it's likelier to
3097 fail sooner if the server has indeed been stopped. -->
3098 <target name="check-tomcat-running">
3099 <condition property="tomcat.isrunning">
3100 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}"/>-->
3101 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}"/>--><!-- untrusted certificates won't work, so don't test https urls-->
3102 <http url="${local.http.url}"/><!-- testing the local http url instead -->
3103 </condition>
3104 </target>
3105
3106 <!--
3107 <target name="verbose-check-tomcat-running">
3108 <condition property="tomcat.isrunning" value="true" else="false">
3109 <http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}"/>
3110 <http url="${local.http.url}"/>
3111 </condition>
3112 <echo>Tomcat is running: ${tomcat.isrunning}</echo>
3113 </target>
3114 -->
3115 <target name="verbose-check-tomcat-running" depends="check-tomcat-running">
3116 <if>
3117 <bool>
3118 <istrue value="${tomcat.isrunning}"/>
3119 </bool>
3120 <echo>Tomcat is running: ${tomcat.isrunning}</echo>
3121 <else><echo>Tomcat is running: false</echo></else><!-- tomcat.isrunning not set -->
3122 </if>
3123 </target>
3124
3125 <!-- Need a copy of the check-tomcat-running target with a distinct property, because ant restart runs
3126 both stop and start, both of which need to do tomcat checks. Each property can be set only once during
3127 an invocation with ant. So ant restart will need two properties to store each of the tomcat checks -->
3128 <target name="check-tomcat-started">
3129 <condition property="tomcat.isstarted">
3130 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}"/>-->
3131 <http url="${local.http.url}"/>
3132 </condition>
3133 </target>
3134
3135
3136
3137 <!-- stop-tomcat checks if the tomcat server is already running. If it appears to be running
3138 (regardless of whether tomcat was just starting to shut down), this target calls force-stop-tomcat
3139 to issue the shutdown command to tomcat. Then it waits for at most 15 seconds for the server to
3140 actually stop by checking the socket at which tomcat listens every second, printing a warning
3141 at the end of the max wait time of 15 seconds if tomcat was still running. -->
3142 <target name="stop-tomcat" description="Shutdown only Tomcat if running" depends="check-tomcat-running" if="tomcat.isrunning">
3143 <antcall target="force-stop-tomcat"/>
3144
3145 <property name="wait.numchecks" value="15"/>
3146 <echo>Waiting for the server to shutdown... (${wait.numchecks} seconds max)</echo>
3147 <waitfor maxwait="${wait.numchecks}" maxwaitunit="second" checkevery="1" checkeveryunit="second" timeoutproperty="tomcat.timedout">
3148 <not><socket server="${tomcat.server}" port="${default.tomcat.port}"/></not>
3149 </waitfor>
3150
3151 <if>
3152 <bool>
3153 <isset property="${tomcat.timedout}"/>
3154 </bool>
3155 <property name="tomcat.isrunning" value="true"/>
3156 <echo>WARNING: Checked the socket ${wait.numchecks} times, but port ${default.tomcat.port} is still busy.</echo>
3157 <else>
3158 <echo>Tomcat is stopped.</echo>
3159 <property name="tomcat.isrunning" value="false"/>
3160 </else>
3161 </if>
3162 </target>
3163
3164 <target name="restart-tomcat" description="Shutdown and restart only Tomcat" depends="init,stop-tomcat,force-start-tomcat"/>
3165
3166 <target name="setup-catalina-ant-tasks">
3167 <!-- Configure the custom Ant tasks for the Tomcat Manager application -->
3168 <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"
3169 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
3170 <taskdef name="list" classname="org.apache.catalina.ant.ListTask"
3171 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
3172 <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"
3173 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
3174 <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"
3175 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
3176 <taskdef name="roles" classname="org.apache.catalina.ant.RolesTask"
3177 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
3178 <taskdef name="start" classname="org.apache.catalina.ant.StartTask"
3179 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
3180 <taskdef name="stop" classname="org.apache.catalina.ant.StopTask"
3181 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
3182 <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"
3183 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
3184 </target>
3185
3186 <!-- http://blog.andrewbeacock.com/2007/11/how-to-truncate-log-file-using-ubuntu.html
3187 Doing "cat </dev/null > packages/tomcat/logs/catalina.out" doesn't work as an ant target.
3188 It seems to have a problem with cat or </dev/null, with or without the < sign. -->
3189 <target name="reset-logs" description="Empties catalina.out, solr.log, greenstone.log, usage.log, server.log and contents of web/logs/tmp">
3190 <echo>Truncating catalina.out, solr.log, greenstone.log, usage.log and server.log, and emptying ${web.writablehome}/logs/tmp</echo>
3191 <exec executable="rm" os="${os.unix}" dir="${catalina.home}/logs" spawn="false">
3192 <arg value="-f"/>
3193 <arg value="catalina.out"/>
3194 </exec>
3195 <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
3196 <arg value="-f"/>
3197 <arg value="greenstone.log"/>
3198 </exec>
3199 <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
3200 <arg value="-f"/>
3201 <arg value="usage.log"/>
3202 </exec>
3203 <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
3204 <arg value="-f"/>
3205 <arg value="server.log"/>
3206 </exec>
3207
3208 <exec executable="touch" os="${os.unix}" dir="${catalina.home}/logs"
3209 spawn="false">
3210 <arg value="catalina.out"/>
3211 </exec>
3212 <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
3213 spawn="false">
3214 <arg value="greenstone.log"/>
3215 </exec>
3216 <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
3217 spawn="false">
3218 <arg value="usage.log"/>
3219 </exec>
3220 <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
3221 spawn="false">
3222 <arg value="server.log"/>
3223 </exec>
3224
3225 <exec executable="cmd" osfamily="windows" dir="${catalina.home}/logs" spawn="false">
3226 <arg line="/c echo. > catalina.out"/>
3227 </exec>
3228 <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
3229 <arg line="/c echo. > greenstone.log"/>
3230 </exec>
3231 <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
3232 <arg line="/c echo. > usage.log"/>
3233 </exec>
3234 <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
3235 <arg line="/c echo. > server.log"/>
3236 </exec>
3237
3238 <!-- if ext/solr/logs/solr.log exists, truncate it -->
3239 <if><bool><available file="${solr-ext.home}/logs/solr.log" type="file"/></bool>
3240 <exec executable="rm" os="${os.unix}" dir="${solr-ext.home}/logs" spawn="false">
3241 <arg value="-f"/>
3242 <arg value="solr.log"/>
3243 </exec>
3244 <exec executable="touch" os="${os.unix}" dir="${solr-ext.home}/logs" spawn="false">
3245 <arg value="solr.log"/>
3246 </exec>
3247 <exec executable="cmd" osfamily="windows" dir="${solr-ext.home}/logs" spawn="false">
3248 <arg line="/c echo. > solr.log"/>
3249 </exec>
3250 </if>
3251
3252 <if>
3253 <bool><available file="${web.writablehome}/logs/tmp" type="dir"/></bool>
3254 <delete>
3255 <fileset dir="${web.writablehome}/logs/tmp" includes="**/*"/>
3256 </delete>
3257 </if>
3258 </target>
3259
3260 <target name="clear-tomcat-sessions" description="Clear the Tomcat Session info." depends="init">
3261 <exec executable="cmd" osfamily="windows" dir="${catalina.home}/work/Catalina/localhost/greenstone3" spawn="false">
3262 <arg line="/c echo. > SESSIONS.ser"/>
3263 </exec>
3264 <exec executable="rm" os="${os.unix}" dir="${catalina.home}/work/Catalina/localhost/greenstone3" spawn="false">
3265 <arg value="-f"/>
3266 <arg value="SESSIONS.ser"/>
3267 </exec>
3268
3269 </target>
3270 <!-- ======================= ant Targets ============================ -->
3271 <target name="prepare-ant" depends="init">
3272 <if>
3273 <bool>
3274 <not><available file="${packages.home}/ant/.flagfile"/></not>
3275 </bool>
3276 <property name="ant.download.version" value="apache-ant-1.9.13" />
3277 <!--
3278 <get src="${gsorg.root}/gs3files/${ant.download.version}-bin.zip"
3279 dest="${packages.home}/${ant.download.version}-bin.zip"
3280 usetimestamp="true"/>
3281 -->
3282 <exec executable="${wget}" failonerror="true">
3283 <arg value="-P"/>
3284 <arg value="${packages.home}"/>
3285 <arg value="--no-check-certificate"/>
3286 <arg value="${gsorg.root}/gs3files/${ant.download.version}-bin.zip"/>
3287 </exec>
3288 <unzip src="${packages.home}/${ant.download.version}-bin.zip"
3289 dest="${packages.home}"/>
3290 <move todir="${packages.home}/ant">
3291 <fileset dir="${packages.home}/${ant.download.version}"/>
3292 </move>
3293 <echo file="${packages.home}/ant/.flagfile">
3294 the timestamp of this file is the time that ant was extracted from the zip files.
3295 it is used to figure out whether the files need to be refreshed or not in `ant prepare-ant`
3296 </echo>
3297
3298 <else>
3299 <echo>Ant has been prepared, will not prepare</echo>
3300 <echo>Delete ${packages.home}/ant/.flagfile to force refresh</echo>
3301 </else>
3302
3303 </if>
3304 </target>
3305
3306 <!-- ======================= Admin Targets ============================ -->
3307
3308 <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
3309 See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
3310 But you can do: echo mypassword | ant config-admin -->
3311 <target name="config-admin" description="Reset admin password">
3312 <input addproperty="admin.password" defaultvalue="admin" message="New admin password (3-20 characters):&gt;">
3313 <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
3314 </input>
3315 <!--<echo>PWD: ${admin.password}</echo>-->
3316 <antcall target="update-userdb">
3317 <param name="user.username" value="admin"/>
3318 <param name="user.password" value="${admin.password}"/>
3319 <param name="user.groups" value=""/>
3320 <param name="user.status" value=""/>
3321 <param name="user.comment" value="Password updated."/>
3322 <param name="user.email" value=""/>
3323 </antcall>
3324 </target>
3325
3326 <target name="config-user" description="Add or modify users" depends="get-user-data,update-userdb"/>
3327<!-- this is called bu config-user to ask for the new user details at the prompt -->
3328 <target name="get-user-data" >
3329 <input addproperty="user.username" message="Username:&gt;"/>
3330 <input addproperty="user.password" defaultvalue="" message="Password (3-20 characters):&gt;">
3331 <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
3332 </input>
3333 <input addproperty="user.groups" defaultvalue="" message="Groups (comma-separated list, e.g. personal-collections-editor):&gt;"/>
3334 <input addproperty="user.status" defaultvalue="true" message="Enabled (true/false):&gt;"/>
3335 <input addproperty="user.comment" defaultvalue="" message="Comment:&gt;"/>
3336 <input addproperty="user.email" defaultvalue="" message="Email:&gt;"/>
3337 </target>
3338
3339 <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
3340 See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
3341 But you can do: echo mypassword | ant config-admin -->
3342 <target name="update-userdb" depends="start-derby">
3343
3344 <!--
3345 We're now using derby networked server, so stopping and starting tomcat is not necessary.
3346 For embedded derby: stop tomcat if running, since derby db is embedded
3347 and only allows connections from one jvm instance at a time
3348 See http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html
3349 The ${tomcat.isrunning} property is set by the depends-target "check-tomcat-running" -->
3350
3351 <!-- Need the derby networked server to be running in order to modify the usersDB.
3352 The start-derby task will check if derby is already running (if not, ${derby.isstarted} will
3353 be false) and will only start up networked derby if it is not already running.
3354 The ${derby.isstarted} property is set by the depends-target "start-derby", since it won't
3355 set the property if called with antcall (like launching in a subshell). Have to use 'depends'.
3356 We'll check ${derby.isstarted} at the end to stop derby again if we had to start it up now.-->
3357 <!--<antcall target="start-derby"/>-->
3358
3359 <!-- wait a max of 5 seconds for the derbyserver to have started up -->
3360 <waitfor maxwait="5" maxwaitunit="second">
3361 <socket server="${derby.server}" port="${derby.server.port}"/>
3362 </waitfor>
3363
3364 <!--<echo>${admin.password}</echo>--> <!-- for testing -->
3365 <echo>gsdl3.writablehome: ${gsdl3.writablehome}</echo> <!-- for testing -->
3366 <echo>web.home: ${web.home}</echo> <!-- for testing -->
3367 <java classname="org.greenstone.gsdl3.util.ModifyUsersDB">
3368 <classpath refid="compile.classpath"/> <!--for ${web.lib}/gsdl3.jar and supporting files-->
3369 <sysproperty key="gsdl3.writablehome" value="${gsdl3.writablehome}" /> <!-- passes -D<syspropKey=syspropVal> to java class ModifyUsersDB. Available in java code as System.getProperty("syspropKey") -->
3370 <arg file="${web.home}/etc/usersDB"/>
3371 <arg value="${user.username}"/>
3372 <arg value="password=${user.password}"/>
3373 <arg value="groups=${user.groups}"/>
3374 <arg value="status=${user.status}"/>
3375 <arg value="comment=${user.comment}"/>
3376 <arg value="email=${user.email}"/>
3377 </java>
3378
3379 <!-- Need to stop networked derby again if we ran it for this target with the depends=start-derby call.
3380 The test here is for <not>derby.isstarted</not>, as the property would be the same as before
3381 derby was started, since properties are immutable within a single ant command. -->
3382 <if>
3383 <bool>
3384 <not><istrue value="${derby.isstarted}"/></not>
3385 </bool>
3386 <antcall target="force-stop-derby"/>
3387 </if>
3388
3389 </target>
3390
3391
3392 <!-- ======================= Axis Targets ============================ -->
3393
3394 <target name="prepare-axis" depends="init">
3395 <echo>Checking for existence of: ${packages.home}/axis/.flagfile</echo>
3396 <if>
3397 <bool>
3398 <not><available file="${packages.home}/axis/.flagfile"/></not>
3399 </bool>
3400
3401 <!--
3402 <get src="${gsorg.root}/gs3files/${axis.zip.version}"
3403 dest="${packages.home}/${axis.zip.version}"
3404 usetimestamp="true"/>
3405 -->
3406 <if>
3407 <bool>
3408 <os family="mac" />
3409 </bool>
3410 <exec executable="curl" failonerror="true">
3411 <arg value="--insecure"/>
3412 <arg value="-o"/>
3413 <arg value="${packages.home}/${axis.zip.version}"/>
3414 <arg value="${gsorg.root}/gs3files/${axis.zip.version}"/>
3415 </exec>
3416 <else>
3417 <exec executable="${wget}" failonerror="true">
3418 <arg value="-P"/><!-- output dir, alt: minus-minus-directory-prefix -->
3419 <arg value="${packages.home}"/>
3420 <arg value="--no-check-certificate"/>
3421 <arg value="${gsorg.root}/gs3files/${axis.zip.version}"/>
3422 </exec>
3423 </else>
3424 </if>
3425
3426 <unzip src="${packages.home}/${axis.zip.version}"
3427 dest="${packages.home}"/>
3428 <move todir="${packages.home}/axis">
3429 <fileset dir="${packages.home}/${axis.dir.version}"/>
3430 </move>
3431 <!-- install axis into greenstone web app -->
3432 <copy todir="${web.lib}">
3433 <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/lib">
3434 <include name="*.jar"/>
3435 </fileset>
3436 </copy>
3437 <copy todir="${web.home}">
3438 <fileset dir="${packages.home}/axis/webapps/axis/">
3439 <include name="*.jsp"/>
3440 <include name="*.jws"/>
3441 </fileset>
3442 </copy>
3443 <copy tofile="${web.home}/axis.html" file="${packages.home}/axis/webapps/axis/index.html"/>
3444 <copy todir="${web.classes}">
3445 <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/classes">
3446 <include name="*.properties"/>
3447 </fileset>
3448 </copy>
3449 <echo file="${packages.home}/axis/.flagfile">
3450 the timestamp of this file is the time that axis was extracted from the zip files.
3451 it is used to figure out whether the files need to be refreshed or not in `ant prepare-axis`
3452 </echo>
3453
3454 <else>
3455 <echo>Axis has been prepared, will not prepare</echo>
3456 <echo>Delete ${packages.home}/axis/.flagfile to force refresh</echo>
3457 </else>
3458
3459 </if>
3460 </target>
3461
3462 <target name="soap-deploy-site" depends="init,get-sitename,get-siteuri,get-webservices,create-deployment-files,deploy-site"
3463 description="Deploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work."/>
3464
3465 <target name="deploy-site">
3466 <java classname="org.apache.axis.client.AdminClient">
3467 <classpath refid="compile.classpath"/>
3468 <arg value="-l"/>
3469 <arg value="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/servlet/AxisServlet"/>
3470 <arg file="${basedir}/resources/soap/deploy.wsdd"/>
3471 </java>
3472 <delete file="${basedir}/resources/soap/deploy.wsdd"/> <!--clean up, no longer used-->
3473 </target>
3474
3475 <target name="soap-undeploy-site" depends="get-undeploy-service-name"
3476 description="Undeploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work.">
3477 <filter token="servicesname" value="${axis.undeploy.servicename}"/>
3478 <copy file="${basedir}/resources/soap/undeploy-site.wsdd.template"
3479 tofile="${basedir}/resources/soap/undeploy.wsdd"
3480 filtering="true"
3481 overwrite="true"/>
3482 <java classname="org.apache.axis.client.AdminClient">
3483 <classpath refid="compile.classpath"/>
3484 <arg value="-l"/>
3485 <arg value="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/servlet/AxisServlet"/>
3486 <arg file="${basedir}/resources/soap/undeploy.wsdd"/>
3487 </java>
3488 <delete file="${basedir}/resources/soap/undeploy.wsdd"/> <!--clean up, no longer used-->
3489 </target>
3490
3491 <!-- this target used to deploy the default web service SOAPServer (base.webservice.name) on the localsite server
3492 with the default servicename of localsite-->
3493 <target name="deploy-localsite" depends="init"
3494 description="Deploy the SOAP server for localsite. Will start and stop Tomcat.">
3495 <antcall target="force-start-tomcat"/>
3496 <echo>Deploying ${base.webservice.name} web services for localsite under service name: localsite</echo>
3497 <antcall target="create-deployment-files">
3498 <param name="axis.sitename" value="localsite"/>
3499 <param name="axis.servicesname" value="${base.webservice.name}"/>
3500 <param name="axis.siteuri" value="localsite"/>
3501 </antcall>
3502 <antcall target="deploy-site">
3503 <param name="axis.sitename" value="localsite"/>
3504 <param name="axis.servicesname" value="${base.webservice.name}"/>
3505 <param name="axis.siteuri" value="localsite"/>
3506 </antcall>
3507 <echo>The Greenstone server has been started up. If you do not want it running, please type: ant stop.</echo>
3508 </target>
3509
3510 <target name="get-sitename" unless="axis.sitename">
3511 <input addproperty="axis.sitename" defaultvalue="localsite">What site do you want to deploy services for?
3512Press Enter for default:localsite</input>
3513 </target>
3514
3515 <target name="get-undeploy-service-name" unless="axis.undeploy.servicename">
3516 <input addproperty="axis.undeploy.servicename" defaultvalue="localsite">Please enter the full name of the service you wish to undeploy.
3517To find out which web services you've got deployed, point your browser to ${default.server.protocol}://${tomcat.server}:${default.tomcat.port}/greenstone3/services
3518Or press Enter for undeploying the default:localsite /&gt;</input>
3519 <echo>Name of service to undeploy: ${axis.undeploy.servicename}</echo>
3520 </target>
3521
3522 <target name="get-webservices" unless="axis.servicesname">
3523 <input addproperty="axis.servicesname" defaultvalue="${base.webservice.name}">Which set of web services do you want to deploy?
3524Choose from: ${web.services.list}
3525Or press Enter for default:${base.webservice.name} /&gt;</input>
3526 <echo>${axis.servicesname}</echo>
3527 </target>
3528
3529 <target name="get-siteuri" depends="get-sitename,get-webservices" unless="axis.siteuri">
3530 <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>
3531 <echo>Site: ${axis.sitename}, services: ${axis.servicesname}, servicesname: ${axis.siteuri}</echo>
3532 </target>
3533
3534 <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">
3535 <condition property="soap.method" value="provider='java:MSG' style='message' use='literal'">
3536 <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
3537 </condition>
3538
3539 <!--everything else defaults to java:RPC at present-->
3540 <condition property="soap.method" value="provider='java:RPC'">
3541 <not>
3542 <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
3543 </not>
3544 </condition>
3545 </target>
3546
3547 <target name="create-deployment-files" depends="set-soapmethod" if="axis.sitename">
3548 <filter token="sitename" value="${axis.sitename}"/>
3549 <filter token="siteuri" value="${axis.siteuri}"/>
3550 <filter token="servicesname" value="${axis.servicesname}"/>
3551 <filter token="soapmethod" value="${soap.method}"/>
3552 <copy file="${basedir}/resources/soap/site.wsdd.template"
3553 tofile="${basedir}/resources/soap/deploy.wsdd"
3554 filtering="true"
3555 overwrite="true"/>
3556 <!-- create the java files and compile them -->
3557 <copy file="${basedir}/resources/java/${axis.servicesname}.java.in"
3558 tofile="${src.gsdl3.home}/${axis.servicesname}${axis.sitename}.java"
3559 filtering="true"
3560 overwrite="true"/>
3561 <mkdir dir="${build.home}"/>
3562 <javac srcdir="${src.home}"
3563 destdir="${build.home}"
3564 includeantruntime="${compile.includeantruntime}"
3565 debug="${compile.debug}"
3566 deprecation="${compile.deprecation}"
3567 optimize="${compile.optimize}"
3568 encoding="${compile.encoding}">
3569 <compilerarg line="${compile.javac.flags}"/>
3570 <classpath refid="compile.classpath"/>
3571 <include name="org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.java" />
3572 </javac>
3573 <mkdir dir="${web.classes}/org/greenstone/gsdl3"/>
3574 <copy file="${build.home}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
3575 tofile="${web.classes}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
3576 overwrite="true" />
3577 </target>
3578
3579
3580 <!-- ====================== Core targets ============================== -->
3581 <!-- core targets refer to the core gsdl3 java src -->
3582
3583 <target name="prepare-core"/>
3584
3585 <target name="configure-core"/>
3586
3587 <target name="update-core" depends="init,svnupdate-core,clean-core,compile-core"
3588 description="Update only the Greenstone core" />
3589
3590 <target name="svnupdate-core" unless="nosvn.mode">
3591 <exec executable="svn">
3592 <arg line="${global-svn-args}"/>
3593 <arg value="update"/>
3594 <arg value="${basedir}"/>
3595 <arg value="-r"/><arg value="${branch.revision}"/>
3596 </exec>
3597 </target>
3598
3599 <target name="clean-core"
3600 description="Clean only the Greenstone core">
3601 <!-- should this delete the gsdl3.jar from web/WEB-INF?? -->
3602 <delete dir="${build.home}"/>
3603 </target>
3604
3605 <target name="compile-core" depends="needs-gs3-devel,init"
3606 description="Compile only the Greenstone core">
3607 <mkdir dir="${build.home}"/>
3608
3609 <if><bool><istrue value="${with.jni}"/></bool>
3610 <javac srcdir="${src.home}"
3611 destdir="${build.home}"
3612 includeantruntime="${compile.includeantruntime}"
3613 debug="${compile.debug}"
3614 deprecation="${compile.deprecation}"
3615 optimize="${compile.optimize}"
3616 encoding="${compile.encoding}">
3617 <compilerarg line="${compile.javac.flags}"/>
3618 <classpath>
3619 <path refid="compile.classpath"/>
3620 </classpath>
3621 </javac>
3622 <else>
3623 <property name="gsprefix" value=""/>
3624 <javac srcdir="${src.home}"
3625 destdir="${build.home}"
3626 includeantruntime="${compile.includeantruntime}"
3627 debug="${compile.debug}"
3628 deprecation="${compile.deprecation}"
3629 optimize="${compile.optimize}"
3630 encoding="${compile.encoding}">
3631 <compilerarg line="${compile.javac.flags}"/>
3632 <classpath>
3633 <path refid="compile.classpath"/>
3634 </classpath>
3635 <exclude name="org/greenstone/gsdl3/service/GS2MGPPRetrieve.java"/>
3636 <exclude name="org/greenstone/gsdl3/service/GS2MGPPSearch.java"/>
3637 <exclude name="org/greenstone/gsdl3/service/GS2MGSearch.java"/>
3638 <exclude name="org/greenstone/gsdl3/service/GS2MGRetrieve.java"/>
3639 <exclude name="org/greenstone/gsdl3/service/GoogleNgramMGPPSearch.java"/>
3640 <exclude name="org/greenstone/gsdl3/service/PhindPhraseBrowse.java"/>
3641 <exclude name="org/greenstone/gsdl3/util/GDBMWrapper.java"/>
3642 </javac>
3643 </else>
3644 </if>
3645 <jar destfile="${build.home}/gsdl3.jar">
3646 <fileset dir="${build.home}">
3647 <include name="org/greenstone/gsdl3/**"/>
3648 <include name="org/flax/**"/>
3649 <exclude name="**/Test.class"/>
3650 </fileset>
3651 <manifest>
3652 <attribute name="Built-By" value="${user.name}" />
3653 </manifest>
3654 </jar>
3655 <copy file="${build.home}/gsdl3.jar" todir="${web.lib}"/>
3656
3657 <antcall target="googlesignin-jar-with-dependencies" />
3658 <copy file="${build.home}/googlesignin-jdbcrealm.jar" todir="${catalina.home}/lib"/>
3659
3660 <jar destfile="${build.home}/gutil.jar">
3661 <fileset dir="${build.home}">
3662 <include name="org/greenstone/util/**"/>
3663 </fileset>
3664 <manifest>
3665 <attribute name="Built-By" value="${user.name}" />
3666 </manifest>
3667 </jar>
3668 <copy file="${build.home}/gutil.jar" todir="${web.lib}"/>
3669
3670 <!-- copy the localsite server in case we need it -->
3671 <copy file="${build.home}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" tofile="${web.classes}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" />
3672
3673 <!-- Greenstone Administrator Interface -->
3674 <jar destfile="${build.home}/GAI.jar">
3675 <fileset dir="${build.home}">
3676 <include name="org/greenstone/admin/**"/>
3677 </fileset>
3678 <manifest>
3679 <attribute name="Built-By" value="${user.name}" />
3680 </manifest>
3681 </jar>
3682 <copy file="${build.home}/GAI.jar" todir="${web.lib}"/>
3683 <copy file="${build.home}/GAI.jar" todir="${admin.dir}"/>
3684 <jar destfile="${build.home}/phind.jar">
3685 <fileset dir="${build.home}">
3686 <include name="org/greenstone/applet/phind/**"/>
3687 </fileset>
3688 <manifest>
3689 <attribute name="Built-By" value="${user.name}" />
3690 </manifest>
3691 </jar>
3692 <mkdir dir="${web.applet}"/>
3693 <copy file="${build.home}/phind.jar" todir="${web.applet}"/>
3694 <!-- phind also needs xercesImpl.jar and xml-apis.jar to be in web/applet -->
3695 <if>
3696 <bool><istrue value="${tomcat.islocal}"/></bool>
3697 <if><bool><available file="${catalina.home}/lib/xercesImpl.jar"/></bool><!-- moved for solr -->
3698 <copy file="${catalina.home}/lib/xercesImpl.jar" todir="${web.applet}"/>
3699 <copy file="${catalina.home}/lib/xml-apis.jar" todir="${web.applet}"/>
3700
3701 <else><!-- get from default GS3 web lib location-->
3702 <copy file="${web.lib}/xercesImpl.jar" todir="${web.applet}"/>
3703 <copy file="${web.lib}/xml-apis.jar" todir="${web.applet}"/>
3704 </else>
3705 </if>
3706 </if>
3707
3708
3709 <!-- skip anttasks for now
3710 <jar destfile="${build.home}/anttasks.jar">
3711 <fileset dir="${build.home}">
3712 <include name="org/greenstone/anttasks/**"/>
3713 </fileset>
3714 <manifest>
3715 <attribute name="Built-By" value="${user.name}" />
3716 </manifest>
3717 </jar>
3718 <copy file="${build.home}/anttasks.jar" todir="${basedir}/lib/java"/>-->
3719 <jar destfile="${build.home}/gsdl3test.jar">
3720 <fileset dir="${build.home}">
3721 <include name="org/greenstone/gsdl3/**/*Test.class"/>
3722 <include name="org/greenstone/testing/**"/>
3723 </fileset>
3724 <manifest>
3725 <attribute name="Built-By" value="${user.name}" />
3726 </manifest>
3727 </jar>
3728 <jar destfile="${build.home}/server.jar">
3729 <fileset dir="${build.home}">
3730 <include name="org/greenstone/server/**"/>
3731 <include name="org/greenstone/util/**"/>
3732 </fileset>
3733 <fileset file="${basedir}/resources/java/server.properties"/>
3734 <manifest>
3735 <attribute name="Built-By" value="${user.name}"/>
3736 </manifest>
3737 </jar>
3738 <copy file="${build.home}/server.jar" todir="${basedir}"/>
3739 </target>
3740
3741 <target name="googlesignin-checkforchanges" >
3742 <uptodate property="googlesignin-nochanges" targetfile="${build.home}/googlesignin-jdbcrealm.jar">
3743 <srcfiles dir="${build.home}" includes="org/greenstone/gsdl3/GoogleSigninJDBCRealm.class"/>
3744 </uptodate>
3745 </target>
3746
3747 <target name="googlesignin-jar-with-dependencies" depends="init,googlesignin-checkforchanges" unless="googlesignin-nochanges">
3748 <path id="googlesignin-jar-dependencies">
3749 <fileset dir="${web.lib}">
3750 <includesfile name="${jarsupport.home}/google-api-client-jars/jar-list.txt"/>
3751 </fileset>
3752 </path>
3753
3754 <unzip dest="${web.lib}/unjarred">
3755 <patternset>
3756 <exclude name="META-INF/*.SF"/>
3757 </patternset>
3758 <!-- fileset to include ... -->
3759 <path refid="googlesignin-jar-dependencies"/>
3760 </unzip>
3761
3762 <path id="googlesignin-unjarred">
3763 <fileset dir="${web.lib}/unjarred">
3764 </fileset>
3765 </path>
3766
3767 <jar destfile="${build.home}/googlesignin-jdbcrealm.jar">
3768 <fileset dir="${build.home}">
3769 <include name="org/greenstone/gsdl3/GoogleSigninJDBCRealm.class"/>
3770 </fileset>
3771 <fileset dir="${src.home}">
3772 <include name="org/greenstone/gsdl3/mbeans-descriptor.xml"/>
3773 </fileset>
3774 <path refid="googlesignin-unjarred" />
3775 <manifest>
3776 <attribute name="Built-By" value="${user.name}" />
3777 </manifest>
3778 </jar>
3779 <delete dir="${web.lib}/unjarred" quiet="true"/>
3780
3781 </target>
3782
3783 <!-- === Eclipse targets == -->
3784 <target name="setup-for-eclipse">
3785
3786 <filter token="gsdlhome" value="${gs2build.home}"/>
3787 <filter token="gsdl3srchome" value="${basedir}"/>
3788 <filter token="gsdl3home" value="${basedir}/web"/>
3789
3790 <if>
3791 <bool><not><available file="${basedir}/TransformingLibrary.launch"/></not></bool>
3792 <copy file="${basedir}/TransformingLibrary.launch.in" tofile="${basedir}/TransformingLibrary.launch" filtering="true" overwrite="true"/>
3793 </if>
3794<!--
3795 <if>
3796 <bool><not><available file="${basedir}/LibraryCommandline.launch"/></not></bool>
3797 <copy file="${basedir}/LibraryCommandline.launch.in" tofile="${basedir}/LibraryCommandline.launch" filtering="true" overwrite="true"/>
3798 </if>
3799-->
3800 </target>
3801
3802 <!-- ================== Packages targets ================================ -->
3803 <!-- these targets refer to the greenstone source packages - these need
3804 updating less often, so are in separate targets to the core -->
3805
3806 <target name="prepare-wget-for-windows">
3807 <exec executable="svn" osfamily="windows" dir="${basedir}/bin/windows">
3808 <arg line="${global-svn-args}"/>
3809 <arg value="export"/>
3810 <arg value="-r"/><arg value="${branch.revision}"/>
3811 <arg value="${svn.root}/main/${branch.path}/binaries/windows/bin/wget.exe"/>
3812 </exec>
3813 <exec executable="svn" osfamily="windows" dir="${basedir}/bin/windows">
3814 <arg line="${global-svn-args}"/>
3815 <arg value="export"/>
3816 <arg value="-r"/><arg value="${branch.revision}"/>
3817 <arg value="${svn.root}/main/${branch.path}/binaries/windows/bin/wgetrc"/>
3818 <arg value="wgetrc"/>
3819 </exec>
3820
3821 </target>
3822 <target name="prepare-packages" depends="init"/>
3823
3824 <target name="update-packages" depends="init,svnupdate-packages,configure-packages,clean-packages,compile-packages"
3825 description="Update only the source packages"/>
3826
3827 <target name="svnupdate-packages" unless="nosvn.mode">
3828 <exec executable="svn">
3829 <arg line="${global-svn-args}"/>
3830 <arg value="update"/>
3831 <arg value="${src.packages.home}"/>
3832 <arg value="-r"/><arg value="${branch.revision}"/>
3833 </exec>
3834 </target>
3835
3836 <target name="prepare-binaries" depends="prepare-bins-unix"/>
3837
3838 <target name="prepare-bins-unix" depends="init" if="current.os.isunix">
3839 <condition property="bitness.suffix" value="64" else="32">
3840 <matches string="${os.arch}" pattern="64"/>
3841 </condition>
3842 <condition property="os.folder.name" value="mac" else="linux"> <!-- checkout from dir: mac or linux -->
3843 <equals arg1="${os.bin.dir}" arg2="darwin" trim="true"/>
3844 </condition>
3845 <mkdir dir="${gs2build.home}/bin/${os.bin.dir}"/> <!-- mkdir darwin or linux -->
3846 <exec executable="svn" dir="${gs2build.home}/bin/${os.bin.dir}">
3847 <arg line="${global-svn-args}"/>
3848 <arg value="export"/>
3849 <arg value="-r"/><arg value="${branch.revision}"/>
3850 <arg value="${svn.root}/main/${branch.path}/binaries/${os.folder.name}/yaz/yaz-client-x${bitness.suffix}"/> <!-- checkout from dir: mac or linux -->
3851 <arg value="yaz-client"/>
3852 </exec>
3853 </target>
3854
3855 <target name="configure-packages" depends="init,configure-javagdbm"
3856 description="Configure only the packages."/>
3857
3858 <target name="configure-javagdbm" if="${with.jni}">
3859 <echo>
3860 Configuring JavaGDBM
3861 </echo>
3862
3863 <exec executable="${javagdbm.home}/configure" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
3864 <arg value="--prefix=${basedir}"/>
3865 <arg value="--libdir=${lib.jni}"/>
3866 <arg value="--with-gdbm=${gdbm.home}"/>
3867 <arg line="${cross.configure.args}"/>
3868 </exec>
3869 </target>
3870
3871 <target name="clean-packages" depends="init,clean-javagdbm" description="Clean only the packages"/>
3872
3873 <target name="clean-javagdbm" depends="init">
3874 <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
3875 <exec executable="make" os="${os.unix}"
3876 dir="${javagdbm.home}" failonerror="true">
3877 <arg value="clean"/>
3878 </exec>
3879 </if>
3880 </target>
3881
3882 <target name="distclean-packages" depends="init,distclean-javagdbm" description="Distclean only the packages"/>
3883
3884 <target name="distclean-javagdbm" depends="init">
3885 <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
3886 <exec executable="make" os="${os.unix}"
3887 dir="${javagdbm.home}" failonerror="true">
3888 <arg value="distclean"/>
3889 </exec>
3890 </if>
3891 </target>
3892
3893 <target name="compile-packages" description="Compile only the source packages">
3894 <!-- javagdbm -->
3895 <antcall target="compile-javagdbm"/>
3896 <!-- Search4j -->
3897 <antcall target="compile-search4j"/>
3898 </target>
3899
3900 <target name="compile-javagdbm" description="Compile JavaGDBM" if="${with.jni}">
3901
3902 <!-- unix: -->
3903 <echo>compile javagdbm</echo>
3904 <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
3905 <arg value="JAVACOPTIONS=-encoding UTF8"/>
3906 <env key="JAVA_HOME" path="${env.JAVA_HOME}"/>
3907 </exec>
3908 <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
3909 <arg value="install"/>
3910 </exec>
3911
3912 <!-- windows: Calling without the "compile" argument first will run winMake.bat with
3913 "all" which will then perform both the compile AND link targets in jni/win32.mak
3914 (thereby also generating gdbmjava.dll). Then we run the same command with
3915 the "install" argument to copy the gdbmjava.dll into the correct location. -->
3916 <echo>Windows: compile javagdbm</echo>
3917 <exec executable="${javagdbm.home}/winMake.bat" osfamily="windows" dir="${javagdbm.home}" failonerror="true">
3918 <env key="JAVA_HOME" path="${env.JAVA_HOME}"/>
3919 <env key="GSDL3SRCHOME" path="${basedir}"/>
3920 </exec>
3921 <exec executable="${javagdbm.home}/winMake.bat" osfamily="windows" dir="${javagdbm.home}" failonerror="true">
3922 <env key="GSDL3SRCHOME" path="${basedir}"/>
3923 <arg value="install"/>
3924 </exec>
3925
3926 <!-- install the jar file -->
3927 <echo>Install the javagdbm jar file ${javagdbm.home}/javagdbm.jar ${lib.jni}</echo>
3928 <copy file="${javagdbm.home}/javagdbm.jar" todir="${lib.jni}"/>
3929 </target>
3930
3931 <target name="compile-search4j">
3932
3933 <!-- windows -->
3934 <if><bool><istrue value="${current.os.iswindows}"/></bool>
3935 <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
3936 <arg value="/f"/>
3937 <arg value="win32.mak"/>
3938 <arg value='BINDIR="${basedir}\bin"'/>
3939 <arg value='LIBDIR="${basedir}\lib"'/>
3940 </exec>
3941 <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
3942 <arg value="/f"/>
3943 <arg value="win32.mak"/>
3944 <arg value="install"/>
3945 <arg value='BINDIR="${basedir}\bin"'/>
3946 <arg value='LIBDIR="${basedir}\lib"'/>
3947 </exec>
3948
3949 <!-- unix -->
3950 <else><if><bool><istrue value="${current.os.isunix}"/></bool>
3951 <exec executable="${src.packages.home}/search4j/configure" dir="${src.packages.home}/search4j" failonerror="true">
3952 <arg value="--bindir=${basedir}/bin"/>
3953 <arg value="--libdir=${basedir}/lib"/>
3954 <arg value="${static.arg}"/>
3955 <arg line="${cross.configure.args}"/>
3956 </exec>
3957 <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true"/>
3958 <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true">
3959 <arg value="install"/>
3960 </exec>
3961
3962 <!-- else warn -->
3963 <else>
3964 <fail>this target does not support the current os</fail>
3965
3966 </else></if></else></if>
3967
3968 </target>
3969
3970 <target name="install-auxiliary-jar-files" depends="init">
3971
3972 <if>
3973 <bool><available file="${mg.home}/mg.jar"/></bool>
3974 <copy file="${mg.home}/mg.jar" todir="${lib.jni}"/>
3975 </if>
3976
3977 <if>
3978 <bool><available file="${mgpp.home}/mgpp.jar"/></bool>
3979 <copy file="${mgpp.home}/mgpp.jar" todir="${lib.jni}"/>
3980 </if>
3981
3982 <copy file="${lucene.home}/LuceneWrapper4.jar" todir="${web.lib}"/>
3983 </target>
3984
3985 <target name="install-jni-files" depends="init" if="${with.jni}">
3986 <antcall target="install-jni-files-linux"/>
3987 <antcall target="install-jni-files-windows"/>
3988 <antcall target="install-jni-files-macos"/>
3989 </target>
3990
3991 <target name="install-jni-files-linux" depends="init" if="current.os.isunixnotmac">
3992
3993 <if>
3994
3995 <bool><equals arg1="${os.bin.dir}" arg2="windows"/></bool>
3996 <!-- cross compiling to windows -->
3997 <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
3998 <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
3999 <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
4000 <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
4001 <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
4002 <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
4003
4004 <else>
4005 <!-- otherwise do the usual Unix copies -->
4006 <copy file="${mg.home}/jni/libmgretrievejni.so" todir="${lib.jni}"/>
4007 <copy file="${mg.home}/jni/libmgsearchjni.so" todir="${lib.jni}"/>
4008 <copy file="${mg.home}/jni/libmgpassjni.so" todir="${lib.jni}"/>
4009 <copy file="${mgpp.home}/jni/libmgppretrievejni.so" todir="${lib.jni}"/>
4010 <copy file="${mgpp.home}/jni/libmgppsearchjni.so" todir="${lib.jni}"/>
4011 <copy file="${mgpp.home}/jni/libmgpppassjni.so" todir="${lib.jni}"/>
4012 </else>
4013 </if>
4014
4015
4016 </target>
4017 <target name="install-jni-files-windows" depends="init" if="current.os.iswindows">
4018 <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
4019 <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
4020 <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
4021 <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
4022 <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
4023 <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
4024 </target>
4025 <target name="install-jni-files-macos" depends="init" if="current.os.ismac">
4026 <copy file="${mg.home}/jni/libmgretrievejni.jnilib" todir="${lib.jni}"/>
4027 <copy file="${mg.home}/jni/libmgsearchjni.jnilib" todir="${lib.jni}"/>
4028 <copy file="${mg.home}/jni/libmgpassjni.jnilib" todir="${lib.jni}"/>
4029 <copy file="${mgpp.home}/jni/libmgppretrievejni.jnilib" todir="${lib.jni}"/>
4030 <copy file="${mgpp.home}/jni/libmgppsearchjni.jnilib" todir="${lib.jni}"/>
4031 <copy file="${mgpp.home}/jni/libmgpppassjni.jnilib" todir="${lib.jni}"/>
4032 </target>
4033
4034 <!-- ========common-src targets =================================-->
4035 <!-- these are used to get common-src (for indexers, gdbm, sqlite etc) when
4036 collection building is not enabled -->
4037
4038 <target name="update-common-src" depends="init" if="collection.building.disabled">
4039 </target>
4040
4041 <target name="svnupdate-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
4042 <exec executable="svn">
4043 <arg line="${global-svn-args}"/>
4044 <arg value="update"/>
4045 <arg value="${common.src.home}"/>
4046 <arg value="-r"/><arg value="${branch.revision}"/>
4047 </exec>
4048 </target>
4049
4050 <target name="prepare-common-src" depends="init" if="collection.building.disabled" unless="common.src.present">
4051 <antcall target="checkout-common-src"/>
4052 <antcall target="unzip-windows-packages"/>
4053 </target>
4054
4055 <target name="checkout-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
4056 <echo>checking out common-src</echo>
4057 <exec executable="svn">
4058 <arg line="${global-svn-args}"/>
4059 <arg value="checkout"/>
4060 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src"/>
4061 <arg value="common-src"/>
4062 <arg value="-r"/><arg value="${branch.revision}"/>
4063 </exec>
4064 </target>
4065
4066 <target name="configure-common-src" depends="envbased-gnomelib-allargs-prop,init">
4067<!--
4068 <echo>cross configure args: ${cross.configure.args}</echo>
4069-->
4070 <exec executable="${common.src.home}/configure" os="${os.unix}"
4071 dir="${common.src.home}" failonerror="true">
4072 <arg value="--prefix=${common.src.binhome}"/> <!-- what value to use?? -->
4073 <arg value="--bindir=${common.src.binhome}/bin/${os.bin.dir}"/> <!-- what value to use?? -->
4074 <arg line="${gs2.opt.args}"/>
4075 <arg line="${static.arg}"/>
4076 <arg line="${cross.configure.args}"/>
4077 <arg line="${allargs}"/>
4078 </exec>
4079 </target>
4080
4081 <target name="clean-common-src" depends="init">
4082 <!-- unix: -->
4083 <if><bool><available file="${common.src.home}/Makefile"/></bool>
4084 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
4085 <arg value="clean"/>
4086 </exec>
4087 </if>
4088 <!-- windows: -->
4089 <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
4090 <arg value="/f"/>
4091 <arg value="win32.mak"/>
4092 <arg value="clean"/>
4093 <arg value="GSDLHOME=${common.src.binhome}"/>
4094 </exec>
4095 </target>
4096 <target name="distclean-common-src" depends="init">
4097 <!-- unix: -->
4098 <if><bool><available file="${common.src.home}/Makefile"/></bool>
4099 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
4100 <arg value="distclean"/>
4101 </exec>
4102 </if>
4103 <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->
4104 <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
4105 <arg value="/f"/>
4106 <arg value="win32.mak"/>
4107 <arg value="clean"/>
4108 <arg value="GSDLHOME=${common.src.binhome}"/>
4109 </exec>
4110 </target>
4111 <target name="compile-common-src" depends="needs-gs3-devel,envbased-devel-props,init">
4112 <!-- unix: -->
4113 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
4114 <arg value="${gs2.compile.target}"/>
4115 <arg value="JAVA_HOME=${env.JAVA_HOME}"/>
4116 </exec>
4117 <!-- windows: -->
4118 <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
4119 <arg value="/f"/>
4120 <arg value="win32.mak"/>
4121 <arg value="VISUAL_STUDIO_MAJORVERSION=${visualstudio.majorversion}"/>
4122 <arg value="JAVA_HOME=${env.JAVA_HOME}"/>
4123
4124 <arg value="GSDLHOME=${common.src.binhome}"/>
4125 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
4126 <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
4127 <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
4128 <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
4129 <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
4130 </exec>
4131 </target>
4132
4133 <!-- ======= collection-building targets ===========================-->
4134
4135 <target name="update-collection-building" if="collection.building.enabled"
4136 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"
4137 description="Update (SVN update, configure, compile etc) only the collection building components"/>
4138
4139 <target name="svnupdate-collection-building" if="collection.building.enabled" depends="init,svnupdate-gs2build,svnupdate-gli" unless="nosvn.mode"
4140 description="SVN update the collection building components">
4141 </target>
4142
4143 <target name="prepare-collection-building" depends="init,prepare-gs2build,prepare-gli" if="collection.building.enabled">
4144 </target>
4145
4146 <target name="configure-collection-building" depends="init,configure-build-src" if="collection.building.enabled"
4147 description="Configure the collection building components">
4148 </target>
4149
4150 <target name="clean-collection-building" depends="init,clean-gli,clean-build-src"
4151 description="Clean only the collection building components"
4152 if="collection.building.enabled"/>
4153
4154 <target name="distclean-collection-building" depends="init,clean-build-src,distclean-build-src"
4155 description="Distclean only the collection building components"
4156 if="collection.building.enabled"/>
4157
4158 <target name="compile-collection-building" depends="needs-gs3-devel,envbased-devel-props,init,compile-build-src,compile-gli" if="collection.building.enabled"
4159 description="Compile only the collection building components">
4160 <!-- make install for common-src -->
4161 <!-- unix: -->
4162 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
4163 <arg value="${gs2.install.target}"/>
4164 </exec>
4165
4166 <!-- windows: -->
4167 <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
4168 <arg value="/f"/>
4169 <arg value="win32.mak"/>
4170 <arg value="install"/>
4171 <arg value="VISUAL_STUDIO_MAJORVERSION=${visualstudio.majorversion}"/>
4172 <arg value="GSDLHOME=${gs2build.home}"/>
4173 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
4174 <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
4175 <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
4176 <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
4177 <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
4178 <!--
4179 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
4180 <arg value="USE_SQLITE=0"/>--> <!-- why is this not on by default? -->
4181 </exec>
4182
4183 <!-- install gs2build indexers for windows -->
4184 <if>
4185 <bool><istrue value="${current.os.iswindows}"/></bool>
4186 <copy todir="${gs2build.home}/bin/windows">
4187 <fileset dir="${gs2build.home}/common-src/indexers/bin">
4188 <include name="*.*"/>
4189 </fileset>
4190 </copy>
4191 </if>
4192
4193 <!-- LuceneWrapper jar file not installed by default -->
4194 <mkdir dir="${gs2build.home}/bin/java"/>
4195 <copy file="${lucene.home}/LuceneWrapper4.jar" todir="${gs2build.home}/bin/java"/>
4196
4197 </target>
4198
4199 <!-- ============== gli targets ================================= -->
4200
4201 <target name="svnupdate-gli" if="collection.building.enabled" depends="init" unless="nosvn.mode">
4202
4203 <exec executable="svn">
4204 <arg line="${global-svn-args}"/>
4205 <arg value="update"/>
4206 <arg value="${gli.home}"/>
4207 <arg value="-r"/><arg value="${branch.revision}"/>
4208 </exec>
4209
4210 </target>
4211
4212 <target name="prepare-gli" depends="init" if="collection.building.enabled" unless="gli.present">
4213 <!-- checkout -->
4214 <if><bool><and><not><istrue value="${nosvn.mode}"/></not><isset property="with.gli.and.gems"/></and></bool>
4215
4216 <exec executable="svn">
4217 <arg line="${global-svn-args}"/>
4218 <arg value="checkout"/>
4219 <arg value="${svn.root}/main/${branch.path}/gli"/>
4220 <arg value="-r"/><arg value="${branch.revision}"/>
4221 </exec>
4222
4223 </if>
4224 </target>
4225
4226 <target name="clean-gli" depends="init" if="collection.building.enabled">
4227 <!-- gli -->
4228 <property name="gli.home" value="${basedir}/gli"/>
4229 <!-- linux -->
4230 <exec executable="clean.sh" os="${os.unix}" dir="${gli.home}"
4231 resolveExecutable="true" failonerror="true"/>
4232 <!-- windows -->
4233 <exec executable="clean.bat" osfamily="windows" dir="${gli.home}"
4234 resolveExecutable="true" failonerror="true"/>
4235 </target>
4236
4237 <target name="compile-gli" depends="needs-gs3-devel,init" if="collection.building.enabled">
4238 <if><bool><isset property="with.gli.and.gems"/></bool>
4239 <!-- gli -->
4240 <property name="gli.home" value="${basedir}/gli"/>
4241
4242 <!-- linux -->
4243 <exec executable="makegli.sh" os="${os.unix}" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
4244 <!--remote gli-->
4245 <exec executable="makejar.sh" os="${os.unix}" dir="${gli.home}"
4246 resolveExecutable="true" failonerror="true"/>
4247 <!-- windows -->
4248 <exec executable="makegli.bat" osfamily="windows" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
4249 <!--remote gli-->
4250 <exec executable="makejar.bat" osfamily="windows" dir="${gli.home}"
4251 resolveExecutable="true" failonerror="true"/>
4252 <copy file="${gli.home}/GLIServer.jar" todir="${gs2build.home}/bin/java" />
4253 </if>
4254 </target>
4255 <target name="install-gli-for-webswing" description="Compile and install GLI.jar into webswing ext" depends="compile-gli">
4256 <copy file="${gli.home}/GLI.jar" todir="${web.writablehome}/ext/webswing/apps/gli" />
4257 </target>
4258 <target name="gli" description="Run the Greenstone Librarian Interface" depends="init" if="collection.building.enabled">
4259 <exec executable="${basedir}/gli/gli.sh" os="${os.linux},${os.solaris}" dir="${basedir}/gli" spawn="true">
4260 <env key="gsdl3path" path="${basedir}"/>
4261 <env key="gsdlpath" path="${gs2build.home}"/>
4262 </exec>
4263 <exec executable="${basedir}/gli/gli.sh" os="${os.mac}" dir="${basedir}/gli" spawn="true">
4264 <env key="gsdl3path" path="${basedir}"/>
4265 <env key="gsdlpath" path="${gs2build.home}"/>
4266 <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${gdbm.home}/lib"/>
4267 </exec>
4268 <exec executable="${basedir}/gli/gli.bat" osfamily="windows" dir="${basedir}/gli" spawn="true">
4269 <env key="GSDL3PATH" path="${basedir}"/>
4270 <env key="GSDLPATH" path="${gs2build.home}"/>
4271 </exec>
4272 <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.
4273 </echo>
4274 </target>
4275
4276 <!-- ================ gs2build targets =========================== -->
4277
4278 <target name="svnupdate-gs2build" if="collection.building.enabled" depends="init" unless="nosvn.mode">
4279 <echo>svn updating gs2build</echo>
4280 <exec executable="svn">
4281 <arg line="${global-svn-args}"/>
4282 <arg value="update"/>
4283 <arg value="${gs2build.home}"/>
4284 <arg value="-r"/><arg value="${branch.revision}"/>
4285 </exec>
4286 </target>
4287
4288 <target name="prepare-gs2build" depends="init" if="collection.building.enabled" unless="gs2build.present">
4289 <antcall target="checkout-gs2build"/>
4290 <antcall target="prepare-pdfbox"/>
4291 <antcall target="prepare-imagemagick"/> <!-- has to be done before calling prepare-gnome-lib -->
4292 <antcall target="prepare-gnome-lib"/>
4293 <antcall target="unzip-windows-packages"/>
4294 <antcall target="checkout-winbin"/>
4295 <antcall target="get-windows-binaries"/>
4296 <antcall target="delete-winbin"/>
4297 </target>
4298
4299 <target name="checkout-gs2build" depends="init" if="collection.building.enabled" unless="nosvn.mode">
4300 <echo>checking out gs2build</echo>
4301 <exec executable="svn">
4302 <arg line="${global-svn-args}"/>
4303 <arg value="checkout"/>
4304 <arg value="${svn.root}/main/${branch.path}/gs2build"/>
4305 <arg value="-r"/><arg value="${branch.revision}"/>
4306 </exec>
4307 </target>
4308
4309 <!-- Gets the PDFBox extension into gs2build/ext if checkout.pdfbox.ext is set to true in build.properties
4310 (which it is by default) -->
4311 <target name="prepare-pdfbox" depends="init" if="collection.building.enabled">
4312 <if>
4313 <bool>
4314 <istrue value="${checkout.pdfbox.ext}"/>
4315 </bool>
4316
4317 <property name="pdfbox.ext.dir" value="${gs2build.home}/ext/pdf-box"/>
4318 <condition property="pdfbox.ext.present">
4319 <available file="${pdfbox.ext.dir}" type="dir" />
4320 </condition>
4321
4322 <!-- 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-->
4323 <if>
4324 <bool>
4325 <not><istrue value="${pdfbox.ext.present}"/></not>
4326 </bool>
4327
4328 <if>
4329 <bool>
4330 <not><istrue value="${gs2build.home}/ext/pdf-box-java.tar.gz"/></not>
4331 </bool>
4332
4333 <echo>Checking out the PDFBox extension into the GSDLHOME extension area</echo>
4334 <exec executable="svn">
4335 <arg line="${global-svn-args}"/>
4336 <arg value="export"/>
4337 <arg value="${svn.root}/gs2-extensions/pdf-box/trunk/pdf-box-java.tar.gz"/>
4338 <arg value="${gs2build.home}/ext/pdf-box-java.tar.gz"/>
4339 </exec>
4340 </if>
4341
4342 <echo>Extacting the PDFBox extension into the GSDLHOME extension area</echo>
4343 <untar compression="gzip"
4344 src="${gs2build.home}/ext/pdf-box-java.tar.gz"
4345 dest="${gs2build.home}/ext"/>
4346
4347 <delete file="${gs2build.home}/ext/pdf-box-java.tar.gz"/>
4348
4349 <else>
4350 <echo>The PDFBox extension already exists at ${pdfbox.ext.dir}</echo>
4351 </else>
4352 </if>
4353
4354 <else>
4355 <echo>**** Not preparing the PDFBox extension:</echo>
4356 <echo>The property checkout.pdfbox.ext in build.properties was not set or was set to false</echo>
4357 </else>
4358 </if>
4359 </target>
4360
4361 <target name="prepare-imagemagick" depends="init" if="collection.building.enabled">
4362 <if>
4363 <bool>
4364 <istrue value="${checkout.imagemagick.ext}"/>
4365 </bool>
4366
4367 <antcall target="checkout-imagemagick"/>
4368 <!--Compilation of imagemagick now happens during ant install, still before configuring the src code, as before -->
4369
4370 <else>
4371 <echo>**** Not preparing imagemagick:</echo>
4372 <echo>property checkout.imagemagick.ext in build.properties was not set or was set to false</echo>
4373 </else>
4374 </if>
4375 </target>
4376
4377 <target name="checkout-imagemagick" depends="init" if="collection.building.enabled" unless="nosvn.mode">
4378
4379 <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
4380 <condition property="imagemagick.src.present">
4381 <available file="${imagemagick.src.dir}" type="dir" />
4382 </condition>
4383
4384 <if>
4385 <bool>
4386 <not><istrue value="${imagemagick.src.present}"/></not>
4387 </bool>
4388
4389 <echo>checking out imagemagick source into the extension area</echo>
4390
4391 <exec executable="svn">
4392 <arg line="${global-svn-args}"/>
4393 <arg value="checkout"/>
4394 <arg value="${svn.root}/gs2-extensions/imagemagick/trunk/src"/>
4395 <arg value="${imagemagick.src.dir}"/>
4396 </exec>
4397
4398 <else>
4399 <echo>imagemagick source code already exists at ${imagemagick.src.dir}</echo>
4400 </else>
4401 </if>
4402 </target>
4403
4404 <!-- 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. -->
4405 <target name="compile-imagemagick" if="${checkout.imagemagick.ext}">
4406
4407 <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
4408 <property name="imagemagick.compiled.dir" value="${gs2build.home}/ext/imagemagick/${os.bin.dir}"/>
4409
4410 <condition property="imagemagick.src.present.firstcheck">
4411 <available file="${imagemagick.src.dir}" type="dir" />
4412 </condition>
4413 <condition property="imagemagick.compiled.present">
4414 <available file="${imagemagick.compiled.dir}" type="dir"/>
4415 </condition>
4416 <!--<condition property="imagemagick.bin.present">
4417 <available file="${basedir}/wherever/the/imgmagick/binary/is/to/be/found" type="dir" />
4418 </condition>-->
4419
4420 <!-- imagemagick will only be checked out if the user set the checkout.imagemagick.ext in build.properties -->
4421 <if>
4422 <bool>
4423 <isfalse value="${imagemagick.src.present.firstcheck}"/>
4424 </bool>
4425 <antcall target="checkout-imagemagick"/>
4426 </if>
4427
4428 <!-- keep track of whether the imagemagick src is now indeed present. Need to know this for a subsequent test -->
4429 <condition property="imagemagick.src.present">
4430 <available file="${imagemagick.src.dir}" type="dir" />
4431 </condition>
4432
4433 <if>
4434 <bool>
4435 <and>
4436 <istrue value="${imagemagick.src.present}"/> <!-- imagemagick src code is present -->
4437 <isfalse value="${imagemagick.compiled.present}"/> <!-- imagemagick src not compiled yet, so no imagemagick/os subfolder yet -->
4438 </and>
4439 </bool>
4440 <!-- then compile it. Only necessary for mac/linux, since windows has a stable working binary of imagemagick -->
4441 <exec executable="/bin/bash" dir="${imagemagick.src.dir}" failonerror="true">
4442 <arg value="CASCADE-MAKE.sh"/>
4443 </exec>
4444 </if>
4445 </target>
4446
4447
4448 <!-- If not on windows, then compile up gnome-lib src folder if:
4449 checkout.gnomelib.ext is turned on,
4450 and if not using the binary version (gnome-lib-minimal),
4451 and if the gnome-lib src folder is not already compiled up. -->
4452 <target name="compile-gnome-lib" if="${checkout.gnomelib.ext}" unless="current.os.iswindows">
4453
4454 <!-- http://stackoverflow.com/questions/3290307/sourcing-a-shell-profile-in-an-ant-build-file
4455 TODO: CASCADE-MAKE already sources devel.bash, but we still want to source it more globally,
4456 so that the rest of the GS3 compilation process also has access to those env variables -->
4457
4458 <property name="gnome.lib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
4459 <property name="gnome.lib.compiled.dir" value="${basedir}/gs2build/ext/gnome-lib/${os.bin.dir}"/>
4460
4461 <condition property="gnome.src.lib.present.firstcheck" value="true" else="false">
4462 <available file="${gnome.lib.src.dir}" type="dir" />
4463 </condition>
4464 <condition property="gnome.compiled.lib.present" value="true" else="false">
4465 <available file="${gnome.lib.compiled.dir}" type="dir"/>
4466 </condition>
4467 <condition property="gnome.lib.min.present" value="true" else="false">
4468 <available file="${basedir}/gs2build/ext/gnome-lib-minimal" type="dir" />
4469 </condition>
4470
4471 <!-- Make sure to checkout gnome-lib if it was not checked out at this stage
4472 since we're instructed to do so in th pre-condition to this target -->
4473 <if>
4474 <bool>
4475 <and>
4476 <isfalse value="${gnome.lib.min.present}"/>
4477 <isfalse value="${gnome.src.lib.present.firstcheck}"/>
4478 </and>
4479 </bool>
4480 <antcall target="checkout-gnome-lib"/>
4481 </if>
4482
4483 <!-- Keep track of whether we have the gnome-lib src folder now. Need to know this for a subsequent test -->
4484 <condition property="gnome.src.lib.present" value="true" else="false">
4485 <available file="${gnome.lib.src.dir}" type="dir" />
4486 </condition>
4487
4488 <!--<echo>MIN: ${gnome.lib.min.present}
4489 SRC LIB: ${gnome.src.lib.present}
4490 COMPILED: ${gnome.compiled.lib.present}</echo>-->
4491
4492 <if>
4493 <bool>
4494 <and>
4495 <isfalse value="${gnome.lib.min.present}"/> <!-- no gnome-lib-minimal binary present -->
4496 <istrue value="${gnome.src.lib.present}"/> <!-- gnome-lib folder for compilation is present-->
4497 <isfalse value="${gnome.compiled.lib.present}"/> <!-- gnome-lib not yet compiled, so no gnome-lib/os subfolder yet -->
4498 </and>
4499 </bool>
4500
4501 <!-- then compile it. Only necessary for mac/linux, since windows doesn't need gnome lib -->
4502 <exec executable="/bin/bash" dir="${gnome.lib.src.dir}" failonerror="true">
4503 <arg value="CASCADE-MAKE.sh"/>
4504 </exec>
4505 </if>
4506 </target>
4507
4508
4509 <target name="prepare-gnome-lib" depends="init" if="collection.building.enabled" unless="gnome-lib.present">
4510 <if>
4511 <bool><istrue value="${checkout.gnomelib.ext}"/></bool>
4512 <if>
4513 <bool><istrue value="${current.os.iswindows}"/></bool>
4514
4515 <echo>Skipping prepare-gnome-lib, because compilation is on Windows which checks out binaries that do not rely on gnomelib</echo>
4516 <else>
4517 <!-- current.os.isunix -->
4518
4519 <antcall target="checkout-gnome-lib"/>
4520 <!--Compilation of gnome-lib happens during ant install, just before configuring (common-src and) build-src-->
4521
4522 </else>
4523 </if>
4524 <else>
4525 <if><bool><istrue value="${current.os.isunix}"/></bool>
4526 <!-- current.os.isunix and checkout.gnomelib.ext not turned on -->
4527 <echo>**** Not preparing gnome-lib:</echo>
4528 <echo>property checkout.gnomelib.ext in build.properties was not set or was set to false.</echo>
4529 </if>
4530 </else>
4531 </if>
4532 </target>
4533
4534
4535 <target name="checkout-gnome-lib" depends="init" if="collection.building.enabled" unless="nosvn.mode">
4536
4537 <property name="gnomelib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
4538 <condition property="gnome.src.present">
4539 <available file="${gnomelib.src.dir}" type="dir" />
4540 </condition>
4541
4542 <if>
4543 <bool>
4544 <not><istrue value="${gnome.src.present}"/></not>
4545 </bool>
4546
4547 <echo>checking out gnome-lib extension</echo>
4548 <exec executable="svn">
4549 <arg line="${global-svn-args}"/>
4550 <arg value="checkout"/>
4551 <arg value="${svn.root}/gs2-extensions/gnome-lib/trunk/src"/>
4552 <arg value="${gs2build.home}/ext/gnome-lib"/>
4553 </exec>
4554
4555 <else>
4556 <echo>gnomelib source code already exists at ${gnomelib.src.dir}</echo>
4557 </else>
4558 </if>
4559
4560 </target>
4561
4562 <target name="checkout-winbin" depends="init" if="current.os.iswindows"
4563 unless="nosvn.mode">
4564
4565 <exec executable="svn">
4566 <arg line="${global-svn-args}"/>
4567 <arg value="checkout"/>
4568 <arg value="${svn.root}/main/${branch.path}/binaries/windows"/>
4569 <arg value="-r"/><arg value="${branch.revision}"/>
4570 <arg value="winbin"/>
4571 </exec>
4572
4573 </target>
4574
4575 <target name="update-winbin" depends="init" if="current.os.iswindows" unless="nosvn.mode">
4576 <exec executable="svn">
4577 <arg line="${global-svn-args}"/>
4578 <arg value="update"/>
4579 <arg value="winbin"/>
4580 <arg value="-r"/><arg value="${branch.revision}"/>
4581 </exec>
4582
4583 </target>
4584
4585 <target name="get-windows-binaries" depends="init" if="collection.building.enabled.windows">
4586 <move todir="${gs2build.home}/bin/windows" failonerror="false">
4587 <fileset dir="${basedir}/winbin/bin"/>
4588 </move>
4589 </target>
4590
4591 <target name="delete-winbin" depends="init" if="collection.building.enabled.windows">
4592 <delete dir="${basedir}/winbin"/>
4593 </target>
4594
4595 <target name="unzip-windows-packages" depends="envbased-devel-props,init" if="current.os.iswindows">
4596 <unzip src="${common.src.home}/packages/windows/crypt/crypt.zip"
4597 dest="${common.src.home}/packages/windows/crypt"/>
4598 <untar compression="gzip"
4599 src="${common.src.home}/packages/sqlite/${sqlite.targz.version}"
4600 dest="${common.src.home}/packages/sqlite"/>
4601 <untar compression="gzip"
4602 src="${common.src.home}/packages/expat/${expat.targz.version}"
4603 dest="${common.src.home}/packages/expat"/>
4604 <untar compression="gzip"
4605 src="${common.src.home}/packages/jdbm/${jdbm.targz.version}"
4606 dest="${common.src.home}/packages/jdbm"/>
4607 <if>
4608 <bool>
4609 <islessthan arg1="${visualstudio.majorversion}" arg2="14"/>
4610 </bool>
4611 <echo>Unzipping Pre-VS14.0 compatible version of iconv</echo>
4612 <unzip src="${common.src.home}/indexers/packages/windows/iconv/iconv-PRE-VS14.zip"
4613 dest="${common.src.home}/indexers/packages/windows/iconv"/>
4614 <else>
4615 <echo>Unzipping VS14.0-Plus compatible version of iconv</echo>
4616 <unzip src="${common.src.home}/indexers/packages/windows/iconv/iconv-VS14-PLUS.zip"
4617 dest="${common.src.home}/indexers/packages/windows/iconv"/>
4618 </else>
4619 </if>
4620
4621 </target>
4622
4623 <target name="gs2build-edit-setup-bat" if="collection.building.enabled.windows">
4624 <!-- we want a windows path in the setup.bat file -->
4625 <pathconvert targetos="windows" property="gs2build.home.windows">
4626 <path path="${gs2build.home}"/>
4627 </pathconvert>
4628 <move file="${gs2build.home}/setup.bat" tofile="${gs2build.home}/setup-tmp.bat">
4629 <filterset>
4630 <filter token="gsdlhome" value="${gs2build.home.windows}"/>
4631 </filterset>
4632 </move>
4633 <move file="${gs2build.home}/setup-tmp.bat" tofile="${gs2build.home}/setup.bat" />
4634 </target>
4635
4636
4637 <target name="clean-build-src" depends="init" if="collection.building.enabled">
4638 <!-- unix: -->
4639 <if><bool><available file="${build.src.home}/Makefile"/></bool>
4640 <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
4641 <arg value="clean"/>
4642 </exec>
4643 </if>
4644 <!-- windows: -->
4645 <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
4646 <arg value="/f"/>
4647 <arg value="win32.mak"/>
4648 <arg value="clean"/>
4649 <arg value="GSDLHOME=${gs2build.home}"/>
4650 </exec>
4651 </target>
4652
4653
4654 <target name="distclean-build-src" depends="init,clean-build-src" if="collection.building.enabled">
4655 <!-- unix: -->
4656 <if><bool><available file="${build.src.home}/Makefile"/></bool>
4657 <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
4658 <arg value="distclean"/>
4659 </exec>
4660 </if>
4661 <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->
4662 <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
4663 <arg value="/f"/>
4664 <arg value="win32.mak"/>
4665 <arg value="clean"/>
4666 <arg value="GSDLHOME=${gs2build.home}"/>
4667 </exec>
4668 </target>
4669
4670 <target name="configure-build-src" depends="envbased-gnomelib-allargs-prop,init" if="collection.building.enabled"
4671 description="Configure the build-src component">
4672 <exec executable="${build.src.home}/configure" os="${os.unix}"
4673 dir="${build.src.home}" failonerror="true">
4674 <arg value="--prefix=${gs2build.home}"/>
4675 <arg line="${gs2.opt.args} ${static.arg} ${cross.configure.args} ${allargs}"/>
4676 </exec>
4677 </target>
4678
4679 <!-- common-src is done separately and needs to be compiled first -->
4680 <target name="compile-build-src" depends="needs-gs3-devel,init" if="collection.building.enabled">
4681
4682 <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
4683 <!-- <arg line="${ldlpath.arg}"/> -->
4684 <env key="LD_LIBRARY_PATH" value="${env.LD_LIBRARY_PATH}"/> <!--changed to specifying through 'env' rather than arg with ldlpath.arg -->
4685 </exec>
4686
4687 <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
4688 <env key="GSDLOS" value="${os.bin.dir}"/>
4689 <arg value="install"/>
4690 </exec>
4691
4692 <!-- run the setup script -->
4693 <!-- <exec executable="${compile.windows.c++.setup}" osfamily="windows" failonerror="true"/>-->
4694 <!--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-->
4695 <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
4696 <arg value="/f"/>
4697 <arg value="win32.mak"/>
4698 <arg value="GSDLHOME=${gs2build.home}"/>
4699 </exec>
4700 <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
4701 <arg value="/f"/>
4702 <arg value="win32.mak"/>
4703 <arg value="install"/>
4704 <arg value="GSDLHOME=${gs2build.home}"/>
4705 </exec>
4706 </target>
4707
4708
4709 <!-- ======================== TESTING Targets ========================= -->
4710
4711 <target name="test" description="Run the (incomplete) JUnit test suite "
4712 depends="init">
4713 <mkdir dir="${basedir}/test"/>
4714 <junit printsummary="withOutAndErr"
4715 errorproperty="test.failed"
4716 failureproperty="test.failed"
4717 fork="${junit.fork}">
4718 <formatter type="plain"/>
4719 <classpath>
4720 <pathelement location="${build.home}/gsdl3test.jar"/>
4721 <path refid="compile.classpath"/>
4722 </classpath>
4723 <test name="${testcase}" if="testcase"/>
4724 <batchtest todir="${basedir}/test" unless="testcase">
4725 <fileset dir="${build.home}" includes="**/*Test.class" />
4726 </batchtest>
4727 </junit>
4728 <echo>
4729 *********************************************
4730 Test output can be found in directory 'test'
4731 *********************************************
4732 </echo>
4733 </target>
4734
4735 <!-- ======================== FLAX Targets ========================= -->
4736 <target name="prepare-flax" description="check out flax source code from another repository" if="install.flax">
4737 <echo>checking out flax ...</echo>
4738 <mkdir dir="${basedir}/src/java/org/flax"/>
4739 <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/flax"/>
4740 <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/action/flax"/>
4741 <mkdir dir="${web.home}/WEB-INF/classes/flax"/>
4742 <mkdir dir="${web.home}/interfaces/flax"/>
4743 <mkdir dir="${web.home}/sites/flax"/>
4744 <mkdir dir="${basedir}/flax-resources"/>
4745 <mkdir dir="${basedir}/flax-lib"/>
4746 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/flax"/>
4747 <arg value="src/java/org/flax"/></exec>
4748 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/flax"/>
4749 <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
4750 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/action/flax"/>
4751 <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
4752 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="checkout"/><arg value="${flax.checkout.path}/web/WEB-INF/classes/flax"/>
4753 <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
4754 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="checkout"/><arg value="${flax.checkout.path}/web/interfaces/flax"/>
4755 <arg value="${web.home}/interfaces/flax"/></exec>
4756 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="checkout"/><arg value="${flax.checkout.path}/web/sites/flax"/>
4757 <arg value="${web.home}/sites/flax"/></exec>
4758 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="checkout"/><arg value="${flax.checkout.path}/flax-resources"/>
4759 <arg value="flax-resources"/></exec>
4760 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="checkout"/><arg value="${flax.checkout.path}/lib"/>
4761 <arg value="flax-lib"/></exec>
4762 <antcall target="flax-copy-del-files" />
4763 </target>
4764
4765 <target name="flax-copy-del-files" description="copy some flax files into the appropriate greenstone3 directories and delete some unwanted greenstone stuff">
4766 <copy file="${web.home}/WEB-INF/classes/flax/flax.xml" todir="${web.home}/WEB-INF" overwrite="true" />
4767 <copy todir="${web.home}/WEB-INF/classes" overwrite="true" >
4768 <fileset dir="${web.home}/WEB-INF/classes/flax">
4769 <include name="interface_flax*.properties"/>
4770 </fileset>
4771 </copy>
4772 <copy todir="${web.home}/WEB-INF/lib">
4773 <fileset dir="${basedir}/flax-lib">
4774 <include name="*.jar"/>
4775 </fileset>
4776 </copy>
4777 <!--<delete dir="${web.home}/sites/gateway"/>
4778 <delete dir="${web.home}/sites/localsite"/>-->
4779 </target>
4780
4781 <target name="update-flax" description="update flax from repository">
4782 <echo>updating flax ...</echo>
4783 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="update"/>
4784 <arg value="src/java/org/flax"/></exec>
4785 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="update"/>
4786 <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
4787 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="update"/>
4788 <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
4789 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="update"/>
4790 <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
4791 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="update"/>
4792 <arg value="${web.home}/interfaces/flax"/></exec>
4793 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="update"/>
4794 <arg value="${web.home}/web/sites/flax"/></exec>
4795 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="update"/>
4796 <arg value="flax-resources"/></exec>
4797 <exec executable="svn"><arg line="${global-svn-args}"/><arg value="update"/>
4798 <arg value="flax-lib"/></exec>
4799 <antcall target="compile-core" />
4800 </target>
4801
4802 <!-- ========================End of FLAX Targets ========================= -->
4803
4804 <target name="compile-javadocs">
4805 <javadoc packagenames="org.greenstone.*"
4806 sourcepath="src/java"
4807 defaultexcludes="yes"
4808 destdir="docs/javadoc"
4809 author="true"
4810 version="true"
4811 use="true"
4812 windowtitle="Greenstone3 API">
4813 <doctitle><![CDATA[<h1>Greenstone3 API</h1>]]></doctitle>
4814 </javadoc>
4815 </target>
4816
4817<!-- ========== Some distribution targets ======================== -->
4818 <target name="remove-source">
4819 <if><bool><isset property="with.gli.and.gems"/></bool>
4820 <delete includeEmptyDirs="true">
4821 <fileset dir="." defaultexcludes="false">
4822 <patternset refid="greenstone3.source.component"/>
4823 </fileset>
4824 </delete>
4825
4826 <else>
4827 <delete includeEmptyDirs="true">
4828 <fileset dir="." defaultexcludes="false">
4829 <patternset refid="greenstone3.source.no.gli.component"/>
4830 </fileset>
4831 </delete>
4832 </else>
4833 </if>
4834 </target>
4835
4836 <target name="dist-tidy"
4837 description="'tidies-up' a greenstone3 installation for distribution."
4838 unless="${properties.keep.src}">
4839
4840 <!-- delete unneeded things -->
4841 <delete dir="${packages.home}/axis"/>
4842 <delete><fileset dir="${packages.home}" includes="*.zip"/></delete>
4843 <delete file="README-SVN.txt"/>
4844 <delete file="build.properties.svn"/>
4845
4846 <!-- delete source files -->
4847 <antcall target="remove-source"/>
4848
4849 <!-- create empty directories -->
4850 <mkdir dir="${web.writablehome}/applet"/>
4851 <mkdir dir="${web.writablehome}/logs"/>
4852 <mkdir dir="${web.writablehome}/logs/tmp"/>
4853
4854 <!-- Lines with ***** are commented out because these files are useful if we want hybrid installations -->
4855
4856 <!-- os specific tidy-ups -->
4857 <!-- linux, mac -->
4858 <if><bool><istrue value="${current.os.isunix}"/></bool>
4859 <!--*****<delete><fileset dir="." includes="*.bat"/></delete>-->
4860 <if><bool><isset property="with.gli.and.gems"/></bool>
4861 <!--*****<delete><fileset dir="gli" includes="*.bat"/></delete>-->
4862 </if>
4863 <!--*****<delete><fileset dir="gs2build" includes="*.bat"/></delete>-->
4864 <!--*****<delete><fileset dir="bin/script" includes="*.bat"/></delete>-->
4865 <delete file="${basedir}/gs2build/win32cfg.h"/>
4866 <delete file="${basedir}/gs2build/win32.mak"/>
4867 <delete dir="${basedir}/winutil"/>
4868 <delete failonerror="false"><fileset dir="${lib.jni}" includes="*.dll"/></delete>
4869
4870 <!-- windows -->
4871 <else><if><bool><istrue value="${current.os.iswindows}"/></bool>
4872 <!--*****<delete><fileset dir="." includes="*.sh,*.bash,*.csh"/></delete>-->
4873 <if><bool><isset property="with.gli.and.gems"/></bool>
4874 <!--*****<delete><fileset dir="gli" includes="*.sh,*.bash,*.csh"/></delete>-->
4875 </if>
4876 <!--*****<delete><fileset dir="gs2build" includes="*.sh,*.bash,*.csh"/></delete>-->
4877 <!--*****<delete><fileset dir="bin/script" includes="*.sh,*.bash,*.csh"/></delete>-->
4878 </if></else></if>
4879
4880 </target>
4881
4882 <!-- fix up executable permissions for binary release -->
4883 <target name="fix-execute-permissions">
4884 <echo>Setting binaries to executable</echo>
4885 <chmod perm="775">
4886 <fileset dir="."><patternset refid="greenstone3.executables"/></fileset>
4887 </chmod>
4888 </target>
4889
4890 <!-- fix up executable permissions for source code release -->
4891 <target name="fix-execute-permissions-source">
4892 <chmod perm="775">
4893 <fileset dir="."><patternset refid="greenstone3.source.executables"/></fileset>
4894 </chmod>
4895 </target>
4896
4897 <!-- for macs, set up the .app shortcuts to gsi, gli, client-gli and gems -->
4898 <target name="gen-mac-shortcuts">
4899 <exec executable="uname" dir="${basedir}" failonerror="false"
4900 outputproperty="darwin.kernel.version">
4901 <arg value="-r"/>
4902 </exec>
4903
4904 <echo>darwin kernel version: ${darwin.kernel.version}</echo>
4905
4906 <if>
4907 <bool><matches string="${darwin.kernel.version}" pattern="^([0-9]|1[0-8])\."/></bool>
4908 <property name="mac.app.bitness" value="32"/>
4909 <else>
4910 <property name="mac.app.bitness" value="64"/>
4911 </else>
4912 </if>
4913
4914 <echo>bitness for mac apps: ${mac.app.bitness}</echo>
4915
4916 <!--(recursively) copy the .app files from the MacShortcutsXbit folder of the correct bitness
4917 https://stackoverflow.com/questions/1685442/how-to-copy-a-directory-using-ant -->
4918 <copy todir="${basedir}" >
4919 <fileset dir="${basedir}/MacShortcuts${mac.app.bitness}bit" includes="**"/>
4920 </copy>
4921
4922 <if><bool><istrue value="${current.os.ismac}"/></bool>
4923 <filter token="gsdl3srchome" value="${basedir}"/>
4924 <copy file="${basedir}/gs3-server.app/Contents/document.wflow.in" tofile="${basedir}/gs3-server.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4925 <copy file="${basedir}/gli.app/Contents/document.wflow.in" tofile="${basedir}/gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4926 <copy file="${basedir}/client-gli.app/Contents/document.wflow.in" tofile="${basedir}/client-gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4927 <copy file="${basedir}/gems.app/Contents/document.wflow.in" tofile="${basedir}/gems.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4928 </if>
4929 </target>
4930
4931 <!-- ============= tweaks for making compilation static ========== -->
4932 <target name="tweak-makefiles" depends="init" if="compile.static">
4933 <antcall target="rtftohtml-add-static" />
4934 </target>
4935
4936 <target name="rtftohtml-add-static" depends="init" if="collection.building.enabled">
4937 <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" />
4938 </target>
4939
4940 <target name="run-collection-tests">
4941 <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
4942 <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>
4943 </if>
4944 <for param="testjar">
4945 <path>
4946 <fileset dir="${basedir}" includes="web/sites/*/collect/*/tests/tests.jar"/>
4947 </path>
4948 <sequential>
4949 <echo>Testing @{testjar}</echo>
4950 <java classname="org.junit.runner.JUnitCore" fork="true">
4951 <!--https://stackoverflow.com/questions/38676719/selenium-using-java-the-path-to-the-driver-executable-must-be-set-by-the-webdr-->
4952 <sysproperty key="webdriver.gecko.driver" path="${basedir}/ext/testing/geckodriver"/>
4953 <arg value="gstests.TestClass"/>
4954 <jvmarg value="-DSERVERURL=${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}${server.default.servlet} "/>
4955 <classpath>
4956 <fileset dir="${basedir}/ext/testing/lib/java">
4957 <include name="*.jar"/>
4958 </fileset>
4959 <files includes="@{testjar}"/>
4960 </classpath>
4961 </java>
4962 </sequential>
4963 </for>
4964 </target>
4965
4966 <target name="build-collection-tests">
4967 <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
4968 <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>
4969 </if>
4970 <for param="compiledir">
4971 <path>
4972 <dirset dir="${basedir}" includes="web/sites/*/collect/*/tests/src"/>
4973 </path>
4974 <sequential>
4975 <echo>Compiling @{compiledir}</echo>
4976 <if><bool><not><available file="@{compiledir}/../build" type="dir"/></not></bool>
4977 <mkdir dir="@{compiledir}/../build"/>
4978 </if>
4979 <javac srcdir="@{compiledir}"
4980 destdir="@{compiledir}/../build"
4981 includeantruntime="${compile.includeantruntime}"
4982 debug="${compile.debug}"
4983 deprecation="${compile.deprecation}"
4984 optimize="${compile.optimize}"
4985 encoding="${compile.encoding}">
4986 <compilerarg line="${compile.javac.flags}"/>
4987 <classpath>
4988 <fileset dir="${basedir}/ext/testing/lib/java">
4989 <include name="*.jar"/>
4990 </fileset>
4991 </classpath>
4992 <include name="gstests/*.java"/>
4993 </javac>
4994 <jar destfile="@{compiledir}/../tests.jar">
4995 <fileset dir="@{compiledir}/../build">
4996 <include name="gstests/**"/>
4997 </fileset>
4998 <manifest>
4999 <attribute name="Built-By" value="${user.name}" />
5000 </manifest>
5001 </jar>
5002 </sequential>
5003 </for>
5004 </target>
5005</project>
Note: See TracBrowser for help on using the repository browser.