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

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

passing in gsdlos now, using env.GSDLOS, so needs to run the needs-gs3-setup target first

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