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

Last change on this file since 38981 was 38981, checked in by anupama, 5 weeks ago

Tabbing final target.

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