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

Last change on this file since 37147 was 37147, checked in by davidb, 16 months ago

Revised note in comment

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