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

Last change on this file since 35640 was 35638, checked in by davidb, 3 years ago

Tidy up of test-setup

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