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

Last change on this file since 37512 was 37512, checked in by anupama, 14 months ago

Added some debugging into build.xml to see why the derby server doesn't get started during installation. Hard to debug this.

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