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

Last change on this file since 38769 was 38769, checked in by anupama, 4 months ago

Following Dr Bainbridge's task description and with his fixes: changes to get the Networked Derby Driver that we now use to use the shorter URL to the usersDB of the form jdbc:derby://derbyserver:derbyport/usersDB, instead of the full path to usersDB after the protocol. It needed setting derby.system.home JAVA_OPT when starting up the derby server in build.xml, then the tomcat greenstone3.xml file needed to refer to the shorter URL. Then classes that used to pass the full path need to pass the shorter form. And those classes called from the comandline with full usersDB path, like ModifyUsersDB, needed to now pass the shorter path. So build.xml needed further updating when calling ModifyUsersDB. The full path still works (for example, you can connect to both the original jdbc:derby URL and the shorter URL now from Squirrel SQL Client now), but the code now uses the shorter path.

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