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

Last change on this file since 34605 was 34605, checked in by anupama, 3 years ago

Didn't see that Kathy had changed gsroot to community machine. Have put it back to greenstone.org since this commit switches ant get tasks over to ant exec tasks using GS compiled wget which has https support. So we are not dependent on http urls. Still need to update all the affected release kits files.

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