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

Last change on this file since 36586 was 36586, checked in by davidb, 20 months ago

Moved (delayed) the location of the test for the webswing config files so they are present when the test is run; also added in _RUNJAVA to the debug-start-tomcat target

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