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

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

Fixed incorrect syntax of <isset> property test

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