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

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

Technique that effectively allows us to 'source' our gs-setup.sh file added in. Written and tested for Linux; Windows version also added in, but not as yet tested

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