source: main/trunk/greenstone3/build.xml

Last change on this file was 38949, checked in by anupama, 3 days ago

Like GsdlCollageApplet, JPhind when run as a commandline application or applet (a.o.t. webswing application/applet) also needs webswing-api.jar to be in the web/applet folder, since we started importing webswing packages (even if not run as a webswing program). 1. Adjusted the now unused service PhindPhraseBrowse's applet archive attribute to include this jar file in the list of those needed. 2. Added the jar mention in the comment to JPhind.java with a sample command on how to successfully launch JPhind from the commandline. 3. build.xml's compile-core target now tries to put this jar file into web/applet if it doesn't yet exist there. But this assumes that ext/webswing has already been setup at this stage, which I think is the case.

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