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

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

More nuanced install/configure targets, so when top-level build.xml does an 'ant start' it now reconfigures the necessary webswing config files

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