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

Last change on this file since 37626 was 37626, checked in by davidb, 13 months ago

build.xml now makes use of a 'template' version of servlets.xml in resources/web/servlets.xml.in so things like the Google Signin client id key only needs to be specified in one place, and through 'ant configure' the value in build.properties is pushed out into both greenstone3.xml for tomcat, and web/WEB-INF/servlets.xml

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