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

Last change on this file since 37344 was 37344, checked in by kjdon, 14 months ago

added in placeholder for svn args needed by release kits to trust server certificates.

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