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

Last change on this file since 37333 was 37333, checked in by davidb, 14 months ago

Shifting internal/external servlet-url properties to top-level to help with install-webswing-ext and configure-webswing-ext

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