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

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

Minimum change to get isisgdl to work for the final GS3 release without breaking linux 64 bit or windows or 32 bit linux by changing over to Dr Bainbridge's new isis-gdl source code: switched over to downloading IsisGdl.mac64mojave when the OS is mojave. Still untested on Catalina, but this is for building the rk3 release-kit with the correct IsisGdl binary anyway. And if it doesn't work on Catalina, it's no worse off as no IsisGdl binary worked on Catalina before and this change won't have broken it for other OS-es. Already uploaded IsisGdl.mac64mojave onto the old and new greenstone.org machines

File size: 199.1 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 <exec executable="uname" dir="${basedir}" failonerror="false"
1599 outputproperty="darwin.kernel.version">
1600 <arg value="-r"/>
1601 </exec>
1602
1603 <echo>darwin kernel version: ${darwin.kernel.version}</echo>
1604 <!-- up to high sierra/kernel (version 17.x) us IsisGdl.macleopard
1605 From Mojave onwards, we can use the Mojave generated IsisGdl.mac64mojave -->
1606 <if>
1607 <bool><matches string="${darwin.kernel.version}" pattern="^([0-9]|1[0-7])\."/></bool>
1608 <property name="mac.isisgdl.suffix" value="macleopard"/>
1609 <else>
1610 <property name="mac.isisgdl.suffix" value="mac64mojave"/>
1611 </else>
1612 </if>
1613
1614
1615 <!--<get src="${gsorg.root}/caveat-emptor/IsisGdl.macleopard"
1616 dest="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl"/>-->
1617 <exec executable="wget" failonerror="true">
1618 <arg value="-P"/>
1619 <arg value="${basedir}/gs2build/bin/${os.bin.dir}"/>
1620 <arg value="--no-check-certificate"/>
1621 <arg value="${gsorg.root}/caveat-emptor/IsisGdl.${mac.isisgdl.suffix}"/>
1622 </exec>
1623 <move file="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl.${mac.isisgdl.suffix}"
1624 tofile="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl"/>
1625 </if>
1626 <if><bool><contains string="${os.bin.dir}" substring="linux" casesensitive="false"/></bool>
1627 <!--<get src="${gsorg.root}/caveat-emptor/IsisGdl.bin32"
1628 dest="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl"/>-->
1629 <exec executable="wget" failonerror="true">
1630 <arg value="-P"/>
1631 <arg value="${basedir}/gs2build/bin/${os.bin.dir}"/>
1632 <arg value="--no-check-certificate"/>
1633 <arg value="${gsorg.root}/caveat-emptor/IsisGdl.bin32"/>
1634 </exec>
1635 <move file="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl.bin32"
1636 tofile="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl"/>
1637 </if>
1638 <chmod file="${basedir}/gs2build/bin/${os.bin.dir}/IsisGdl" perm="755"/>
1639 </if>
1640 </target>
1641
1642 <target name="set-perl-shebangs" depends="perl-for-building">
1643 <if>
1644 <bool>
1645 <and><isset property="perl.path"/>
1646 <not><equals arg1="${perl.path}" arg2=""/></not>
1647 </and>
1648 </bool>
1649
1650 <if><bool><istrue value="${current.os.iswindows}"/></bool>
1651 <property name="perl.exec" value="${perl.path}perl.exe"/>
1652 <else>
1653 <property name="perl.exec" value="${perl.path}perl"/>
1654 </else>
1655 </if>
1656
1657 <!--<echo>**** PERLPATH: ${perl.path}</echo>-->
1658 <echo>Setting perl shebangs to Perl Exec: ${perl.exec}</echo>
1659
1660 <!-- set the shebangs in the cgi files to point to the correct perlpath -->
1661 <if>
1662 <bool><not><equals arg1="${web.home}" arg2="${web.writablehome}"></equals></not></bool>
1663 <mkdir dir="${web.writablehome}"/>
1664 <copy file="${full.web.dir}/WEB-INF/cgi/gliserver.pl" tofile="${web.writablehome}/WEB-INF/cgi/gliserver.pl" overwrite="true"/>
1665 <copy file="${full.web.dir}/WEB-INF/cgi/metadata-server.pl" tofile="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" overwrite="true"/>
1666 <copy file="${full.web.dir}/WEB-INF/cgi/checksum.pl" tofile="${web.writablehome}/WEB-INF/cgi/checksum.pl" overwrite="true"/>
1667 </if>
1668
1669 <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/gliserver.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1670 <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1671 <rsr verbosity="1" file="${web.writablehome}/WEB-INF/cgi/checksum.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1672 <else>
1673 <echo>WARNING: perl.path is empty. Unable to set the shebangs in the perl files in ${web.writablehome}/WEB-INF/cgi</echo>
1674 </else>
1675 </if>
1676 </target>
1677
1678 <target name="configure-web" depends="init,perl-for-building"
1679 description="Configure only the web app config files">
1680 <!-- we want a unix path in the global.properties file -->
1681 <pathconvert targetos="unix" property="src.gsdl3.home.unix">
1682 <path path="${web.home}"/>
1683 </pathconvert>
1684 <pathconvert targetos="unix" property="src.gsdl3.writablehome.unix">
1685 <path path="${web.writablehome}"/>
1686 </pathconvert>
1687
1688 <antcall target="set-perl-shebangs" inheritAll="true" />
1689
1690 <filter token="gsdlhome" value="${gs2build.home}"/>
1691 <filter token="gsdlhomequoted" value="&quot;${gs2build.home}&quot;"/>
1692 <filter token="gsdl3srchome" value="${basedir}"/>
1693 <filter token="gsdl3srchomequoted" value="&quot;${basedir}&quot;"/>
1694 <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
1695 <filter token="gsdl3homequoted" value="&quot;${src.gsdl3.home.unix}&quot;"/>
1696 <filter token="gsdl3writablehome" value="${src.gsdl3.writablehome.unix}"/>
1697 <filter token="gsdl3version" value="${app.version}"/>
1698 <filter token="server.protocols" value="${server.protocols}"/>
1699 <filter token="default.server.protocol" value="${default.server.protocol}"/>
1700 <filter token="tomcat.server" value="${tomcat.server}"/>
1701 <filter token="default.tomcat.port" value="${default.tomcat.port}"/>
1702 <filter token="localhost.server.http" value="${localhost.server.http}"/>
1703 <filter token="localhost.port.http" value="${localhost.port.http}"/>
1704 <filter token="tomcat.port.https" value="${tomcat.port.https}"/>
1705 <filter token="restrict.http.to.local" value="${restrict.http.to.local}"/>
1706 <filter token="greenstone.context" value="${greenstone.context}"/>
1707 <filter token="solr.context" value="${solr.context}"/>
1708 <filter token="derbyserver" value="${derby.server}"/>
1709 <filter token="derbyserver.port" value="${derby.server.port}"/>
1710 <filter token="perlpath" value="${escaped.perl.path}"/>
1711 <filter token="disable.collection.building" value="${disable.collection.building}"/>
1712 <copy file="${basedir}/resources/cgi/gsdl3site.cfg.in" tofile="${web.writablehome}/WEB-INF/cgi/gsdl3site.cfg" filtering="true" overwrite="true"/>
1713 <copy file="${basedir}/resources/web/global.properties.in" tofile="${web.writableclasses}/global.properties" filtering="true" overwrite="true"/>
1714 <copy file="${basedir}/resources/web/log4j.properties.in" tofile="${web.writableclasses}/log4j.properties" filtering="true" overwrite="true"/>
1715 <if>
1716 <bool><istrue value="${gsdl3home.isreadonly}"/></bool>
1717 <!-- uncomment the writablehome properties -->
1718 <rsr verbosity="1" file="${web.writableclasses}/global.properties" pattern="^#gsdl3\.(writable{1})?home" replacement="gsdl3.$1home" />
1719 </if>
1720 <chmod file="${web.writableclasses}/global.properties" perm="644"/>
1721 <chmod file="${web.writableclasses}/log4j.properties" perm="644"/>
1722
1723 <copy file="${basedir}/resources/iiif/cantaloupe.properties.in" tofile="${basedir}/cantaloupe.properties" filtering="true" overwrite="true"/>
1724 <chmod file="${basedir}/cantaloupe.properties" perm="644"/>
1725 </target>
1726
1727 <target name="compile-web" depends="init">
1728 <javac srcdir="${web.classes}"
1729 destdir="${web.classes}"
1730 includeantruntime="${compile.includeantruntime}"
1731 debug="${compile.debug}"
1732 deprecation="${compile.deprecation}"
1733 optimize="${compile.optimize}"
1734 encoding="${compile.encoding}">
1735 <classpath><path refid="compile.classpath"/></classpath>
1736 </javac>
1737 </target>
1738
1739 <target name="compile-classpath-jars" depends="init">
1740 <if><bool><available file="admin/cp.mf"/></bool>
1741 <jar destfile="admin/cp.jar" manifest="admin/cp.mf"/>
1742 </if>
1743 <if><bool><available file="${lib.java}/cp.mf"/></bool>
1744 <jar destfile="${lib.java}/cp.jar" manifest="${lib.java}/cp.mf"/>
1745 </if>
1746 <if><bool><available file="${lib.jni}/cp.mf"/></bool>
1747 <jar destfile="${lib.jni}/cp.jar" manifest="${lib.jni}/cp.mf"/>
1748 </if>
1749 <if><bool><available file="${web.lib}/cp.mf"/></bool>
1750 <jar destfile="${web.lib}/cp.jar" manifest="${web.lib}/cp.mf"/>
1751 </if>
1752 <jar destfile="cp.jar">
1753 <manifest>
1754 <attribute name="Class-Path" value="server.jar admin/cp.jar lib/java/cp.jar lib/jni/cp.jar web/WEB-INF/lib/cp.jar"/>
1755 </manifest>
1756 </jar>
1757 </target>
1758
1759 <target name="clean-classpath-jars" depends="init">
1760 <delete file="admin/cp.jar"/>
1761 <delete file="${lib.java}/cp.jar"/>
1762 <delete file="${lib.jni}/cp.jar"/>
1763 <delete file="${web.lib}/cp.jar"/>
1764 <delete file="cp.jar"/>
1765 </target>
1766
1767
1768 <target name="svnupdate-web" unless="nosvn.mode">
1769 <exec executable="svn">
1770 <arg value="update"/>
1771 <arg value="${web.writablehome}"/>
1772 <arg value="-r"/><arg value="${branch.revision}"/>
1773 </exec>
1774 </target>
1775
1776 <target name="update-web" depends="init,svnupdate-web,configure-web"
1777 description="update only the web stuff (config files)"/>
1778
1779 <!-- ============ Targets concerned with https certification ================ -->
1780
1781 <target name="setup-https-cert-info">
1782 <echo>
1783 *********************************************************************
1784 NOTE TO OBTAINING A TLS (SSL) CERTIFICATE FOR HTTPS
1785 *********************************************************************
1786 A signed certificate is needed for your GS server to serve pages over https.
1787 This target will attempt to obtain a certificate for you from the official and free Certificate Authority Let's Encrypt.
1788 However, a certificate can only be obtained if you have admin/sudo permissions on this machine that you're installing Greenstone on.
1789
1790 Note that:
1791 * 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.
1792 * 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.
1793 </echo>
1794 </target>
1795
1796
1797 <target name="https-conditions-set">
1798 <input addproperty="https.conditions.ok" validargs="y,n">
1799 To run this target, ensure you have:
1800 * (if on unix) sudo permissions. Enter the sudo password if prompted.
1801 * (if on windows) sufficient privileges to run the included tomcat on port 80.
1802 * nothing running on port 80 when you run this target
1803 * edited the build.properties file with
1804 - tomcat.server set to the/a domain name of your server
1805 - 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)
1806 - tomcat.port.https set to a valid port number not yet in use
1807 - keystore.pass set to a password for the certification process
1808 * read the Let's Encrypt Subscriber Agreement at https://letsencrypt.org/repository/
1809 If any of the above is not possible, quit this target. Continue [y/n]?
1810 </input>
1811
1812 <condition property="quit.https.setup">
1813 <equals arg1="n" arg2="${https.conditions.ok}"/>
1814 </condition>
1815
1816 <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>
1817 </target>
1818
1819
1820 <target name="setup-https-cert" depends="setup-https-cert-info,https-conditions-set">
1821 <if><bool><not><matches string="${server.protocols}" pattern="https"/></not></bool>
1822 <fail>To setup https certification, the server.protocols property in file build.properties must contain 'https'</fail>
1823 </if>
1824
1825 <input addproperty="https.cert.email">Enter an email that Let's Encrypt, the certification authority, can send any important notifications to</input>
1826 <input addproperty="https.other.domains">Besides tomcat.server=${tomcat.server}, enter a comma separated list of additional domains to support, if any</input>
1827 <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>
1828 <if>
1829 <bool><equals arg1="y" arg2="${https.cert.agree}"/></bool>
1830
1831 <condition property="https.cert.domains" value="${tomcat.server},${https.other.domains}" else="${tomcat.server}">
1832 <and>
1833 <isset property="https.other.domains" />
1834 <not><matches string="${https.other.domains}" pattern="^\s*$"/></not>
1835 </and>
1836 </condition>
1837
1838 <input addproperty="https.do.cert" validargs="y,n">
1839 You've agreed to the Let's Encrypt TOS with
1840 - email: ${https.cert.email}
1841 - domains: ${https.cert.domains}
1842 Looks okay? [y/n]
1843 </input>
1844 </if>
1845
1846 <if><bool><equals arg1="n" arg2="${https.do.cert}"/></bool>
1847 <echo>Not proceeding with https certification for the Greenstone 3 web server</echo>
1848 <else>
1849 <echo>Proceeding...</echo>
1850 <if><bool><istrue value="${current.os.iswindows}"/></bool>
1851 <antcall target="setup-https-cert-windows">
1852 <param name="https.cert.renewal" value=""/><!-- for cert issuance, there are none of the additional parameters specific to cert renewal -->
1853 </antcall>
1854 </if>
1855 <if><bool><istrue value="${current.os.isunixnotmac}"/></bool>
1856 <antcall target="setup-https-cert-linux"/>
1857 </if>
1858 <if><bool><istrue value="${current.os.ismac}"/></bool>
1859 <antcall target="setup-https-cert-mac"/>
1860 </if>
1861 </else>
1862 </if>
1863
1864 </target>
1865
1866
1867 <target name="setup-https-cert-windows">
1868
1869 <echo>********** The included tomcat will be stopped, then restarted on port 80 and stopped again</echo>
1870
1871 <!-- create folder packages\tomcat\webapps\ROOT\.well-known\acme-challenge -->
1872 <mkdir dir="${packages.home}/tomcat/webapps/ROOT/.well-known/acme-challenge"/>
1873 <mkdir dir="${packages.home}/tomcat/conf/https_cert"/>
1874
1875 <!--
1876 For Windows, Greenstone can generate the account and domain keys with the openSSL we compiled up ourselves
1877 and put on SVN (at GS3/bin/windows/openssl) rather than let ZeroSSL generate these keys for the user.
1878 Letting Greenstone generate the keys may be considered more trustworthy by the user than letting a 3rd
1879 party do so. See https://zerossl.com/usage.html#First_time_run_and_regular_use for OpenSSL commands
1880 If we don't generate the keys ourselves with our OpenSSL, then ZeroSSL will do so automatically in the
1881 call to le64/32.exe further below, as it's passed in the flag generate-missing.
1882 -->
1883 <!-- We generate the account key named "privkey.key" in ${packages.home}\tomcat\conf\https_cert -->
1884 <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
1885 <arg value="/c" />
1886 <arg value="openssl.exe" />
1887 <arg value="genrsa" />
1888 <arg value="-out" /><arg value="${packages.home}\tomcat\conf\https_cert\privkey.key" /><arg value="4096" />
1889 </exec>
1890
1891 <!-- Also generate the domain key (for csr-key parameter to zeroSSL's le.exe)
1892 ${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key
1893 Using 2048 instead of 4096 bits for this. See https://zerossl.com/usage.html#First_time_run_and_regular_use
1894 -->
1895 <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
1896 <arg value="/c" />
1897 <arg value="openssl.exe" />
1898 <arg value="genrsa" />
1899 <arg value="-out" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key" /><arg value="2048" />
1900 </exec>
1901
1902 <!-- stop the included tomcat (also stopping derby and solr) -->
1903 <antcall target="stop" />
1904
1905 <!-- rerun tomcat on port 80
1906 See https://ant.apache.org/manual/Tasks/antcall.html -->
1907 <antcall target="start">
1908 <param name="localhost.port.http" value="80"/>
1909 <param name="default.tomcat.port" value="80"/>
1910 <param name="local.http.url" value="http://${localhost.server.http}"/><!-- For port 80 over http, leave out port number in URL -->
1911 <param name="http.address.restriction" value=""/><!-- don't prevent public access over http of port 80 -->
1912 <param name="https.comment.out.start" value="${comment.start}"/>
1913 <param name="https.comment.out.end" value="${comment.end}"/>
1914 </antcall>
1915
1916 <!-- get the certificate: use zerossl for windows
1917 Download from https://github.com/do-know/Crypt-LE/releases,
1918 For licence see https://github.com/do-know/Crypt-LE/
1919 Usage instructions at https://zerossl.com/usage.html
1920
1921 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}"
1922
1923 which generates a .pfx file with the same name as the PEM certificate (.crt param below)
1924 .pfx vs .p12: https://stackoverflow.com/questions/6819079/convert-pfx-format-to-p12
1925
1926 In this case "fullchain_and_prvtkey.pfx" is generated, which is the windows value of ${keystore.file} property
1927
1928 Helpful for debugging: https://stackoverflow.com/questions/10302489/ant-script-have-exec-tag-dump-out-entire-command-line
1929 -->
1930 <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}" spawn="false">
1931 <arg value="/c" />
1932 <arg value="le${os.bitness}" />
1933 <arg value="--key" /><arg value="${packages.home}\tomcat\conf\https_cert\privkey.key" />
1934 <arg value="--csr" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.csr" />
1935 <arg value="--csr-key" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key" />
1936 <!--<arg value="==crt" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.crt" />-->
1937 <arg value="--crt" /><arg value="${packages.home}\tomcat\conf\https_cert\fullchain_and_prvtkey.crt" />
1938 <arg value="--domains" /><arg value="${https.cert.domains}" />
1939 <arg value="--path" /><arg value="${packages.home}\tomcat\webapps\ROOT\.well-known\acme-challenge" />
1940 <arg value="--generate-missing" />
1941 <arg value="--unlink" />
1942 <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 -->
1943 <!--<arg value="==export-pfx" /><arg value="${keystore.pass}" />
1944 <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-->
1945 <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. -->
1946 </exec>
1947
1948 <!-- stop the tomcat running on port 80 -->
1949 <antcall target="stop">
1950 <param name="localhost.port.http" value="80"/>
1951 <param name="default.tomcat.port" value="80"/>
1952 <param name="local.http.url" value="http://${localhost.server.http}"/><!-- For port 80 over http, leave out port number in URL -->
1953 <param name="http.address.restriction" value=""/>
1954 <param name="https.comment.out.start" value="${comment.start}"/>
1955 <param name="https.comment.out.end" value="${comment.end}"/>
1956 </antcall>
1957
1958 <!-- Use OpenSSL instead of ZeroSSL to convert the certificate to the .pfx format that tomcat likes, using this cmd:
1959 GS3/bin/windows/openssl/bin/openssl.exe pkcs12 -inkey domain.key -in domain.crt -passin pass:pwd -passout pass:pwd -export -out ${keystore.file}
1960 GS3/bin/windows/openssl/bin/openssl.exe pkcs12 -inkey domain.key -in domain.crt -password pass:pwd -export -out ${keystore.file}
1961 where on windows, keystore.file = fullchain_and_prvtkey.pfx
1962 -->
1963 <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
1964 <arg value="/c" />
1965 <arg value="openssl.exe" />
1966 <arg value="pkcs12" />
1967 <arg value="-inkey" /><arg value="${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key" />
1968 <arg value="-in" /><arg value="${packages.home}\tomcat\conf\https_cert\fullchain_and_prvtkey.crt" />
1969 <arg value="-export" />
1970 <arg value="-out" /><arg value="${packages.home}\tomcat\conf\https_cert\${keystore.file}" />
1971 <arg value="-name"/><arg value="greenstone3-tomcat"/><!-- See https://stackoverflow.com/questions/808669/convert-a-cert-pem-certificate-to-a-pfx-certificate -->
1972 <arg value="-password"/><arg value="pass:${keystore.pass}"/>
1973 </exec>
1974
1975 </target>
1976
1977
1978 <!-- On Mac as on Linux, we need sudo permissions to setup https certification.
1979 But unlike on Linux, on Mac we only need to sudo when running tomcat on port 80
1980 and when stopping tomcat running on port 80. But we don't need to sudo on a Mac when calling le.pl.
1981 This also means all the files in https_cert have the correct (user, not root) permissions.
1982 -->
1983 <target name="setup-https-cert-mac">
1984
1985 <echo>********** The included tomcat will be stopped, then restarted on port 80 and stopped again</echo>
1986
1987 <!-- create folder packages\tomcat\webapps\ROOT\.well-known\acme-challenge -->
1988 <mkdir dir="${packages.home}/tomcat/webapps/ROOT/.well-known/acme-challenge"/>
1989 <mkdir dir="${packages.home}/tomcat/conf/https_cert"/>
1990
1991 <!--
1992 See comments under setup-https-cert-WINDOWS
1993 -->
1994 <!-- We generate the account key named "privkey.key" in ${packages.home}\tomcat\conf\https_cert -->
1995 <if><bool><not><available file="${packages.home}/tomcat/conf/https_cert/privkey.key"/></not></bool>
1996 <exec executable="openssl" osfamily="mac" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
1997 <arg value="genrsa" />
1998 <arg value="-out" /><arg value="${packages.home}/tomcat/conf/https_cert/privkey.key" /><arg value="4096" />
1999 </exec>
2000 </if>
2001
2002 <!-- Also generate the domain key (for csr-key parameter to zeroSSL's le.pl)
2003 ${packages.home}\tomcat\conf\https_cert\${tomcat.server}.key
2004 Using 2048 instead of 4096 bits for this. See https://zerossl.com/usage.html#First_time_run_and_regular_use
2005 -->
2006 <if><bool><not><available file="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.key"/></not></bool>
2007 <exec executable="openssl" osfamily="mac" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
2008 <arg value="genrsa" />
2009 <arg value="-out" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.key" /><arg value="2048" />
2010 </exec>
2011 </if>
2012
2013 <!-- stop the included tomcat (also stopping derby and solr) -->
2014 <antcall target="stop" />
2015
2016 <!-- rerun tomcat on port 80
2017 See https://ant.apache.org/manual/Tasks/antcall.html -->
2018 <antcall target="start">
2019 <param name="sudo.or.not" value="/usr/bin/sudo" />
2020 <param name="localhost.port.http" value="80"/>
2021 <param name="default.tomcat.port" value="80"/>
2022 <param name="local.http.url" value="http://${localhost.server.http}"/><!-- For port 80 over http, leave out port number in URL -->
2023 <param name="http.address.restriction" value=""/><!-- don't prevent public access over http of port 80 -->
2024 <param name="https.comment.out.start" value="${comment.start}"/>
2025 <param name="https.comment.out.end" value="${comment.end}"/>
2026 </antcall>
2027
2028 <!-- get the certificate: use zerossl's le.pl compiled up for Mac.
2029 For further notes, see under setup-https-cert-WINDOWS
2030 -->
2031
2032 <exec executable="perl" osfamily="mac" dir="${gs2build.home}/perllib/cpan/Crypt/LE/bin" spawn="false">
2033 <env key="PERL5LIB" value="${gs2build.home}/perllib/cpan${path.separator}${gs2build.home}/perllib/cpan/perl-5.18"/>
2034 <arg value="-S" />
2035 <arg value="${gs2build.home}/perllib/cpan/Crypt/LE/bin/le.pl" />
2036 <arg value="--key" /><arg value="${packages.home}/tomcat/conf/https_cert/privkey.key" />
2037 <arg value="--csr" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.csr" />
2038 <arg value="--csr-key" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.key" />
2039 <!--<arg value="==crt" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.crt" />-->
2040 <arg value="--crt" /><arg value="${packages.home}/tomcat/conf/https_cert/fullchain_and_prvtkey.crt" />
2041 <arg value="--domains" /><arg value="${https.cert.domains}" />
2042 <arg value="--path" /><arg value="${packages.home}/tomcat/webapps/ROOT/.well-known/acme-challenge" />
2043 <arg value="--generate-missing" />
2044 <arg value="--unlink" />
2045 <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 -->
2046 <!--<arg value="==export-pfx" /><arg value="${keystore.pass}" />
2047 <arg value="==tag-pfx" /><arg value="greenstone3-tomcat" />--><!-- not sure if this generates a keystore filename with ext .p12 or .pfx for Macs -->
2048 <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. -->
2049 </exec>
2050
2051 <!-- stop the tomcat running on port 80 -->
2052 <antcall target="stop">
2053 <param name="sudo.or.not" value="/usr/bin/sudo" />
2054 <param name="localhost.port.http" value="80"/>
2055 <param name="default.tomcat.port" value="80"/>
2056 <param name="local.http.url" value="http://${localhost.server.http}"/>
2057 <param name="http.address.restriction" value=""/>
2058 <param name="https.comment.out.start" value="${comment.start}"/>
2059 <param name="https.comment.out.end" value="${comment.end}"/>
2060 </antcall>
2061
2062 <!-- Use OpenSSL instead of ZeroSSL to convert the certificate to the .pfx format that tomcat likes, using this cmd:
2063 GS3/bin/windows/openssl/bin/openssl.exe pkcs12 -inkey domain.key -in domain.crt -passin pass:pwd -passout pass:pwd -export -out ${keystore.file}
2064 GS3/bin/windows/openssl/bin/openssl.exe pkcs12 -inkey domain.key -in domain.crt -password pass:pwd -export -out ${keystore.file}
2065 where on windows, keystore.file = fullchain_and_prvtkey.pfx
2066 -->
2067 <exec executable="openssl" osfamily="mac" dir="${basedir}/bin/${os.bin.dir}/openssl/bin" spawn="false">
2068 <arg value="pkcs12" />
2069 <arg value="-inkey" /><arg value="${packages.home}/tomcat/conf/https_cert/${tomcat.server}.key" />
2070 <arg value="-in" /><arg value="${packages.home}/tomcat/conf/https_cert/fullchain_and_prvtkey.crt" />
2071 <arg value="-export" />
2072 <arg value="-out" /><arg value="${packages.home}/tomcat/conf/https_cert/${keystore.file}" />
2073 <arg value="-name"/><arg value="greenstone3-tomcat"/><!-- See https://stackoverflow.com/questions/808669/convert-a-cert-pem-certificate-to-a-pfx-certificate -->
2074 <arg value="-password"/><arg value="pass:${keystore.pass}"/>
2075 </exec>
2076
2077 </target>
2078
2079
2080
2081 <target name="setup-https-cert-linux">
2082 <!-- Running as
2083 ./certbot-auto certonly ==standalone ==preferred-challenges http ==email EMAIL -d DOMAINS
2084 expects input from stdin to accept (A) ToS and say Yes (Y) to sharing email.
2085 We can run in non-interactive mode as the user has at this stage already agreed
2086 to LetsEncrypt's Terms of Service and provided an email address.
2087 -->
2088 <exec executable="/bin/bash" dir="${basedir}/bin/${os.bin.dir}" failonerror="true">
2089 <arg value="./certbot-auto"/>
2090 <arg value="certonly"/>
2091 <arg line="${https.testing}"/><!-- https://stackoverflow.com/questions/11840284/pass-arguments-to-apache-ant-exec-task-based-on-the-variables-value -->
2092 <arg value="--standalone"/>
2093 <arg value="--non-interactive"/>
2094 <arg value="--agree-tos"/>
2095 <arg value="--preferred-challenges"/><arg value="http"/>
2096 <arg value="--email"/><arg value="${https.cert.email}"/>
2097 <arg value="--domains"/><arg value="${https.cert.domains}"/>
2098 </exec>
2099
2100 <!-- sudo openssl pkcs12 -export -out /tmp/DOMAIN_fullchain_and_key.p12 \
2101 -in /etc/letsencrypt/live/DOMAIN/fullchain.pem \
2102 -inkey /etc/letsencrypt/live/DOMAIN/privkey.pem \
2103 -name tomcat
2104 Must run as sudo because only admin has access to the pem files that admin
2105 generated in /etc/letsencrypt
2106 See https://computingforgeeks.com/tomcat-7-with-letsencrypt-ssl-certificate/
2107 but also https://community.letsencrypt.org/t/using-lets-encrypt-with-tomcat/41082
2108 which bypasses the step to generate the java keystore jks file
2109 and uses openssl to generate a pfx file instead of a p12 file
2110 -->
2111
2112 <exec executable="sudo" dir="/tmp" failonerror="true">
2113 <arg value="${basedir}/bin/${os.bin.dir}/openssl/bin/openssl"/>
2114 <arg value="pkcs12"/>
2115 <arg value="-export"/>
2116 <arg value="-out"/><arg value="/tmp/${tomcat.server}_fullchain_and_key.p12"/>
2117 <arg value="-in"/><arg value="/etc/letsencrypt/live/${tomcat.server}/fullchain.pem"/>
2118 <arg value="-inkey"/><arg value="/etc/letsencrypt/live/${tomcat.server}/privkey.pem"/>
2119 <arg value="-name"/><arg value="greenstone3-tomcat"/>
2120 <arg value="-password"/><arg value="pass:${keystore.pass}"/>
2121 </exec>
2122
2123 <!-- Finally, mkdir ${packages.home}/tomcat/conf/https_cert
2124 and copy the file /tmp/${tomcat.server}_fullchain_and_key.p12 into it
2125 and rename to a slightly shorter and simpler name,
2126 see https://stackoverflow.com/questions/8971187/ant-renaming-while-copying-file
2127 The file in tmp has root permissions. But copying it from tmp into
2128 the local account will give the copy local account permissions.
2129 Then sudo to remove the original copy in /tmp
2130 -->
2131 <mkdir dir="${packages.home}/tomcat/conf/https_cert"/>
2132 <!--<copy file="/tmp/${tomcat.server}_fullchain_and_key.p12" todir="${packages.home}/tomcat/conf/https_cert"/>-->
2133 <copy todir="${packages.home}/tomcat/conf/https_cert">
2134 <fileset file="/tmp/${tomcat.server}_fullchain_and_key.p12"/>
2135 <globmapper from="${tomcat.server}_fullchain_and_key.p12" to="${keystore.file}"/>
2136 </copy>
2137
2138 <exec executable="sudo" dir="/tmp" failonerror="true">
2139 <arg line="rm -f /tmp/${tomcat.server}_fullchain_and_key.p12" />
2140 </exec>
2141
2142 </target>
2143
2144
2145 <!-- Revoke the certificate and remove it, including folders.
2146 See https://certbot.eff.org/docs/using.html#revoking-certificates
2147 which also states "if a certificate is a test certificate obtained via the
2148 ==staging or ==test-cert flag, that flag must be passed to the revoke subcommand."
2149 -->
2150 <target name="remove-https-cert">
2151 <echo>
2152 NOTE: If you're on Linux, you need to have sudo permissions to execute this target.
2153 Enter the sudo password if prompted.
2154 </echo>
2155 <!--
2156 On linux, we use certbot-auto.
2157 It says at https://github.com/certbot/certbot/issues/1741
2158 "you shouldn't run letsencrypt-auto [now called certbot-auto] as superuser,
2159 because the program will invoke sudo when it needs to automatically."
2160 We need to send Y(es) as inputstring to confirm that the
2161 /etc/letsencrypt/live/${tomcat.server} folder can be deleted.
2162 Note osfamily="unix" is separate from osfamily="mac", which comes out handy here as we haven't set up certbot-auto for mac (yet).
2163 -->
2164 <exec executable="./certbot-auto" os="${os.linux},${os.solaris}" dir="${basedir}/bin/${os.bin.dir}" failonerror="true" inputstring="Y">
2165 <arg value="revoke"/>
2166 <arg line="${https.testing}"/>
2167 <arg value="--cert-path"/><arg value="/etc/letsencrypt/live/${tomcat.server}/cert.pem"/>
2168 </exec>
2169 <!-- The above command already deletes the folder when Y(es) was passed in. Explicitly deleting:
2170 <exec executable="./certbot-auto" dir="${basedir}/bin/${os.bin.dir}" failonerror="true">
2171 <arg value="delete"/>
2172 <arg value="==cert-name"/><arg value="${tomcat.server}"/>
2173 </exec>
2174 -->
2175
2176 <!-- On Windows and Mac, we use zeroSSl. For the revoke command, see https://zerossl.com/usage.html#Certificate_revocation -->
2177 <exec executable="cmd" osfamily="windows" dir="${basedir}/bin/${os.bin.dir}" spawn="false">
2178 <arg value="/c" />
2179 <arg value="le${os.bitness}" />
2180 <arg value="--key" /><arg value="${packages.home}\tomcat\conf\https_cert\privkey.key" />
2181 <arg value="--crt" /><arg value="${packages.home}\tomcat\conf\https_cert\fullchain_and_prvtkey.crt"/>
2182 <arg value="--revoke"/>
2183 <arg line="${https.testing}"/>
2184 </exec>
2185
2186 <!-- On Mac, we use the le.pl we compiled up (Crypt::LE) and which needs to have PERL5LIB set correctly to run -->
2187 <exec executable="perl" osfamily="mac" dir="${gs2build.home}/perllib/cpan/Crypt/LE/bin" spawn="false">
2188 <env key="PERL5LIB" value="${gs2build.home}/perllib/cpan${path.separator}${gs2build.home}/perllib/cpan/perl-5.18"/>
2189 <arg value="-S" />
2190 <arg value="${gs2build.home}/perllib/cpan/Crypt/LE/bin/le.pl" />
2191 <arg value="--key" /><arg value="${packages.home}/tomcat/conf/https_cert/privkey.key" />
2192 <arg value="--crt" /><arg value="${packages.home}/tomcat/conf/https_cert/fullchain_and_prvtkey.crt"/>
2193 <arg value="--revoke"/>
2194 <arg line="${https.testing}"/>
2195 </exec>
2196
2197 <!-- And remove the https_cert folder -->
2198 <delete dir="${packages.home}/tomcat/conf/https_cert"/>
2199 </target>
2200
2201
2202 <!-- Renewing existing https certificate
2203 Linux:
2204 https://certbot.eff.org/docs/using.html#renewing-certificates
2205 ./path/to/GS3/bin/linux/certbot-auto renew ==quiet ==no-self-upgrade
2206 Windows: reuse Windows issuance target
2207 see https://zerossl.com/usage.html#Certificate_renewal
2208 -->
2209 <target name="renew-existing-https-cert">
2210 <echo>
2211 NOTE: To run this target,
2212 * ensure nothing is running on port 80
2213 * if you're on Linux or Mac, you need to have sudo permissions. Enter the sudo password if prompted.
2214
2215 If you want your cronjob to renew a certificate, you can add pre and post hooks
2216 refer to https://certbot.eff.org/docs/using.html#renewing-certificates
2217 For more information run:
2218 ./path/to/GS3/bin/linux/certbot-auto --help renew
2219 </echo>
2220 <exec executable="./certbot-auto" os="${os.linux},${os.solaris}" dir="${basedir}/bin/${os.bin.dir}" failonerror="true">
2221 <arg value="renew"/>
2222 <arg value="--quiet"/>
2223 <arg value="--no-self-upgrade"/>
2224 </exec>
2225
2226 <!-- For renewal on Windows or Mac, we use ZeroSSL as intermediary between GS3 and Let's Encrypt.
2227 And when using ZeroSSL we need to re-run the original (issuance) command and append "min-min-renew XX" to it,
2228 where if it's within XX days of expiry, the certificate will get renewed.
2229 See https://zerossl.com/usage.html#Certificate_renewal -->
2230 <if><bool><or>
2231 <istrue value="${current.os.iswindows}"/>
2232 <istrue value="${current.os.ismac}"/>
2233 </or></bool>
2234
2235 <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>
2236 <condition property="https.cert.domains" value="${tomcat.server},${https.other.domains}" else="${tomcat.server}">
2237 <and>
2238 <isset property="https.other.domains" />
2239 <not><matches string="${https.other.domains}" pattern="^\s*$"/></not>
2240 </and>
2241 </condition>
2242 <if><bool><istrue value="${current.os.iswindows}"/></bool>
2243 <antcall target="setup-https-cert-windows">
2244 <param name="https.cert.renewal" value="--renew 10"/>
2245 </antcall>
2246 <else>
2247 <antcall target="setup-https-cert-mac">
2248 <param name="https.cert.renewal" value="--renew 10"/>
2249 </antcall>
2250 </else>
2251 </if>
2252 </if>
2253 </target>
2254
2255 <!-- ======================= Tomcat Targets ========================== -->
2256
2257 <!-- this target downloads and installs Tomcat -->
2258 <!-- we download tomcat (version 7 for Java 1.5 and later, version 5 for Java 1.4 plus the 1.4 compatibility package). -->
2259 <target name="prepare-tomcat" depends="init,setup-proxy" if="tomcat.islocal"
2260 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">
2261 <if>
2262 <bool>
2263 <not><available file="${packages.home}/tomcat/.flagfile"/></not>
2264 </bool>
2265
2266 <!-- check that packages dir is there -->
2267 <mkdir dir="${packages.home}"/>
2268 <!--
2269 <get src="${gsorg.root}/gs3files/${tomcat.version}.zip"
2270 dest="${packages.home}/${tomcat.version}.zip"
2271 usetimestamp="true"/>
2272 -->
2273 <exec executable="wget" failonerror="true">
2274 <arg value="-P"/><!-- specifying output dir, also: minus-minus-directory-prefix -->
2275 <arg value="${packages.home}"/>
2276 <arg value="--no-check-certificate"/>
2277 <arg value="${gsorg.root}/gs3files/${tomcat.version}.zip"/>
2278 </exec>
2279 <unzip src="${packages.home}/${tomcat.version}.zip"
2280 dest="${packages.home}"/>
2281
2282 <!-- If we are using Java 1.4, we'd be using tomcat 5.5 in which case
2283 we would need to have the tomcat compat package to work with Java 1.4-->
2284 <if>
2285 <bool><equals arg1="1.4" arg2="${ant.java.version}"/></bool>
2286 <!--
2287 <get src="${gsorg.root}/gs3files/${tomcat.version}-compat.zip"
2288 dest="${packages.home}/${tomcat.version}-compat.zip"
2289 usetimestamp="true"/>
2290 -->
2291 <exec executable="wget" failonerror="true">
2292 <arg value="-P"/>
2293 <arg value="${packages.home}"/>
2294 <arg value="--no-check-certificate"/>
2295 <arg value="${gsorg.root}/gs3files/${tomcat.version}-compat.zip"/>
2296 </exec>
2297 <unzip src="${packages.home}/${tomcat.version}-compat.zip"
2298 dest="${packages.home}"/>
2299 </if>
2300
2301 <!-- delete any existing tomcat -->
2302 <delete dir="${packages.home}/tomcat"/>
2303 <move todir="${packages.home}/tomcat">
2304 <fileset dir="${packages.home}/${tomcat.version}"/>
2305 </move>
2306
2307 <!-- To avoid the CGI permissions error appearing continuously in the (localhost) log,
2308 need privileged=true set in the root context.xml file too, not just greenstone context file.
2309 See http://stackoverflow.com/questions/9845936/tomcat-v7-0-load-exception-marking-servlet-ssi-as-unavailable/10305471#10305471
2310 For usage of IfTask IsLessThan: http://antelope.stage.tigris.org/nonav/docs/manual/bk03ch05s02.html -->
2311 <if><bool><not><islessthan arg1="${tomcat.version.major}" arg2="7"/></not></bool>
2312 <copy file="${basedir}/resources/tomcat/root_context.xml.in" tofile="${packages.home}/tomcat/conf/context.xml" overwrite="true" />
2313 </if>
2314
2315
2316 <!--
2317 <copy file="${basedir}/resources/tomcat/setclasspath.bat"
2318 tofile="${packages.home}/tomcat/bin/setclasspath.bat"
2319 overwrite="true"/>
2320 <copy file="${basedir}/resources/tomcat/setclasspath.sh"
2321 tofile="${packages.home}/tomcat/bin/setclasspath.sh"
2322 overwrite="true"/>
2323 -->
2324 <!-- make sure we have execute permission for the .sh files -->
2325 <chmod dir="${packages.home}/tomcat/bin" perm="ugo+rx"
2326 includes="*.sh"/>
2327
2328 <echo file="${packages.home}/tomcat/.flagfile">
2329 the timestamp of this file is the time that tomcat was extracted from the zip files.
2330 it is used to figure out whether the files need to be refreshed or not in `ant prepare-tomcat`
2331 </echo>
2332
2333 <!-- this is not strictly a prepare tomcat thing, but if one changes
2334 Java, then they need to change tomcat as well, so might as well call
2335 it here -->
2336 <antcall target="configure-java-version"/>
2337 <else>
2338 <echo>Tomcat has been prepared, will not prepare</echo>
2339 <echo>Delete ${packages.home}/tomcat/.flagfile to force refresh</echo>
2340 </else>
2341
2342 </if>
2343
2344 </target>
2345
2346 <target name="configure-tomcat" depends="init,configure-tomcat-local,configure-tomcat-external"/>
2347
2348 <target name="configure-tomcat-local" depends="init,perl-for-building" if="tomcat.islocal">
2349 <!-- re-setup the server.xml file -->
2350 <copy file="${basedir}/resources/tomcat/server_tomcat${tomcat.version.major}.xml.in"
2351 tofile="${packages.home}/tomcat/conf/server.xml" overwrite="true">
2352 <filterset>
2353 <filter token="shutdown-port" value="${tomcat.shutdown.port}"/>
2354 <filter token="tomcat.ajp.port" value="${tomcat.ajp.port}"/>
2355 <filter token="https.redirect.port" value="${https.redirect.port}"/>
2356 <filter token="localhost.port.http" value="${localhost.port.http}"/>
2357 <filter token="tomcat.port.https" value="${tomcat.port.https}"/>
2358 <!-- Relative path preferred for keystore.file, in case tomcat is moved elsewhere -->
2359 <!--<filter token="keystore.file" value="conf/https_cert/${tomcat.server}.jks" />-->
2360 <!--ON UNIX: <filter token="keystore.file" value="conf/https_cert/fullchain_and_prvtkey.p12" />-->
2361 <!--ON WINDOWS: <filter token="keystore.file" value="conf/https_cert/fullchain_and_prvtkey.pfx" />-->
2362 <filter token="keystore.file" value="conf/https_cert/${keystore.file}" />
2363 <!-- tomcat Connector's keystoreType param defaults to JKS (Java keystore), see https://tomcat.apache.org/tomcat-7.0-doc/config/http.html
2364 We'll follow the instructions at https://community.letsencrypt.org/t/using-lets-encrypt-with-tomcat/41082,
2365 https://www.ssl.com/how-to/create-a-pfx-p12-certificate-file-using-openssl/
2366 and https://computingforgeeks.com/tomcat-7-with-letsencrypt-ssl-certificate/
2367 (minus the keytool step) and use the PKCS12 file generated by openssl directly,
2368 instead of an additional step to generate the java keystore file from that -->
2369 <filter token="keystore.type" value="PKCS12"/>
2370 <filter token="keystore.pass" value="${keystore.pass}"/>
2371 <!--
2372 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)
2373 In that case, see https://serverfault.com/questions/218666/how-to-configure-tomcat-to-only-listen-to-127-0-0-1
2374 -->
2375 <filter token="http.address.restriction" value="${http.address.restriction}"/>
2376 <filter token="https.comment.out.start" value="${https.comment.out.start}"/>
2377 <filter token="https.comment.out.end" value="${https.comment.out.end}"/>
2378 </filterset>
2379 </copy>
2380
2381 <!-- set up the solr context -->
2382
2383 <!-- First work out the IPv4 address for this machine -->
2384 <exec executable="${basedir}/bin/script/IPv4.sh" os="${os.unix}" failonerror="false" outputproperty="ipv4.val">
2385 <arg value="-format-for-tomcat-context"/>
2386 </exec>
2387 <exec executable="${basedir}/bin/script/IPv4.bat" osfamily="windows" failonerror="false" outputproperty="ipv4.val">
2388 <arg value="-format-for-tomcat-context"/>
2389 </exec>
2390
2391 <copy file="${basedir}/ext/solr/solr-tomcat-context.xml.in" tofile="${packages.home}/tomcat/conf/Catalina/localhost/solr.xml" overwrite="true">
2392 <filterset>
2393 <filter token="solr.context" value="${solr.context}"/>
2394 <filter token="gsdl3webhome" value="${web.writablehome}"/>
2395 <filter token="tomcathome" value="${basedir}/packages/tomcat"/>
2396 <filter token="IPv4" value="${ipv4.val}"/>
2397 </filterset>
2398 </copy>
2399
2400 <!-- set up the greenstone3 context, it may have a custom name specified in build.properties -->
2401 <if><bool><not><equals arg1="greenstone3" arg2="${greenstone.context}"></equals></not></bool>
2402 <copy file="${basedir}/resources/tomcat/greenstone3.xml.in" tofile="${basedir}/resources/tomcat/${greenstone.context}.xml.in" overwrite="true"/>
2403 </if>
2404 <copy file="${basedir}/resources/tomcat/${greenstone.context}.xml.in" tofile="${packages.home}/tomcat/conf/Catalina/localhost/${greenstone.context}.xml" overwrite="true">
2405 <filterset>
2406 <filter token="gsdl3webhome" value="${web.home}"/>
2407 <filter token="gsdl3webwritablehome" value="${web.writablehome}"/>
2408 <filter token="privilegedattribute" value="${privileged.attribute}"/>
2409 <filter token="allowlinking" value="${tomcat.allowLinking}"/>
2410 <filter token="allowedIPs" value="${allowed.IPs}"/>
2411 <filter token="derbyserver" value="${derby.server}"/>
2412 <filter token="derbyserverport" value="${derby.server.port}"/>
2413 </filterset>
2414 </copy>
2415 <if>
2416 <bool>
2417 <and>
2418 <available file="${packages.home}/tomcat/conf/Catalina/localhost/greenstone3.xml"/>
2419 <not><equals arg1="greenstone3" arg2="${greenstone.context}"></equals></not>
2420 </and>
2421 </bool>
2422 <delete file="${packages.home}/tomcat/conf/Catalina/localhost/greenstone3.xml"/>
2423 </if>
2424
2425 <!-- set up the greenstone3 web.xml file -->
2426 <copy file="${basedir}/resources/tomcat/web8.xml.in" tofile="${packages.home}/tomcat/conf/web.xml" overwrite="true">
2427 <filterset>
2428 <filter token="perlpath" value="${perl.path}"/>
2429 </filterset>
2430 </copy>
2431 </target>
2432
2433 <target name="configure-tomcat-external" depends="init" unless="tomcat.islocal">
2434 <!-- re-setup the server.xml file -->
2435 <!-- need to edit the config file, or do we get the user to do this???-->
2436 </target>
2437
2438 <target name="configure-solr-ext" depends="init" >
2439 <!-- re-setup the web/ext/solr/solr.xml file -->
2440 <copy file="${web.home}/ext/solr/solr.xml.in"
2441 tofile="${gsdl3.writablehome}/ext/solr/solr.xml" filtering="true" overwrite="true">
2442 <filterset>
2443 <filter token="gsdl3.home" value="${src.gsdl3.home.unix}"/>
2444 <filter token="gsdl3.writablehome" value="${src.gsdl3.writablehome.unix}"/>
2445 </filterset>
2446 </copy>
2447 </target>
2448
2449 <!-- This target runs tomcat's "bin/catalina.bat(.sh) jpda start"
2450 to allow debugging the running GS3 server in Eclipse. See the instructions at
2451 http://www.wikijava.org/wiki/Debugging_a_servlet_with_tomcat_and_Eclipse_tutorial
2452 on how to use this with eclipse
2453 -->
2454 <target name="debug-start-tomcat" description="Startup Tomcat for debugger" depends="init" if="tomcat.islocal">
2455 <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
2456 <property name="tomcat.path" refid="local.tomcat.path"/>
2457
2458 <if><bool>
2459 <isset property="fedora.maxpermsize"/></bool>
2460 <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}"/>
2461 <else>
2462 <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}"/>
2463 </else>
2464 </if>
2465
2466 <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
2467 <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
2468
2469 <exec executable="${catalina.home}/bin/catalina.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
2470 <arg value="jpda" />
2471 <arg value="start" />
2472 <env key="JPDA_ADDRESS" value="8000"/> <!-- for debugging Tomcat in Eclipse -->
2473 <env key="JPDA_TRANSPORT" value="dt_socket"/> <!-- for debugging Tomcat in Eclipse -->
2474 <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
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="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
2480 <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
2481 <env key="WNHOME" path="${wn.home}"/>
2482 <env key="FEDORA_HOME" path="${fedora.home}"/>
2483 </exec>
2484 <exec executable="${catalina.home}/bin/catalina.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="true">
2485 <arg value="jpda" />
2486 <arg value="start" />
2487 <env key="JPDA_ADDRESS" value="8000"/> <!-- for debugging Tomcat in Eclipse -->
2488 <env key="JPDA_TRANSPORT" value="dt_socket"/> <!-- for debugging Tomcat in Eclipse -->
2489 <env key="GSDLOS" value="windows"/>
2490 <env key="GSDL3HOME" value="${web.home}"/>
2491 <env key="Path" path="${tomcat.path}"/>
2492 <env key="PATH" path="${tomcat.path}"/>
2493 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
2494 <env key="CATALINA_HOME" value="${catalina.home}"/>
2495 <env key="CLASSPATH" path="${tomcat.classpath}"/>
2496 <env key="FEDORA_HOME" path="${fedora.home}"/>
2497 </exec>
2498 <!-- wait for the server to startup in case other targets need it running -->
2499 <waitfor maxwait="5" maxwaitunit="second">
2500 <and>
2501 <socket server="${tomcat.server}" port="${default.tomcat.port}"/>
2502 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/index.html"/>-->
2503 <http url="${local.http.url}${app.path}/index.html"/>
2504 </and>
2505 </waitfor>
2506 </target>
2507
2508 <target name="start-tomcat" description="Startup only Tomcat" depends="check-tomcat-started">
2509
2510 <if><bool><istrue value="${tomcat.isstarted}"/></bool>
2511 <echo>**************************************</echo>
2512 <echo>A WEB SERVER IS ALREADY RUNNING ON ${default.server.protocol}://${tomcat.server}:${default.tomcat.port} (${local.http.url}). NOT STARTING.</echo>
2513 <echo>**************************************</echo>
2514 <else>
2515 <antcall target="force-start-tomcat"/>
2516 </else>
2517 </if>
2518 </target>
2519
2520 <!-- Another way: http://ptrthomas.wordpress.com/2006/03/25/how-to-start-and-stop-tomcat-from-ant/ -->
2521 <target name="force-start-tomcat" description="Startup only Tomcat" depends="init" if="tomcat.islocal">
2522
2523 <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
2524 <property name="tomcat.path" refid="local.tomcat.path"/>
2525
2526 <if><bool>
2527 <isset property="fedora.maxpermsize"/></bool>
2528 <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}"/>
2529 <else>
2530 <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}"/>
2531 </else>
2532 </if>
2533
2534 <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
2535 <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
2536
2537 <!-- using osfamily instead of testing os against os.windows list of recognised windows versions
2538 so that future windows versions are included. See http://simonharrer.wordpress.com/tag/osfamily/
2539 Can't use the osfamily test for linux-type machines as a group since osfamily=unix is separate from osfamily=mac,
2540 see http://ant-contrib.sourceforge.net/tasks/tasks/osfamily.html -->
2541
2542 <!--<exec executable="${catalina.home}/bin/startup.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">-->
2543 <exec executable="${sudo.or.not}" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
2544 <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
2545 <!--<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-->
2546 <env key="GSDL3HOME" value="${web.home}"/>
2547 <env key="PATH" path="${tomcat.path}"/>
2548 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
2549 <env key="CATALINA_HOME" value="${catalina.home}"/>
2550 <env key="CLASSPATH" path="${tomcat.classpath}"/>
2551 <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
2552 <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
2553 <env key="WNHOME" path="${wn.home}"/>
2554 <env key="FEDORA_HOME" path="${fedora.home}"/>
2555 <arg value="${catalina.home}/bin/startup.sh"/>
2556 </exec>
2557 <exec executable="${catalina.home}/bin/startup.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="true">
2558 <!--<env key="JAVA_TOOL_OPTIONS" value="-Dfile.encoding=UTF-8"/>-->
2559 <env key="GSDLOS" value="windows"/>
2560 <env key="GSDL3HOME" value="${web.home}"/>
2561 <env key="Path" path="${tomcat.path}"/>
2562 <env key="PATH" path="${tomcat.path}"/>
2563 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
2564 <env key="CATALINA_HOME" value="${catalina.home}"/>
2565 <env key="CLASSPATH" path="${tomcat.classpath}"/>
2566 <env key="FEDORA_HOME" path="${fedora.home}"/>
2567 </exec>
2568 <!-- wait for the server to startup in case other targets need it running -->
2569 <waitfor maxwait="5" maxwaitunit="second">
2570 <and>
2571 <socket server="${tomcat.server}" port="${default.tomcat.port}"/>
2572 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/index.html"/>-->
2573 <http url="${local.http.url}${app.path}/index.html"/>
2574 </and>
2575 </waitfor>
2576
2577 </target>
2578
2579 <!--ant task http: http://www.jajakarta.org/ant/ant-1.6.1/docs/ja/manual/api/org/apache/tools/ant/taskdefs/condition/Http.html-->
2580 <target name="reconfigure" description="Reconfigure the message router">
2581 <waitfor maxwait="5" maxwaitunit="second">
2582 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c"/>-->
2583 <http url="${local.http.url}${app.path}${server.default.servlet}?a=s&amp;sa=c"/>
2584 </waitfor>
2585 </target>
2586
2587 <!--Command-line args to Ant: http://www.jguru.com/faq/view.jsp?EID=471794-->
2588 <target name="reconfigure-collection" description="Reconfigure the collection">
2589 <waitfor maxwait="5" maxwaitunit="second">
2590 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c&amp;sc=${collection}"/>-->
2591 <http url="${local.http.url}${app.path}${server.default.servlet}?a=s&amp;sa=c&amp;sc=${collection}"/>
2592 </waitfor>
2593 </target>
2594
2595 <!-- windows: do we want to launch a webrowser?? -->
2596 <!-- shouldn't this test whether anything is running first?
2597 It's safer to always attempt to stop tomcat: that way we won't be dependent on the right time
2598 to check whether the server is stopped or still running before attempting to start again.
2599 This target, which was recently called force-stop-tomcat for a while but is back to being
2600 called stop-tomcat, now hides the Java exception output that appears whenever tomcat is already
2601 stopped as happens when stop-tomcat is called consecutively. -->
2602 <target name="force-stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal">
2603 <!--<exec executable="${catalina.home}/bin/shutdown.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">-->
2604 <exec executable="${sudo.or.not}" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
2605 <!--<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-->
2606 <env key="FEDORA_HOME" path="${fedora.home}"/>
2607 <env key="CATALINA_HOME" value="${catalina.home}"/>
2608 <arg value="${catalina.home}/bin/shutdown.sh"/>
2609 <arg line=">/dev/null 2>&amp;1"/>
2610 </exec>
2611 <exec executable="${catalina.home}/bin/shutdown.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="false">
2612 <!--<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? -->
2613 <env key="FEDORA_HOME" path="${fedora.home}"/>
2614 <env key="CATALINA_HOME" value="${catalina.home}"/>
2615 <arg line=">nul 2>&amp;1"/>
2616 </exec>
2617 </target>
2618
2619 <!-- Can also try the "socket" condition in place of the "http" condition
2620 And also use a <waitfor> in place of <condition>, such as:
2621 <waitfor maxwait="5" maxwaitunit="second" timeoutproperty="tomcat.isstopped"><http url="..."/></waitfor>
2622 The http URL resolves to host:port/greenstone3
2623 Condition uses <http/> rather than <socket/> for testing, since if the server was stopped, the socket
2624 might still be in use for some moments. We test the URL with the http condition since it's likelier to
2625 fail sooner if the server has indeed been stopped. -->
2626 <target name="check-tomcat-running">
2627 <condition property="tomcat.isrunning">
2628 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}"/>-->
2629 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}"/>--><!-- untrusted certificates won't work, so don't test https urls-->
2630 <http url="${local.http.url}"/><!-- testing the local http url instead -->
2631 </condition>
2632 </target>
2633
2634 <!--
2635 <target name="verbose-check-tomcat-running">
2636 <condition property="tomcat.isrunning" value="true" else="false">
2637 <http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}"/>
2638 <http url="${local.http.url}"/>
2639 </condition>
2640 <echo>Tomcat is running: ${tomcat.isrunning}</echo>
2641 </target>
2642 -->
2643 <target name="verbose-check-tomcat-running" depends="check-tomcat-running">
2644 <if>
2645 <bool>
2646 <istrue value="${tomcat.isrunning}"/>
2647 </bool>
2648 <echo>Tomcat is running: ${tomcat.isrunning}</echo>
2649 <else><echo>Tomcat is running: false</echo></else><!-- tomcat.isrunning not set -->
2650 </if>
2651 </target>
2652
2653 <!-- Need a copy of the check-tomcat-running target with a distinct property, because ant restart runs
2654 both stop and start, both of which need to do tomcat checks. Each property can be set only once during
2655 an invocation with ant. So ant restart will need two properties to store each of the tomcat checks -->
2656 <target name="check-tomcat-started">
2657 <condition property="tomcat.isstarted">
2658 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}"/>-->
2659 <http url="${local.http.url}"/>
2660 </condition>
2661 </target>
2662
2663
2664
2665 <!-- stop-tomcat checks if the tomcat server is already running. If it appears to be running
2666 (regardless of whether tomcat was just starting to shut down), this target calls force-stop-tomcat
2667 to issue the shutdown command to tomcat. Then it waits for at most 15 seconds for the server to
2668 actually stop by checking the socket at which tomcat listens every second, printing a warning
2669 at the end of the max wait time of 15 seconds if tomcat was still running. -->
2670 <target name="stop-tomcat" description="Shutdown only Tomcat if running" depends="check-tomcat-running" if="tomcat.isrunning">
2671 <antcall target="force-stop-tomcat"/>
2672
2673 <property name="wait.numchecks" value="15"/>
2674 <echo>Waiting for the server to shutdown... (${wait.numchecks} seconds max)</echo>
2675 <waitfor maxwait="${wait.numchecks}" maxwaitunit="second" checkevery="1" checkeveryunit="second" timeoutproperty="tomcat.timedout">
2676 <not><socket server="${tomcat.server}" port="${default.tomcat.port}"/></not>
2677 </waitfor>
2678
2679 <if>
2680 <bool>
2681 <isset property="${tomcat.timedout}"/>
2682 </bool>
2683 <property name="tomcat.isrunning" value="true"/>
2684 <echo>WARNING: Checked the socket ${wait.numchecks} times, but port ${default.tomcat.port} is still busy.</echo>
2685 <else>
2686 <echo>Tomcat is stopped.</echo>
2687 <property name="tomcat.isrunning" value="false"/>
2688 </else>
2689 </if>
2690 </target>
2691
2692 <target name="restart-tomcat" description="Shutdown and restart only Tomcat" depends="init,stop-tomcat,force-start-tomcat"/>
2693
2694 <target name="setup-catalina-ant-tasks">
2695 <!-- Configure the custom Ant tasks for the Tomcat Manager application -->
2696 <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"
2697 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2698 <taskdef name="list" classname="org.apache.catalina.ant.ListTask"
2699 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2700 <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"
2701 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2702 <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"
2703 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2704 <taskdef name="roles" classname="org.apache.catalina.ant.RolesTask"
2705 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2706 <taskdef name="start" classname="org.apache.catalina.ant.StartTask"
2707 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2708 <taskdef name="stop" classname="org.apache.catalina.ant.StopTask"
2709 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2710 <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"
2711 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2712 </target>
2713
2714 <!-- http://blog.andrewbeacock.com/2007/11/how-to-truncate-log-file-using-ubuntu.html
2715 Doing "cat </dev/null > packages/tomcat/logs/catalina.out" doesn't work as an ant target.
2716 It seems to have a problem with cat or </dev/null, with or without the < sign. -->
2717 <target name="reset-logs" description="Empties catalina.out, solr.log, greenstone.log, usage.log, server.log and contents of web/logs/tmp">
2718 <echo>Truncating catalina.out, solr.log, greenstone.log, usage.log and server.log, and emptying ${web.writablehome}/logs/tmp</echo>
2719 <exec executable="rm" os="${os.unix}" dir="${catalina.home}/logs" spawn="false">
2720 <arg value="-f"/>
2721 <arg value="catalina.out"/>
2722 </exec>
2723 <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
2724 <arg value="-f"/>
2725 <arg value="greenstone.log"/>
2726 </exec>
2727 <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
2728 <arg value="-f"/>
2729 <arg value="usage.log"/>
2730 </exec>
2731 <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
2732 <arg value="-f"/>
2733 <arg value="server.log"/>
2734 </exec>
2735
2736 <exec executable="touch" os="${os.unix}" dir="${catalina.home}/logs"
2737 spawn="false">
2738 <arg value="catalina.out"/>
2739 </exec>
2740 <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
2741 spawn="false">
2742 <arg value="greenstone.log"/>
2743 </exec>
2744 <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
2745 spawn="false">
2746 <arg value="usage.log"/>
2747 </exec>
2748 <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
2749 spawn="false">
2750 <arg value="server.log"/>
2751 </exec>
2752
2753 <exec executable="cmd" osfamily="windows" dir="${catalina.home}/logs" spawn="false">
2754 <arg line="/c echo. > catalina.out"/>
2755 </exec>
2756 <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
2757 <arg line="/c echo. > greenstone.log"/>
2758 </exec>
2759 <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
2760 <arg line="/c echo. > usage.log"/>
2761 </exec>
2762 <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
2763 <arg line="/c echo. > server.log"/>
2764 </exec>
2765
2766 <!-- if ext/solr/logs/solr.log exists, truncate it -->
2767 <if><bool><available file="${solr-ext.home}/logs/solr.log" type="file"/></bool>
2768 <exec executable="rm" os="${os.unix}" dir="${solr-ext.home}/logs" spawn="false">
2769 <arg value="-f"/>
2770 <arg value="solr.log"/>
2771 </exec>
2772 <exec executable="touch" os="${os.unix}" dir="${solr-ext.home}/logs" spawn="false">
2773 <arg value="solr.log"/>
2774 </exec>
2775 <exec executable="cmd" osfamily="windows" dir="${solr-ext.home}/logs" spawn="false">
2776 <arg line="/c echo. > solr.log"/>
2777 </exec>
2778 </if>
2779
2780 <if>
2781 <bool><available file="${web.writablehome}/logs/tmp" type="dir"/></bool>
2782 <delete>
2783 <fileset dir="${web.writablehome}/logs/tmp" includes="**/*"/>
2784 </delete>
2785 </if>
2786 </target>
2787
2788 <target name="clear-tomcat-sessions" description="Clear the Tomcat Session info." depends="init">
2789 <exec executable="cmd" osfamily="windows" dir="${catalina.home}/work/Catalina/localhost/greenstone3" spawn="false">
2790 <arg line="/c echo. > SESSIONS.ser"/>
2791 </exec>
2792 <exec executable="rm" os="${os.unix}" dir="${catalina.home}/work/Catalina/localhost/greenstone3" spawn="false">
2793 <arg value="-f"/>
2794 <arg value="SESSIONS.ser"/>
2795 </exec>
2796
2797 </target>
2798 <!-- ======================= ant Targets ============================ -->
2799 <target name="prepare-ant" depends="init">
2800 <if>
2801 <bool>
2802 <not><available file="${packages.home}/ant/.flagfile"/></not>
2803 </bool>
2804 <property name="ant.download.version" value="apache-ant-1.9.13" />
2805 <!--
2806 <get src="${gsorg.root}/gs3files/${ant.download.version}-bin.zip"
2807 dest="${packages.home}/${ant.download.version}-bin.zip"
2808 usetimestamp="true"/>
2809 -->
2810 <exec executable="wget" failonerror="true">
2811 <arg value="-P"/>
2812 <arg value="${packages.home}"/>
2813 <arg value="--no-check-certificate"/>
2814 <arg value="${gsorg.root}/gs3files/${ant.download.version}-bin.zip"/>
2815 </exec>
2816 <unzip src="${packages.home}/${ant.download.version}-bin.zip"
2817 dest="${packages.home}"/>
2818 <move todir="${packages.home}/ant">
2819 <fileset dir="${packages.home}/${ant.download.version}"/>
2820 </move>
2821 <echo file="${packages.home}/ant/.flagfile">
2822 the timestamp of this file is the time that ant was extracted from the zip files.
2823 it is used to figure out whether the files need to be refreshed or not in `ant prepare-ant`
2824 </echo>
2825
2826 <else>
2827 <echo>Ant has been prepared, will not prepare</echo>
2828 <echo>Delete ${packages.home}/ant/.flagfile to force refresh</echo>
2829 </else>
2830
2831 </if>
2832 </target>
2833
2834 <!-- ======================= Admin Targets ============================ -->
2835
2836 <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
2837 See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
2838 But you can do: echo mypassword | ant config-admin -->
2839 <target name="config-admin" description="Reset admin password">
2840 <input addproperty="admin.password" defaultvalue="admin" message="New admin password (3-20 characters):&gt;">
2841 <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
2842 </input>
2843 <!--<echo>PWD: ${admin.password}</echo>-->
2844 <antcall target="update-userdb">
2845 <param name="user.username" value="admin"/>
2846 <param name="user.password" value="${admin.password}"/>
2847 <param name="user.groups" value=""/>
2848 <param name="user.status" value=""/>
2849 <param name="user.comment" value="Password updated."/>
2850 <param name="user.email" value=""/>
2851 </antcall>
2852 </target>
2853
2854 <target name="config-user" description="Add or modify users" depends="get-user-data,update-userdb"/>
2855
2856 <target name="get-user-data" description="Get user details">
2857 <input addproperty="user.username" message="Username:&gt;"/>
2858 <input addproperty="user.password" defaultvalue="" message="Password (3-20 characters):&gt;">
2859 <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
2860 </input>
2861 <input addproperty="user.groups" defaultvalue="" message="Groups (comma-separated list, e.g. personal-collections-editor):&gt;"/>
2862 <input addproperty="user.status" defaultvalue="true" message="Enabled (true/false):&gt;"/>
2863 <input addproperty="user.comment" defaultvalue="" message="Comment:&gt;"/>
2864 <input addproperty="user.email" defaultvalue="" message="Email:&gt;"/>
2865 </target>
2866
2867 <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
2868 See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
2869 But you can do: echo mypassword | ant config-admin -->
2870 <target name="update-userdb" description="Add or modify users" depends="start-derby">
2871
2872 <!--
2873 We're now using derby networked server, so stopping and starting tomcat is not necessary.
2874 For embedded derby: stop tomcat if running, since derby db is embedded
2875 and only allows connections from one jvm instance at a time
2876 See http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html
2877 The ${tomcat.isrunning} property is set by the depends-target "check-tomcat-running" -->
2878
2879 <!-- Need the derby networked server to be running in order to modify the usersDB.
2880 The start-derby task will check if derby is already running (if not, ${derby.isstarted} will
2881 be false) and will only start up networked derby if it is not already running.
2882 The ${derby.isstarted} property is set by the depends-target "start-derby", since it won't
2883 set the property if called with antcall (like launching in a subshell). Have to use 'depends'.
2884 We'll check ${derby.isstarted} at the end to stop derby again if we had to start it up now.-->
2885 <!--<antcall target="start-derby"/>-->
2886
2887 <!-- wait a max of 5 seconds for the derbyserver to have started up -->
2888 <waitfor maxwait="5" maxwaitunit="second">
2889 <socket server="${derby.server}" port="${derby.server.port}"/>
2890 </waitfor>
2891
2892 <!--<echo>${admin.password}</echo>--> <!-- for testing -->
2893 <echo>gsdl3.writablehome: ${gsdl3.writablehome}</echo> <!-- for testing -->
2894 <echo>web.home: ${web.home}</echo> <!-- for testing -->
2895 <java classname="org.greenstone.gsdl3.util.ModifyUsersDB">
2896 <classpath refid="compile.classpath"/> <!--for ${web.lib}/gsdl3.jar and supporting files-->
2897 <sysproperty key="gsdl3.writablehome" value="${gsdl3.writablehome}" /> <!-- passes -D<syspropKey=syspropVal> to java class ModifyUsersDB. Available in java code as System.getProperty("syspropKey") -->
2898 <arg file="${web.home}/etc/usersDB"/>
2899 <arg value="${user.username}"/>
2900 <arg value="password=${user.password}"/>
2901 <arg value="groups=${user.groups}"/>
2902 <arg value="status=${user.status}"/>
2903 <arg value="comment=${user.comment}"/>
2904 <arg value="email=${user.email}"/>
2905 </java>
2906
2907 <!-- Need to stop networked derby again if we ran it for this target with the depends=start-derby call.
2908 The test here is for <not>derby.isstarted</not>, as the property would be the same as before
2909 derby was started, since properties are immutable within a single ant command. -->
2910 <if>
2911 <bool>
2912 <not><istrue value="${derby.isstarted}"/></not>
2913 </bool>
2914 <antcall target="force-stop-derby"/>
2915 </if>
2916
2917 </target>
2918
2919
2920 <!-- ======================= Axis Targets ============================ -->
2921
2922 <target name="prepare-axis" depends="init">
2923
2924 <if>
2925 <bool>
2926 <not><available file="${packages.home}/axis/.flagfile"/></not>
2927 </bool>
2928
2929 <!--
2930 <get src="${gsorg.root}/gs3files/${axis.zip.version}"
2931 dest="${packages.home}/${axis.zip.version}"
2932 usetimestamp="true"/>
2933 -->
2934 <exec executable="wget" failonerror="true">
2935 <arg value="-P"/><!-- output dir, alt: minus-minus-directory-prefix -->
2936 <arg value="${packages.home}"/>
2937 <arg value="--no-check-certificate"/>
2938 <arg value="${gsorg.root}/gs3files/${axis.zip.version}"/>
2939 </exec>
2940 <unzip src="${packages.home}/${axis.zip.version}"
2941 dest="${packages.home}"/>
2942 <move todir="${packages.home}/axis">
2943 <fileset dir="${packages.home}/${axis.dir.version}"/>
2944 </move>
2945 <!-- install axis into greenstone web app -->
2946 <copy todir="${web.lib}">
2947 <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/lib">
2948 <include name="*.jar"/>
2949 </fileset>
2950 </copy>
2951 <copy todir="${web.home}">
2952 <fileset dir="${packages.home}/axis/webapps/axis/">
2953 <include name="*.jsp"/>
2954 <include name="*.jws"/>
2955 </fileset>
2956 </copy>
2957 <copy tofile="${web.home}/axis.html" file="${packages.home}/axis/webapps/axis/index.html"/>
2958 <copy todir="${web.classes}">
2959 <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/classes">
2960 <include name="*.properties"/>
2961 </fileset>
2962 </copy>
2963 <echo file="${packages.home}/axis/.flagfile">
2964 the timestamp of this file is the time that axis was extracted from the zip files.
2965 it is used to figure out whether the files need to be refreshed or not in `ant prepare-axis`
2966 </echo>
2967
2968 <else>
2969 <echo>Axis has been prepared, will not prepare</echo>
2970 <echo>Delete ${packages.home}/axis/.flagfile to force refresh</echo>
2971 </else>
2972
2973 </if>
2974 </target>
2975
2976 <target name="soap-deploy-site" depends="init,get-sitename,get-siteuri,get-webservices,create-deployment-files,deploy-site"
2977 description="Deploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work."/>
2978
2979 <target name="deploy-site">
2980 <java classname="org.apache.axis.client.AdminClient">
2981 <classpath refid="compile.classpath"/>
2982 <arg value="-l"/>
2983 <arg value="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/servlet/AxisServlet"/>
2984 <arg file="${basedir}/resources/soap/deploy.wsdd"/>
2985 </java>
2986 <delete file="${basedir}/resources/soap/deploy.wsdd"/> <!--clean up, no longer used-->
2987 </target>
2988
2989 <target name="soap-undeploy-site" depends="get-undeploy-service-name"
2990 description="Undeploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work.">
2991 <filter token="servicesname" value="${axis.undeploy.servicename}"/>
2992 <copy file="${basedir}/resources/soap/undeploy-site.wsdd.template"
2993 tofile="${basedir}/resources/soap/undeploy.wsdd"
2994 filtering="true"
2995 overwrite="true"/>
2996 <java classname="org.apache.axis.client.AdminClient">
2997 <classpath refid="compile.classpath"/>
2998 <arg value="-l"/>
2999 <arg value="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/servlet/AxisServlet"/>
3000 <arg file="${basedir}/resources/soap/undeploy.wsdd"/>
3001 </java>
3002 <delete file="${basedir}/resources/soap/undeploy.wsdd"/> <!--clean up, no longer used-->
3003 </target>
3004
3005 <!-- this target used to deploy the default web service SOAPServer (base.webservice.name) on the localsite server
3006 with the default servicename of localsite-->
3007 <target name="deploy-localsite" depends="init"
3008 description="Deploy the SOAP server for localsite. Will start and stop Tomcat.">
3009 <antcall target="force-start-tomcat"/>
3010 <echo>Deploying ${base.webservice.name} web services for localsite under service name: localsite</echo>
3011 <antcall target="create-deployment-files">
3012 <param name="axis.sitename" value="localsite"/>
3013 <param name="axis.servicesname" value="${base.webservice.name}"/>
3014 <param name="axis.siteuri" value="localsite"/>
3015 </antcall>
3016 <antcall target="deploy-site">
3017 <param name="axis.sitename" value="localsite"/>
3018 <param name="axis.servicesname" value="${base.webservice.name}"/>
3019 <param name="axis.siteuri" value="localsite"/>
3020 </antcall>
3021 <echo>The Greenstone server has been started up. If you do not want it running, please type: ant stop.</echo>
3022 </target>
3023
3024 <target name="get-sitename" unless="axis.sitename">
3025 <input addproperty="axis.sitename" defaultvalue="localsite">What site do you want to deploy services for?
3026Press Enter for default:localsite</input>
3027 </target>
3028
3029 <target name="get-undeploy-service-name" unless="axis.undeploy.servicename">
3030 <input addproperty="axis.undeploy.servicename" defaultvalue="localsite">Please enter the full name of the service you wish to undeploy.
3031To find out which web services you've got deployed, point your browser to ${default.server.protocol}://${tomcat.server}:${default.tomcat.port}/greenstone3/services
3032Or press Enter for undeploying the default:localsite /&gt;</input>
3033 <echo>Name of service to undeploy: ${axis.undeploy.servicename}</echo>
3034 </target>
3035
3036 <target name="get-webservices" unless="axis.servicesname">
3037 <input addproperty="axis.servicesname" defaultvalue="${base.webservice.name}">Which set of web services do you want to deploy?
3038Choose from: ${web.services.list}
3039Or press Enter for default:${base.webservice.name} /&gt;</input>
3040 <echo>${axis.servicesname}</echo>
3041 </target>
3042
3043 <target name="get-siteuri" depends="get-sitename,get-webservices" unless="axis.siteuri">
3044 <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>
3045 <echo>Site: ${axis.sitename}, services: ${axis.servicesname}, servicesname: ${axis.siteuri}</echo>
3046 </target>
3047
3048 <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">
3049 <condition property="soap.method" value="provider='java:MSG' style='message' use='literal'">
3050 <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
3051 </condition>
3052
3053 <!--everything else defaults to java:RPC at present-->
3054 <condition property="soap.method" value="provider='java:RPC'">
3055 <not>
3056 <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
3057 </not>
3058 </condition>
3059 </target>
3060
3061 <target name="create-deployment-files" depends="set-soapmethod" if="axis.sitename">
3062 <filter token="sitename" value="${axis.sitename}"/>
3063 <filter token="siteuri" value="${axis.siteuri}"/>
3064 <filter token="servicesname" value="${axis.servicesname}"/>
3065 <filter token="soapmethod" value="${soap.method}"/>
3066 <copy file="${basedir}/resources/soap/site.wsdd.template"
3067 tofile="${basedir}/resources/soap/deploy.wsdd"
3068 filtering="true"
3069 overwrite="true"/>
3070 <!-- create the java files and compile them -->
3071 <copy file="${basedir}/resources/java/${axis.servicesname}.java.in"
3072 tofile="${src.gsdl3.home}/${axis.servicesname}${axis.sitename}.java"
3073 filtering="true"
3074 overwrite="true"/>
3075 <mkdir dir="${build.home}"/>
3076 <javac srcdir="${src.home}"
3077 destdir="${build.home}"
3078 includeantruntime="${compile.includeantruntime}"
3079 debug="${compile.debug}"
3080 deprecation="${compile.deprecation}"
3081 optimize="${compile.optimize}"
3082 encoding="${compile.encoding}">
3083 <classpath refid="compile.classpath"/>
3084 <include name="org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.java" />
3085 </javac>
3086 <mkdir dir="${web.classes}/org/greenstone/gsdl3"/>
3087 <copy file="${build.home}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
3088 tofile="${web.classes}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
3089 overwrite="true" />
3090 </target>
3091
3092
3093 <!-- ====================== Core targets ============================== -->
3094 <!-- core targets refer to the core gsdl3 java src -->
3095
3096 <target name="prepare-core"/>
3097
3098 <target name="configure-core"/>
3099
3100 <target name="update-core" depends="init,svnupdate-core,clean-core,compile-core"
3101 description="Update only the Greenstone core" />
3102
3103 <target name="svnupdate-core" unless="nosvn.mode">
3104 <exec executable="svn">
3105 <arg value="update"/>
3106 <arg value="${basedir}"/>
3107 <arg value="-r"/><arg value="${branch.revision}"/>
3108 </exec>
3109 </target>
3110
3111 <target name="clean-core"
3112 description="Clean only the Greenstone core">
3113 <!-- should this delete the gsdl3.jar from web/WEB-INF?? -->
3114 <delete dir="${build.home}"/>
3115 </target>
3116
3117 <target name="compile-core" depends="init"
3118 description="Compile only the Greenstone core">
3119 <mkdir dir="${build.home}"/>
3120
3121 <if><bool><isset property="with.jni"/></bool>
3122 <javac srcdir="${src.home}"
3123 destdir="${build.home}"
3124 includeantruntime="${compile.includeantruntime}"
3125 debug="${compile.debug}"
3126 deprecation="${compile.deprecation}"
3127 optimize="${compile.optimize}"
3128 encoding="${compile.encoding}">
3129 <classpath>
3130 <path refid="compile.classpath"/>
3131 </classpath>
3132 </javac>
3133 <else>
3134 <property name="gsprefix" value=""/>
3135 <javac srcdir="${src.home}"
3136 destdir="${build.home}"
3137 includeantruntime="${compile.includeantruntime}"
3138 debug="${compile.debug}"
3139 deprecation="${compile.deprecation}"
3140 optimize="${compile.optimize}"
3141 encoding="${compile.encoding}">
3142 <classpath>
3143 <path refid="compile.classpath"/>
3144 </classpath>
3145 <exclude name="org/greenstone/gsdl3/service/GS2MGPPRetrieve.java"/>
3146 <exclude name="org/greenstone/gsdl3/service/GS2MGPPSearch.java"/>
3147 <exclude name="org/greenstone/gsdl3/service/GS2MGSearch.java"/>
3148 <exclude name="org/greenstone/gsdl3/service/GS2MGRetrieve.java"/>
3149 <exclude name="org/greenstone/gsdl3/service/GoogleNgramMGPPSearch.java"/>
3150 <exclude name="org/greenstone/gsdl3/service/PhindPhraseBrowse.java"/>
3151 <exclude name="org/greenstone/gsdl3/util/GDBMWrapper.java"/>
3152 </javac>
3153 </else>
3154 </if>
3155 <jar destfile="${build.home}/gsdl3.jar">
3156 <fileset dir="${build.home}">
3157 <include name="org/greenstone/gsdl3/**"/>
3158 <include name="org/flax/**"/>
3159 <exclude name="**/Test.class"/>
3160 </fileset>
3161 <manifest>
3162 <attribute name="Built-By" value="${user.name}" />
3163 </manifest>
3164 </jar>
3165 <copy file="${build.home}/gsdl3.jar" todir="${web.lib}"/>
3166
3167 <jar destfile="${build.home}/gutil.jar">
3168 <fileset dir="${build.home}">
3169 <include name="org/greenstone/util/**"/>
3170 </fileset>
3171 <manifest>
3172 <attribute name="Built-By" value="${user.name}" />
3173 </manifest>
3174 </jar>
3175 <copy file="${build.home}/gutil.jar" todir="${web.lib}"/>
3176
3177 <!-- copy the localsite server in case we need it -->
3178 <copy file="${build.home}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" tofile="${web.classes}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" />
3179
3180 <!-- Greenstone Administrator Interface -->
3181 <jar destfile="${build.home}/GAI.jar">
3182 <fileset dir="${build.home}">
3183 <include name="org/greenstone/admin/**"/>
3184 </fileset>
3185 <manifest>
3186 <attribute name="Built-By" value="${user.name}" />
3187 </manifest>
3188 </jar>
3189 <copy file="${build.home}/GAI.jar" todir="${web.lib}"/>
3190 <copy file="${build.home}/GAI.jar" todir="${admin.dir}"/>
3191 <jar destfile="${build.home}/phind.jar">
3192 <fileset dir="${build.home}">
3193 <include name="org/greenstone/applet/phind/**"/>
3194 </fileset>
3195 <manifest>
3196 <attribute name="Built-By" value="${user.name}" />
3197 </manifest>
3198 </jar>
3199 <mkdir dir="${web.applet}"/>
3200 <copy file="${build.home}/phind.jar" todir="${web.applet}"/>
3201 <!-- phind also needs xercesImpl.jar and xml-apis.jar to be in web/applet -->
3202 <if>
3203 <bool><istrue value="${tomcat.islocal}"/></bool>
3204 <if><bool><available file="${catalina.home}/lib/xercesImpl.jar"/></bool><!-- moved for solr -->
3205 <copy file="${catalina.home}/lib/xercesImpl.jar" todir="${web.applet}"/>
3206 <copy file="${catalina.home}/lib/xml-apis.jar" todir="${web.applet}"/>
3207
3208 <else><!-- get from default GS3 web lib location-->
3209 <copy file="${web.lib}/xercesImpl.jar" todir="${web.applet}"/>
3210 <copy file="${web.lib}/xml-apis.jar" todir="${web.applet}"/>
3211 </else>
3212 </if>
3213 </if>
3214
3215
3216 <!-- skip anttasks for now
3217 <jar destfile="${build.home}/anttasks.jar">
3218 <fileset dir="${build.home}">
3219 <include name="org/greenstone/anttasks/**"/>
3220 </fileset>
3221 <manifest>
3222 <attribute name="Built-By" value="${user.name}" />
3223 </manifest>
3224 </jar>
3225 <copy file="${build.home}/anttasks.jar" todir="${basedir}/lib/java"/>-->
3226 <jar destfile="${build.home}/gsdl3test.jar">
3227 <fileset dir="${build.home}">
3228 <include name="org/greenstone/gsdl3/**/*Test.class"/>
3229 <include name="org/greenstone/testing/**"/>
3230 </fileset>
3231 <manifest>
3232 <attribute name="Built-By" value="${user.name}" />
3233 </manifest>
3234 </jar>
3235 <jar destfile="${build.home}/server.jar">
3236 <fileset dir="${build.home}">
3237 <include name="org/greenstone/server/**"/>
3238 <include name="org/greenstone/util/**"/>
3239 </fileset>
3240 <fileset file="${basedir}/resources/java/server.properties"/>
3241 <manifest>
3242 <attribute name="Built-By" value="${user.name}"/>
3243 </manifest>
3244 </jar>
3245 <copy file="${build.home}/server.jar" todir="${basedir}"/>
3246 </target>
3247
3248 <!-- === Eclipse targets == -->
3249 <target name="setup-for-eclipse">
3250
3251 <filter token="gsdlhome" value="${gs2build.home}"/>
3252 <filter token="gsdl3srchome" value="${basedir}"/>
3253 <filter token="gsdl3home" value="${basedir}/web"/>
3254
3255 <if>
3256 <bool><not><available file="${basedir}/TransformingLibrary.launch"/></not></bool>
3257 <copy file="${basedir}/TransformingLibrary.launch.in" tofile="${basedir}/TransformingLibrary.launch" filtering="true" overwrite="true"/>
3258 </if>
3259<!--
3260 <if>
3261 <bool><not><available file="${basedir}/LibraryCommandline.launch"/></not></bool>
3262 <copy file="${basedir}/LibraryCommandline.launch.in" tofile="${basedir}/LibraryCommandline.launch" filtering="true" overwrite="true"/>
3263 </if>
3264-->
3265 </target>
3266
3267 <!-- ================== Packages targets ================================ -->
3268 <!-- these targets refer to the greenstone source packages - these need
3269 updating less often, so are in separate targets to the core -->
3270 <target name="prepare-packages" depends="init"/>
3271
3272 <target name="update-packages" depends="init,svnupdate-packages,configure-packages,clean-packages,compile-packages"
3273 description="Update only the source packages"/>
3274
3275 <target name="svnupdate-packages" unless="nosvn.mode">
3276 <exec executable="svn">
3277 <arg value="update"/>
3278 <arg value="${src.packages.home}"/>
3279 <arg value="-r"/><arg value="${branch.revision}"/>
3280 </exec>
3281 </target>
3282
3283 <target name="prepare-binaries" depends="prepare-bins-unix"/>
3284
3285 <target name="prepare-bins-unix" depends="init" if="current.os.isunix">
3286 <condition property="bitness.suffix" value="64" else="32">
3287 <matches string="${os.arch}" pattern="64"/>
3288 </condition>
3289 <condition property="os.folder.name" value="mac" else="linux"> <!-- checkout from dir: mac or linux -->
3290 <equals arg1="${os.bin.dir}" arg2="darwin" trim="true"/>
3291 </condition>
3292 <mkdir dir="${gs2build.home}/bin/${os.bin.dir}"/> <!-- mkdir darwin or linux -->
3293 <exec executable="svn" dir="${gs2build.home}/bin/${os.bin.dir}">
3294 <arg value="export"/>
3295 <arg value="-r"/><arg value="${branch.revision}"/>
3296 <arg value="${svn.root}/main/${branch.path}/binaries/${os.folder.name}/yaz/yaz-client-x${bitness.suffix}"/> <!-- checkout from dir: mac or linux -->
3297 <arg value="yaz-client"/>
3298 </exec>
3299 </target>
3300
3301 <target name="configure-packages" depends="init,configure-javagdbm"
3302 description="Configure only the packages."/>
3303
3304 <target name="configure-javagdbm" if="with.jni">
3305 <echo>
3306 Configuring JavaGDBM
3307 </echo>
3308
3309 <exec executable="${javagdbm.home}/configure" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
3310 <arg value="--prefix=${basedir}"/>
3311 <arg value="--libdir=${lib.jni}"/>
3312 <arg value="--with-gdbm=${gdbm.home}"/>
3313 <arg line="${cross.configure.args}"/>
3314 </exec>
3315 </target>
3316
3317 <target name="clean-packages" depends="init,clean-javagdbm" description="Clean only the packages"/>
3318
3319 <target name="clean-javagdbm" depends="init">
3320 <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
3321 <exec executable="make" os="${os.unix}"
3322 dir="${javagdbm.home}" failonerror="true">
3323 <arg value="clean"/>
3324 </exec>
3325 </if>
3326 </target>
3327
3328 <target name="distclean-packages" depends="init,distclean-javagdbm" description="Distclean only the packages"/>
3329
3330 <target name="distclean-javagdbm" depends="init">
3331 <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
3332 <exec executable="make" os="${os.unix}"
3333 dir="${javagdbm.home}" failonerror="true">
3334 <arg value="distclean"/>
3335 </exec>
3336 </if>
3337 </target>
3338
3339 <target name="compile-packages" description="Compile only the source packages">
3340 <!-- javagdbm -->
3341 <antcall target="compile-javagdbm"/>
3342 <!-- Search4j -->
3343 <antcall target="compile-search4j"/>
3344 </target>
3345
3346 <target name="compile-javagdbm" description="Compile JavaGDBM" if="with.jni">
3347
3348 <!-- unix: -->
3349 <echo>compile javagdbm</echo>
3350 <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
3351 <arg value="JAVACOPTIONS=-encoding UTF8"/>
3352 </exec>
3353 <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
3354 <arg value="install"/>
3355 </exec>
3356
3357 <!-- windows: Calling without the "compile" argument first will run winMake.bat with
3358 "all" which will then perform both the compile AND link targets in jni/win32.mak
3359 (thereby also generating gdbmjava.dll). Then we run the same command with
3360 the "install" argument to copy the gdbmjava.dll into the correct location. -->
3361 <echo>Windows: compile javagdbm</echo>
3362 <exec executable="${javagdbm.home}/winMake.bat" osfamily="windows" dir="${javagdbm.home}" failonerror="true">
3363 <env key="GSDL3SRCHOME" path="${basedir}"/>
3364 </exec>
3365 <exec executable="${javagdbm.home}/winMake.bat" osfamily="windows" dir="${javagdbm.home}" failonerror="true">
3366 <env key="GSDL3SRCHOME" path="${basedir}"/>
3367 <arg value="install"/>
3368 </exec>
3369
3370 <!-- install the jar file -->
3371 <echo>Install the javagdbm jar file ${javagdbm.home}/javagdbm.jar ${lib.jni}</echo>
3372 <copy file="${javagdbm.home}/javagdbm.jar" todir="${lib.jni}"/>
3373 </target>
3374
3375 <target name="compile-search4j">
3376
3377 <!-- windows -->
3378 <if><bool><istrue value="${current.os.iswindows}"/></bool>
3379 <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
3380 <arg value="/f"/>
3381 <arg value="win32.mak"/>
3382 <arg value='BINDIR="${basedir}\bin"'/>
3383 </exec>
3384 <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
3385 <arg value="/f"/>
3386 <arg value="win32.mak"/>
3387 <arg value="install"/>
3388 <arg value='BINDIR="${basedir}\bin"'/>
3389 </exec>
3390
3391 <!-- unix -->
3392 <else><if><bool><istrue value="${current.os.isunix}"/></bool>
3393 <exec executable="${src.packages.home}/search4j/configure" dir="${src.packages.home}/search4j" failonerror="true">
3394 <arg value="--bindir=${basedir}/bin"/>
3395 <arg value="${static.arg}"/>
3396 <arg line="${cross.configure.args}"/>
3397 </exec>
3398 <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true"/>
3399 <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true">
3400 <arg value="install"/>
3401 </exec>
3402
3403 <!-- else warn -->
3404 <else>
3405 <fail>this target does not support the current os</fail>
3406
3407 </else></if></else></if>
3408
3409 </target>
3410
3411 <target name="install-auxiliary-jar-files" depends="init">
3412
3413 <if>
3414 <bool><available file="${mg.home}/mg.jar"/></bool>
3415 <copy file="${mg.home}/mg.jar" todir="${lib.jni}"/>
3416 </if>
3417
3418 <if>
3419 <bool><available file="${mgpp.home}/mgpp.jar"/></bool>
3420 <copy file="${mgpp.home}/mgpp.jar" todir="${lib.jni}"/>
3421 </if>
3422
3423 <copy file="${lucene.home}/LuceneWrapper4.jar" todir="${web.lib}"/>
3424 </target>
3425
3426 <target name="install-jni-files" depends="init" if="with.jni">
3427 <antcall target="install-jni-files-linux"/>
3428 <antcall target="install-jni-files-windows"/>
3429 <antcall target="install-jni-files-macos"/>
3430 </target>
3431
3432 <target name="install-jni-files-linux" depends="init" if="current.os.isunixnotmac">
3433
3434 <if>
3435
3436 <bool><equals arg1="${os.bin.dir}" arg2="windows"/></bool>
3437 <!-- cross compiling to windows -->
3438 <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
3439 <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
3440 <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
3441 <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
3442 <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
3443 <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
3444
3445 <else>
3446 <!-- otherwise do the usual Unix copies -->
3447 <copy file="${mg.home}/jni/libmgretrievejni.so" todir="${lib.jni}"/>
3448 <copy file="${mg.home}/jni/libmgsearchjni.so" todir="${lib.jni}"/>
3449 <copy file="${mg.home}/jni/libmgpassjni.so" todir="${lib.jni}"/>
3450 <copy file="${mgpp.home}/jni/libmgppretrievejni.so" todir="${lib.jni}"/>
3451 <copy file="${mgpp.home}/jni/libmgppsearchjni.so" todir="${lib.jni}"/>
3452 <copy file="${mgpp.home}/jni/libmgpppassjni.so" todir="${lib.jni}"/>
3453 </else>
3454 </if>
3455
3456
3457 </target>
3458 <target name="install-jni-files-windows" depends="init" if="current.os.iswindows">
3459 <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
3460 <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
3461 <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
3462 <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
3463 <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
3464 <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
3465 </target>
3466 <target name="install-jni-files-macos" depends="init" if="current.os.ismac">
3467 <copy file="${mg.home}/jni/libmgretrievejni.jnilib" todir="${lib.jni}"/>
3468 <copy file="${mg.home}/jni/libmgsearchjni.jnilib" todir="${lib.jni}"/>
3469 <copy file="${mg.home}/jni/libmgpassjni.jnilib" todir="${lib.jni}"/>
3470 <copy file="${mgpp.home}/jni/libmgppretrievejni.jnilib" todir="${lib.jni}"/>
3471 <copy file="${mgpp.home}/jni/libmgppsearchjni.jnilib" todir="${lib.jni}"/>
3472 <copy file="${mgpp.home}/jni/libmgpppassjni.jnilib" todir="${lib.jni}"/>
3473 </target>
3474
3475 <!-- ========common-src targets =================================-->
3476 <!-- these are used to get common-src (for indexers, gdbm, sqlite etc) when
3477 collection building is not enabled -->
3478
3479 <target name="update-common-src" depends="init" if="collection.building.disabled">
3480 </target>
3481
3482 <target name="svnupdate-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
3483 <exec executable="svn">
3484 <arg value="update"/>
3485 <arg value="${common.src.home}"/>
3486 <arg value="-r"/><arg value="${branch.revision}"/>
3487 </exec>
3488 </target>
3489
3490 <target name="prepare-common-src" depends="init" if="collection.building.disabled" unless="common.src.present">
3491 <antcall target="checkout-common-src"/>
3492 <antcall target="unzip-windows-packages"/>
3493 </target>
3494
3495 <target name="checkout-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
3496 <echo>checking out common-src</echo>
3497 <exec executable="svn">
3498 <arg value="checkout"/>
3499 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src"/>
3500 <arg value="common-src"/>
3501 <arg value="-r"/><arg value="${branch.revision}"/>
3502 </exec>
3503 </target>
3504
3505 <target name="configure-common-src" depends="init">
3506<!--
3507 <echo>cross configure args: ${cross.configure.args}</echo>
3508-->
3509 <exec executable="${common.src.home}/configure" os="${os.unix}"
3510 dir="${common.src.home}" failonerror="true">
3511 <arg value="--prefix=${gs2build.home}"/> <!-- what value to use?? -->
3512 <arg value="--bindir=${gs2build.home}/bin/${os.bin.dir}"/> <!-- what value to use?? -->
3513 <arg line="${gs2.opt.args}"/>
3514 <arg line="${static.arg}"/>
3515 <arg line="${cross.configure.args}"/>
3516 <arg line="${allargs}"/>
3517 </exec>
3518 </target>
3519
3520 <target name="clean-common-src" depends="init">
3521 <!-- unix: -->
3522 <if><bool><available file="${common.src.home}/Makefile"/></bool>
3523 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
3524 <arg value="clean"/>
3525 </exec>
3526 </if>
3527 <!-- windows: -->
3528 <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
3529 <arg value="/f"/>
3530 <arg value="win32.mak"/>
3531 <arg value="clean"/>
3532 <arg value="GSDLHOME=${gs2build.home}"/>
3533 </exec>
3534 </target>
3535 <target name="distclean-common-src" depends="init">
3536 <!-- unix: -->
3537 <if><bool><available file="${common.src.home}/Makefile"/></bool>
3538 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
3539 <arg value="distclean"/>
3540 </exec>
3541 </if>
3542 <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->
3543 <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
3544 <arg value="/f"/>
3545 <arg value="win32.mak"/>
3546 <arg value="clean"/>
3547 <arg value="GSDLHOME=${gs2build.home}"/>
3548 </exec>
3549 </target>
3550 <target name="compile-common-src" depends="init">
3551 <!-- unix: -->
3552 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
3553 <arg value="${gs2.compile.target}"/>
3554 </exec>
3555 <!-- windows: -->
3556 <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
3557 <arg value="/f"/>
3558 <arg value="win32.mak"/>
3559 <arg value="GSDLHOME=${gs2build.home}"/>
3560 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
3561 <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
3562 <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
3563 <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
3564 <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
3565 </exec>
3566 </target>
3567
3568 <!-- ======= collection-building targets ===========================-->
3569
3570 <target name="update-collection-building" if="collection.building.enabled"
3571 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"
3572 description="Update (SVN update, configure, compile etc) only the collection building components"/>
3573
3574 <target name="svnupdate-collection-building" if="collection.building.enabled" depends="init,svnupdate-gs2build,svnupdate-cgi,svnupdate-gli" unless="nosvn.mode"
3575 description="SVN update the collection building components">
3576 </target>
3577
3578 <target name="prepare-collection-building" depends="init,prepare-gs2build,svnupdate-cgi,prepare-gli" if="collection.building.enabled">
3579 </target>
3580
3581 <target name="configure-collection-building" depends="init,configure-build-src" if="collection.building.enabled"
3582 description="Configure the collection building components">
3583 </target>
3584
3585 <target name="clean-collection-building" depends="init,clean-gli,clean-build-src"
3586 description="Clean only the collection building components"
3587 if="collection.building.enabled"/>
3588
3589 <target name="distclean-collection-building" depends="init,clean-build-src,distclean-build-src"
3590 description="Distclean only the collection building components"
3591 if="collection.building.enabled"/>
3592
3593 <target name="compile-collection-building" depends="init,compile-build-src,compile-gli" if="collection.building.enabled"
3594 description="Compile only the collection building components">
3595 <!-- make install for common-src -->
3596 <!-- unix: -->
3597 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
3598 <arg value="${gs2.install.target}"/>
3599 </exec>
3600
3601 <!-- windows: -->
3602 <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
3603 <arg value="/f"/>
3604 <arg value="win32.mak"/>
3605 <arg value="install"/>
3606 <arg value="GSDLHOME=${gs2build.home}"/>
3607 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
3608 <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
3609 <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
3610 <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
3611 <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
3612 <!--
3613 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
3614 <arg value="USE_SQLITE=0"/>--> <!-- why is this not on by default? -->
3615 </exec>
3616
3617 <!-- install gs2build indexers for windows -->
3618 <if>
3619 <bool><istrue value="${current.os.iswindows}"/></bool>
3620 <copy todir="${gs2build.home}/bin/windows">
3621 <fileset dir="${gs2build.home}/common-src/indexers/bin">
3622 <include name="*.*"/>
3623 </fileset>
3624 </copy>
3625 </if>
3626
3627 <!-- LuceneWrapper jar file not installed by default -->
3628 <mkdir dir="${gs2build.home}/bin/java"/>
3629 <copy file="${lucene.home}/LuceneWrapper4.jar" todir="${gs2build.home}/bin/java"/>
3630
3631 </target>
3632
3633 <!-- ============== gli targets ================================= -->
3634
3635 <!-- gliserver.pl, gsdlCGI.pm, metadata-server.pl and checksum.pl are updated alongside
3636 this in target svnupdate-collection-building -->
3637 <target name="svnupdate-gli" if="collection.building.enabled" depends="init" unless="nosvn.mode">
3638
3639 <exec executable="svn">
3640 <arg value="update"/>
3641 <arg value="${gli.home}"/>
3642 <arg value="-r"/><arg value="${branch.revision}"/>
3643 </exec>
3644
3645 </target>
3646
3647 <!-- gliserver.pl, gsdlCGI.pm, metadata-server.pl and checksum.pl are updated
3648 alongside this prepare-gli target in target prepare-collection-building -->
3649 <target name="prepare-gli" depends="init" if="collection.building.enabled" unless="gli.present">
3650 <!-- checkout -->
3651 <if><bool><and><not><istrue value="${nosvn.mode}"/></not><isset property="with.gli.and.gems"/></and></bool>
3652
3653 <exec executable="svn">
3654 <arg value="checkout"/>
3655 <arg value="${svn.root}/main/${branch.path}/gli"/>
3656 <arg value="-r"/><arg value="${branch.revision}"/>
3657 </exec>
3658
3659 </if>
3660 </target>
3661
3662 <!-- svn checkout gliserver.pl, gsdlCGI.pm for gli applet, as well as gsdlCGI.pm-dependent metadata-server.pl
3663 (checksum.pl is used by GS2 for depositdspace.dm and may eventually be used by GS3 too) -->
3664 <target name="svnupdate-cgi">
3665
3666 <exec executable="svn" dir="web/WEB-INF/cgi">
3667 <arg value="export"/>
3668 <arg value="-r"/><arg value="${branch.revision}"/>
3669 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/gliserver.pl"/>
3670 </exec>
3671 <exec executable="svn" dir="web/WEB-INF/cgi">
3672 <arg value="export"/>
3673 <arg value="-r"/><arg value="${branch.revision}"/>
3674 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/gsdlCGI.pm"/>
3675 </exec>
3676 <exec executable="svn" dir="web/WEB-INF/cgi">
3677 <arg value="export"/>
3678 <arg value="-r"/><arg value="${branch.revision}"/>
3679 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/metadata-server.pl"/>
3680 </exec>
3681 <exec executable="svn" dir="web/WEB-INF/cgi">
3682 <arg value="export"/>
3683 <arg value="-r"/><arg value="${branch.revision}"/>
3684 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/checksum.pl"/>
3685 </exec>
3686 </target>
3687
3688
3689 <target name="clean-gli" depends="init" if="collection.building.enabled">
3690 <!-- gli -->
3691 <property name="gli.home" value="${basedir}/gli"/>
3692 <!-- linux -->
3693 <exec executable="clean.sh" os="${os.unix}" dir="${gli.home}"
3694 resolveExecutable="true" failonerror="true"/>
3695 <!-- windows -->
3696 <exec executable="clean.bat" osfamily="windows" dir="${gli.home}"
3697 resolveExecutable="true" failonerror="true"/>
3698 </target>
3699
3700 <target name="compile-gli" depends="init" if="collection.building.enabled">
3701 <if><bool><isset property="with.gli.and.gems"/></bool>
3702 <!-- gli -->
3703 <property name="gli.home" value="${basedir}/gli"/>
3704
3705 <!-- linux -->
3706 <exec executable="makegli.sh" os="${os.unix}" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
3707 <!--remote gli-->
3708 <exec executable="makejar.sh" os="${os.unix}" dir="${gli.home}"
3709 resolveExecutable="true" failonerror="true"/>
3710 <!-- windows -->
3711 <exec executable="makegli.bat" osfamily="windows" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
3712 <!--remote gli-->
3713 <exec executable="makejar.bat" osfamily="windows" dir="${gli.home}"
3714 resolveExecutable="true" failonerror="true"/>
3715 <copy file="${gli.home}/GLIServer.jar" todir="${gs2build.home}/bin/java" />
3716 </if>
3717 </target>
3718
3719 <target name="gli" description="Run the Greenstone Librarian Interface" depends="init" if="collection.building.enabled">
3720 <exec executable="${basedir}/gli/gli.sh" os="${os.linux},${os.solaris}" dir="${basedir}/gli" spawn="true">
3721 <env key="gsdl3path" path="${basedir}"/>
3722 <env key="gsdlpath" path="${gs2build.home}"/>
3723 </exec>
3724 <exec executable="${basedir}/gli/gli.sh" os="${os.mac}" dir="${basedir}/gli" spawn="true">
3725 <env key="gsdl3path" path="${basedir}"/>
3726 <env key="gsdlpath" path="${gs2build.home}"/>
3727 <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${gdbm.home}/lib"/>
3728 </exec>
3729 <exec executable="${basedir}/gli/gli.bat" osfamily="windows" dir="${basedir}/gli" spawn="true">
3730 <env key="GSDL3PATH" path="${basedir}"/>
3731 <env key="GSDLPATH" path="${gs2build.home}"/>
3732 </exec>
3733 <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.
3734 </echo>
3735 </target>
3736
3737 <!-- ================ gs2build targets =========================== -->
3738
3739 <target name="svnupdate-gs2build" if="collection.building.enabled" depends="init" unless="nosvn.mode">
3740 <echo>svn updating gs2build</echo>
3741 <exec executable="svn">
3742 <arg value="update"/>
3743 <arg value="${gs2build.home}"/>
3744 <arg value="-r"/><arg value="${branch.revision}"/>
3745 </exec>
3746 </target>
3747
3748 <target name="prepare-gs2build" depends="init" if="collection.building.enabled" unless="gs2build.present">
3749 <antcall target="checkout-gs2build"/>
3750 <antcall target="prepare-pdfbox"/>
3751 <antcall target="prepare-imagemagick"/> <!-- has to be done before calling prepare-gnome-lib -->
3752 <antcall target="prepare-gnome-lib"/>
3753 <antcall target="unzip-windows-packages"/>
3754 <antcall target="checkout-winbin"/>
3755 <antcall target="get-windows-binaries"/>
3756 <antcall target="delete-winbin"/>
3757 </target>
3758
3759 <target name="checkout-gs2build" depends="init" if="collection.building.enabled" unless="nosvn.mode">
3760 <echo>checking out gs2build</echo>
3761 <exec executable="svn">
3762 <arg value="checkout"/>
3763 <arg value="${svn.root}/main/${branch.path}/gs2build"/>
3764 <arg value="-r"/><arg value="${branch.revision}"/>
3765 </exec>
3766 </target>
3767
3768 <!-- Gets the PDFBox extension into gs2build/ext if checkout.pdfbox.ext is set to true in build.properties
3769 (which it is by default) -->
3770 <target name="prepare-pdfbox" depends="init" if="collection.building.enabled">
3771 <if>
3772 <bool>
3773 <istrue value="${checkout.pdfbox.ext}"/>
3774 </bool>
3775
3776 <property name="pdfbox.ext.dir" value="${gs2build.home}/ext/pdf-box"/>
3777 <condition property="pdfbox.ext.present">
3778 <available file="${pdfbox.ext.dir}" type="dir" />
3779 </condition>
3780
3781 <!-- 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-->
3782 <if>
3783 <bool>
3784 <not><istrue value="${pdfbox.ext.present}"/></not>
3785 </bool>
3786
3787 <if>
3788 <bool>
3789 <not><istrue value="${gs2build.home}/ext/pdf-box-java.tar.gz"/></not>
3790 </bool>
3791
3792 <echo>Checking out the PDFBox extension into the GSDLHOME extension area</echo>
3793 <exec executable="svn">
3794 <arg value="export"/>
3795 <arg value="${svn.root}/gs2-extensions/pdf-box/trunk/pdf-box-java.tar.gz"/>
3796 <arg value="${gs2build.home}/ext/pdf-box-java.tar.gz"/>
3797 </exec>
3798 </if>
3799
3800 <echo>Extacting the PDFBox extension into the GSDLHOME extension area</echo>
3801 <untar compression="gzip"
3802 src="${gs2build.home}/ext/pdf-box-java.tar.gz"
3803 dest="${gs2build.home}/ext"/>
3804
3805 <delete file="${gs2build.home}/ext/pdf-box-java.tar.gz"/>
3806
3807 <else>
3808 <echo>The PDFBox extension already exists at ${pdfbox.ext.dir}</echo>
3809 </else>
3810 </if>
3811
3812 <else>
3813 <echo>**** Not preparing the PDFBox extension:</echo>
3814 <echo>The property checkout.pdfbox.ext in build.properties was not set or was set to false</echo>
3815 </else>
3816 </if>
3817 </target>
3818
3819 <target name="prepare-imagemagick" depends="init" if="collection.building.enabled">
3820 <if>
3821 <bool>
3822 <istrue value="${checkout.imagemagick.ext}"/>
3823 </bool>
3824
3825 <antcall target="checkout-imagemagick"/>
3826 <!--Compilation of imagemagick now happens during ant install, still before configuring the src code, as before -->
3827
3828 <else>
3829 <echo>**** Not preparing imagemagick:</echo>
3830 <echo>property checkout.imagemagick.ext in build.properties was not set or was set to false</echo>
3831 </else>
3832 </if>
3833 </target>
3834
3835 <target name="checkout-imagemagick" depends="init" if="collection.building.enabled" unless="nosvn.mode">
3836
3837 <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
3838 <condition property="imagemagick.src.present">
3839 <available file="${imagemagick.src.dir}" type="dir" />
3840 </condition>
3841
3842 <if>
3843 <bool>
3844 <not><istrue value="${imagemagick.src.present}"/></not>
3845 </bool>
3846
3847 <echo>checking out imagemagick source into the extension area</echo>
3848
3849 <exec executable="svn">
3850 <arg value="checkout"/>
3851 <arg value="${svn.root}/gs2-extensions/imagemagick/trunk/src"/>
3852 <arg value="${imagemagick.src.dir}"/>
3853 </exec>
3854
3855 <else>
3856 <echo>imagemagick source code already exists at ${imagemagick.src.dir}</echo>
3857 </else>
3858 </if>
3859 </target>
3860
3861 <!-- 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. -->
3862 <target name="compile-imagemagick" if="checkout.imagemagick.ext">
3863
3864 <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
3865 <property name="imagemagick.compiled.dir" value="${gs2build.home}/ext/imagemagick/${os.bin.dir}"/>
3866
3867 <condition property="imagemagick.src.present.firstcheck">
3868 <available file="${imagemagick.src.dir}" type="dir" />
3869 </condition>
3870 <condition property="imagemagick.compiled.present">
3871 <available file="${imagemagick.compiled.dir}" type="dir"/>
3872 </condition>
3873 <!--<condition property="imagemagick.bin.present">
3874 <available file="${basedir}/wherever/the/imgmagick/binary/is/to/be/found" type="dir" />
3875 </condition>-->
3876
3877 <!-- imagemagick will only be checked out if the user set the checkout.imagemagick.ext in build.properties -->
3878 <if>
3879 <bool>
3880 <isfalse value="${imagemagick.src.present.firstcheck}"/>
3881 </bool>
3882 <antcall target="checkout-imagemagick"/>
3883 </if>
3884
3885 <!-- keep track of whether the imagemagick src is now indeed present. Need to know this for a subsequent test -->
3886 <condition property="imagemagick.src.present">
3887 <available file="${imagemagick.src.dir}" type="dir" />
3888 </condition>
3889
3890 <if>
3891 <bool>
3892 <and>
3893 <istrue value="${imagemagick.src.present}"/> <!-- imagemagick src code is present -->
3894 <isfalse value="${imagemagick.compiled.present}"/> <!-- imagemagick src not compiled yet, so no imagemagick/os subfolder yet -->
3895 </and>
3896 </bool>
3897 <!-- then compile it. Only necessary for mac/linux, since windows has a stable working binary of imagemagick -->
3898 <exec executable="/bin/bash" dir="${imagemagick.src.dir}" failonerror="true">
3899 <arg value="CASCADE-MAKE.sh"/>
3900 </exec>
3901 </if>
3902 </target>
3903
3904
3905 <!-- Compile up gnome-lib src folder if: checkout.gnomelib.ext is turned on, and if not using the binary
3906 version (gnome-lib-minimal), and if the gnome-lib src folder is not already compiled up. -->
3907 <target name="compile-gnome-lib" if="checkout.gnomelib.ext">
3908
3909 <!-- http://stackoverflow.com/questions/3290307/sourcing-a-shell-profile-in-an-ant-build-file
3910 TODO: CASCADE-MAKE already sources devel.bash, but we still want to source it more globally,
3911 so that the rest of the GS3 compilation process also has access to those env variables -->
3912
3913 <property name="gnome.lib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
3914 <property name="gnome.lib.compiled.dir" value="${basedir}/gs2build/ext/gnome-lib/${os.bin.dir}"/>
3915
3916 <condition property="gnome.src.lib.present.firstcheck" value="true" else="false">
3917 <available file="${gnome.lib.src.dir}" type="dir" />
3918 </condition>
3919 <condition property="gnome.compiled.lib.present" value="true" else="false">
3920 <available file="${gnome.lib.compiled.dir}" type="dir"/>
3921 </condition>
3922 <condition property="gnome.lib.min.present" value="true" else="false">
3923 <available file="${basedir}/gs2build/ext/gnome-lib-minimal" type="dir" />
3924 </condition>
3925
3926 <!-- Make sure to checkout gnome-lib if it was not checked out at this stage
3927 since we're instructed to do so in th pre-condition to this target -->
3928 <if>
3929 <bool>
3930 <and>
3931 <isfalse value="${gnome.lib.min.present}"/>
3932 <isfalse value="${gnome.src.lib.present.firstcheck}"/>
3933 </and>
3934 </bool>
3935 <antcall target="checkout-gnome-lib"/>
3936 </if>
3937
3938 <!-- Keep track of whether we have the gnome-lib src folder now. Need to know this for a subsequent test -->
3939 <condition property="gnome.src.lib.present" value="true" else="false">
3940 <available file="${gnome.lib.src.dir}" type="dir" />
3941 </condition>
3942
3943 <!--<echo>MIN: ${gnome.lib.min.present}
3944 SRC LIB: ${gnome.src.lib.present}
3945 COMPILED: ${gnome.compiled.lib.present}</echo>-->
3946
3947 <if>
3948 <bool>
3949 <and>
3950 <isfalse value="${gnome.lib.min.present}"/> <!-- no gnome-lib-minimal binary present -->
3951 <istrue value="${gnome.src.lib.present}"/> <!-- gnome-lib folder for compilation is present-->
3952 <isfalse value="${gnome.compiled.lib.present}"/> <!-- gnome-lib not yet compiled, so no gnome-lib/os subfolder yet -->
3953 </and>
3954 </bool>
3955
3956 <!-- then compile it. Only necessary for mac/linux, since windows doesn't need gnome lib -->
3957 <exec executable="/bin/bash" dir="${gnome.lib.src.dir}" failonerror="true">
3958 <arg value="CASCADE-MAKE.sh"/>
3959 </exec>
3960 </if>
3961 </target>
3962
3963
3964 <target name="prepare-gnome-lib" depends="init" if="collection.building.enabled" unless="gnome-lib.present">
3965 <if>
3966 <bool>
3967 <istrue value="${checkout.gnomelib.ext}"/>
3968 </bool>
3969
3970 <antcall target="checkout-gnome-lib"/>
3971 <!--Compilation of gnome-lib happens during ant install, just before configuring (common-src and) build-src-->
3972
3973 <else>
3974 <echo>**** Not preparing gnome-lib:</echo>
3975 <echo>property checkout.gnomelib.ext in build.properties was not set or was set to false</echo>
3976 </else>
3977 </if>
3978 </target>
3979
3980
3981 <target name="checkout-gnome-lib" depends="init" if="collection.building.enabled" unless="nosvn.mode">
3982
3983 <property name="gnomelib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
3984 <condition property="gnome.src.present">
3985 <available file="${gnomelib.src.dir}" type="dir" />
3986 </condition>
3987
3988 <if>
3989 <bool>
3990 <not><istrue value="${gnome.src.present}"/></not>
3991 </bool>
3992
3993 <echo>checking out gnome-lib extension</echo>
3994 <exec executable="svn">
3995 <arg value="checkout"/>
3996 <arg value="${svn.root}/gs2-extensions/gnome-lib/trunk/src"/>
3997 <arg value="${gs2build.home}/ext/gnome-lib"/>
3998 </exec>
3999
4000 <else>
4001 <echo>gnomelib source code already exists at ${gnomelib.src.dir}</echo>
4002 </else>
4003 </if>
4004
4005 </target>
4006
4007 <target name="checkout-winbin" depends="init" if="current.os.iswindows"
4008 unless="nosvn.mode">
4009
4010 <exec executable="svn">
4011 <arg value="checkout"/>
4012 <arg value="${svn.root}/main/${branch.path}/binaries/windows"/>
4013 <arg value="-r"/><arg value="${branch.revision}"/>
4014 <arg value="winbin"/>
4015 </exec>
4016
4017 </target>
4018
4019 <target name="update-winbin" depends="init" if="current.os.iswindows" unless="nosvn.mode">
4020 <exec executable="svn">
4021 <arg value="update"/>
4022 <arg value="winbin"/>
4023 <arg value="-r"/><arg value="${branch.revision}"/>
4024 </exec>
4025
4026 </target>
4027
4028 <target name="get-windows-binaries" depends="init" if="collection.building.enabled.windows">
4029 <move todir="${gs2build.home}/bin/windows" failonerror="false">
4030 <fileset dir="${basedir}/winbin/bin"/>
4031 </move>
4032 </target>
4033
4034 <target name="delete-winbin" depends="init" if="collection.building.enabled.windows">
4035 <delete dir="${basedir}/winbin"/>
4036 </target>
4037
4038 <target name="unzip-windows-packages" depends="init" if="current.os.iswindows">
4039 <unzip src="${common.src.home}/packages/windows/crypt/crypt.zip"
4040 dest="${common.src.home}/packages/windows/crypt"/>
4041 <untar compression="gzip"
4042 src="${common.src.home}/packages/sqlite/${sqlite.targz.version}"
4043 dest="${common.src.home}/packages/sqlite"/>
4044 <unzip src="${common.src.home}/indexers/packages/windows/iconv/iconv.zip"
4045 dest="${common.src.home}/indexers/packages/windows/iconv"/>
4046 </target>
4047
4048 <target name="gs2build-edit-setup-bat" if="collection.building.enabled.windows">
4049 <!-- we want a windows path in the setup.bat file -->
4050 <pathconvert targetos="windows" property="gs2build.home.windows">
4051 <path path="${gs2build.home}"/>
4052 </pathconvert>
4053 <move file="${gs2build.home}/setup.bat" tofile="${gs2build.home}/setup-tmp.bat">
4054 <filterset>
4055 <filter token="gsdlhome" value="${gs2build.home.windows}"/>
4056 </filterset>
4057 </move>
4058 <move file="${gs2build.home}/setup-tmp.bat" tofile="${gs2build.home}/setup.bat" />
4059 </target>
4060
4061
4062 <target name="clean-build-src" depends="init" 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="clean"/>
4067 </exec>
4068 </if>
4069 <!-- windows: -->
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
4079 <target name="distclean-build-src" depends="init,clean-build-src" if="collection.building.enabled">
4080 <!-- unix: -->
4081 <if><bool><available file="${build.src.home}/Makefile"/></bool>
4082 <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
4083 <arg value="distclean"/>
4084 </exec>
4085 </if>
4086 <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->
4087 <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
4088 <arg value="/f"/>
4089 <arg value="win32.mak"/>
4090 <arg value="clean"/>
4091 <arg value="GSDLHOME=${gs2build.home}"/>
4092 </exec>
4093 </target>
4094
4095 <target name="configure-build-src" depends="init" if="collection.building.enabled"
4096 description="Configure the build-src component">
4097 <exec executable="${build.src.home}/configure" os="${os.unix}"
4098 dir="${build.src.home}" failonerror="true">
4099 <arg value="--prefix=${gs2build.home}"/>
4100 <arg line="${gs2.opt.args} ${static.arg} ${cross.configure.args} ${allargs}"/>
4101 </exec>
4102 </target>
4103
4104 <!-- common-src is done separately and needs to be compiled first -->
4105 <target name="compile-build-src" depends="init" if="collection.building.enabled">
4106
4107 <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
4108 <arg line="${ldlpath.arg}"/>
4109 </exec>
4110
4111 <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
4112 <env key="GSDLOS" value="${os.bin.dir}"/>
4113 <arg value="install"/>
4114 </exec>
4115
4116 <!-- run the setup script -->
4117 <!-- <exec executable="${compile.windows.c++.setup}" osfamily="windows" failonerror="true"/>-->
4118 <!--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-->
4119 <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
4120 <arg value="/f"/>
4121 <arg value="win32.mak"/>
4122 <arg value="GSDLHOME=${gs2build.home}"/>
4123 </exec>
4124 <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
4125 <arg value="/f"/>
4126 <arg value="win32.mak"/>
4127 <arg value="install"/>
4128 <arg value="GSDLHOME=${gs2build.home}"/>
4129 </exec>
4130 </target>
4131
4132
4133 <!-- ======================== TESTING Targets ========================= -->
4134
4135 <target name="test" description="Run the (incomplete) JUnit test suite "
4136 depends="init">
4137 <mkdir dir="${basedir}/test"/>
4138 <junit printsummary="withOutAndErr"
4139 errorproperty="test.failed"
4140 failureproperty="test.failed"
4141 fork="${junit.fork}">
4142 <formatter type="plain"/>
4143 <classpath>
4144 <pathelement location="${build.home}/gsdl3test.jar"/>
4145 <path refid="compile.classpath"/>
4146 </classpath>
4147 <test name="${testcase}" if="testcase"/>
4148 <batchtest todir="${basedir}/test" unless="testcase">
4149 <fileset dir="${build.home}" includes="**/*Test.class" />
4150 </batchtest>
4151 </junit>
4152 <echo>
4153 *********************************************
4154 Test output can be found in directory 'test'
4155 *********************************************
4156 </echo>
4157 </target>
4158
4159 <!-- ======================== FLAX Targets ========================= -->
4160 <target name="prepare-flax" description="check out flax source code from another repository" if="install.flax">
4161 <echo>checking out flax ...</echo>
4162 <mkdir dir="${basedir}/src/java/org/flax"/>
4163 <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/flax"/>
4164 <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/action/flax"/>
4165 <mkdir dir="${web.home}/WEB-INF/classes/flax"/>
4166 <mkdir dir="${web.home}/interfaces/flax"/>
4167 <mkdir dir="${web.home}/sites/flax"/>
4168 <mkdir dir="${basedir}/flax-resources"/>
4169 <mkdir dir="${basedir}/flax-lib"/>
4170 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/flax"/>
4171 <arg value="src/java/org/flax"/></exec>
4172 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/flax"/>
4173 <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
4174 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/action/flax"/>
4175 <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
4176 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/WEB-INF/classes/flax"/>
4177 <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
4178 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/interfaces/flax"/>
4179 <arg value="${web.home}/interfaces/flax"/></exec>
4180 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/sites/flax"/>
4181 <arg value="${web.home}/sites/flax"/></exec>
4182 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/flax-resources"/>
4183 <arg value="flax-resources"/></exec>
4184 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/lib"/>
4185 <arg value="flax-lib"/></exec>
4186 <antcall target="flax-copy-del-files" />
4187 </target>
4188
4189 <target name="flax-copy-del-files" description="copy some flax files into the appropriate greenstone3 directories and delete some unwanted greenstone stuff">
4190 <copy file="${web.home}/WEB-INF/classes/flax/flax.xml" todir="${web.home}/WEB-INF" overwrite="true" />
4191 <copy todir="${web.home}/WEB-INF/classes" overwrite="true" >
4192 <fileset dir="${web.home}/WEB-INF/classes/flax">
4193 <include name="interface_flax*.properties"/>
4194 </fileset>
4195 </copy>
4196 <copy todir="${web.home}/WEB-INF/lib">
4197 <fileset dir="${basedir}/flax-lib">
4198 <include name="*.jar"/>
4199 </fileset>
4200 </copy>
4201 <!--<delete dir="${web.home}/sites/gateway"/>
4202 <delete dir="${web.home}/sites/localsite"/>-->
4203 </target>
4204
4205 <target name="update-flax" description="update flax from repository">
4206 <echo>updating flax ...</echo>
4207 <exec executable="svn"><arg value="update"/>
4208 <arg value="src/java/org/flax"/></exec>
4209 <exec executable="svn"><arg value="update"/>
4210 <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
4211 <exec executable="svn"><arg value="update"/>
4212 <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
4213 <exec executable="svn"><arg value="update"/>
4214 <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
4215 <exec executable="svn"><arg value="update"/>
4216 <arg value="${web.home}/interfaces/flax"/></exec>
4217 <exec executable="svn"><arg value="update"/>
4218 <arg value="${web.home}/web/sites/flax"/></exec>
4219 <exec executable="svn"><arg value="update"/>
4220 <arg value="flax-resources"/></exec>
4221 <exec executable="svn"><arg value="update"/>
4222 <arg value="flax-lib"/></exec>
4223 <antcall target="compile-core" />
4224 </target>
4225
4226 <!-- ========================End of FLAX Targets ========================= -->
4227
4228 <target name="compile-javadocs">
4229 <javadoc packagenames="org.greenstone.*"
4230 sourcepath="src/java"
4231 defaultexcludes="yes"
4232 destdir="docs/javadoc"
4233 author="true"
4234 version="true"
4235 use="true"
4236 windowtitle="Greenstone3 API">
4237 <doctitle><![CDATA[<h1>Greenstone3 API</h1>]]></doctitle>
4238 </javadoc>
4239 </target>
4240
4241<!-- ========== Some distribution targets ======================== -->
4242 <target name="remove-source">
4243 <if><bool><isset property="with.gli.and.gems"/></bool>
4244 <delete includeEmptyDirs="true">
4245 <fileset dir="." defaultexcludes="false">
4246 <patternset refid="greenstone3.source.component"/>
4247 </fileset>
4248 </delete>
4249
4250 <else>
4251 <delete includeEmptyDirs="true">
4252 <fileset dir="." defaultexcludes="false">
4253 <patternset refid="greenstone3.source.no.gli.component"/>
4254 </fileset>
4255 </delete>
4256 </else>
4257 </if>
4258 </target>
4259
4260 <target name="dist-tidy"
4261 description="'tidies-up' a greenstone3 installation for distribution."
4262 unless="${properties.keep.src}">
4263
4264 <!-- delete unneeded things -->
4265 <delete dir="${packages.home}/axis"/>
4266 <delete><fileset dir="${packages.home}" includes="*.zip"/></delete>
4267 <delete file="README-SVN.txt"/>
4268 <delete file="build.properties.svn"/>
4269
4270 <!-- delete source files -->
4271 <antcall target="remove-source"/>
4272
4273 <!-- create empty directories -->
4274 <mkdir dir="${web.writablehome}/applet"/>
4275 <mkdir dir="${web.writablehome}/logs"/>
4276 <mkdir dir="${web.writablehome}/logs/tmp"/>
4277
4278 <!-- Lines with ***** are commented out because these files are useful if we want hybrid installations -->
4279
4280 <!-- os specific tidy-ups -->
4281 <!-- linux, mac -->
4282 <if><bool><istrue value="${current.os.isunix}"/></bool>
4283 <!--*****<delete><fileset dir="." includes="*.bat"/></delete>-->
4284 <if><bool><isset property="with.gli.and.gems"/></bool>
4285 <!--*****<delete><fileset dir="gli" includes="*.bat"/></delete>-->
4286 </if>
4287 <!--*****<delete><fileset dir="gs2build" includes="*.bat"/></delete>-->
4288 <!--*****<delete><fileset dir="bin/script" includes="*.bat"/></delete>-->
4289 <delete file="${basedir}/gs2build/win32cfg.h"/>
4290 <delete file="${basedir}/gs2build/win32.mak"/>
4291 <delete dir="${basedir}/winutil"/>
4292 <delete failonerror="false"><fileset dir="${lib.jni}" includes="*.dll"/></delete>
4293
4294 <!-- windows -->
4295 <else><if><bool><istrue value="${current.os.iswindows}"/></bool>
4296 <!--*****<delete><fileset dir="." includes="*.sh,*.bash,*.csh"/></delete>-->
4297 <if><bool><isset property="with.gli.and.gems"/></bool>
4298 <!--*****<delete><fileset dir="gli" includes="*.sh,*.bash,*.csh"/></delete>-->
4299 </if>
4300 <!--*****<delete><fileset dir="gs2build" includes="*.sh,*.bash,*.csh"/></delete>-->
4301 <!--*****<delete><fileset dir="bin/script" includes="*.sh,*.bash,*.csh"/></delete>-->
4302 </if></else></if>
4303
4304 </target>
4305
4306 <!-- fix up executable permissions for binary release -->
4307 <target name="fix-execute-permissions">
4308 <echo>Setting binaries to executable</echo>
4309 <chmod perm="775">
4310 <fileset dir="."><patternset refid="greenstone3.executables"/></fileset>
4311 </chmod>
4312 </target>
4313
4314 <!-- fix up executable permissions for source code release -->
4315 <target name="fix-execute-permissions-source">
4316 <chmod perm="775">
4317 <fileset dir="."><patternset refid="greenstone3.source.executables"/></fileset>
4318 </chmod>
4319 </target>
4320
4321 <!-- for macs, set up the .app shortcuts to gsi, gli, client-gli and gems -->
4322 <target name="gen-mac-shortcuts">
4323 <exec executable="uname" dir="${basedir}" failonerror="false"
4324 outputproperty="darwin.kernel.version">
4325 <arg value="-r"/>
4326 </exec>
4327
4328 <echo>darwin kernel version: ${darwin.kernel.version}</echo>
4329
4330 <if>
4331 <bool><matches string="${darwin.kernel.version}" pattern="^([0-9]|1[0-8])\."/></bool>
4332 <property name="mac.app.bitness" value="32"/>
4333 <else>
4334 <property name="mac.app.bitness" value="64"/>
4335 </else>
4336 </if>
4337
4338 <echo>bitness for mac apps: ${mac.app.bitness}</echo>
4339
4340 <!--(recursively) copy the .app files from the MacShortcutsXbit folder of the correct bitness
4341 https://stackoverflow.com/questions/1685442/how-to-copy-a-directory-using-ant -->
4342 <copy todir="${basedir}" >
4343 <fileset dir="${basedir}/MacShortcuts${mac.app.bitness}bit" includes="**"/>
4344 </copy>
4345
4346 <if><bool><istrue value="${current.os.ismac}"/></bool>
4347 <filter token="gsdl3srchome" value="${basedir}"/>
4348 <copy file="${basedir}/gs3-server.app/Contents/document.wflow.in" tofile="${basedir}/gs3-server.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4349 <copy file="${basedir}/gli.app/Contents/document.wflow.in" tofile="${basedir}/gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4350 <copy file="${basedir}/client-gli.app/Contents/document.wflow.in" tofile="${basedir}/client-gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4351 <copy file="${basedir}/gems.app/Contents/document.wflow.in" tofile="${basedir}/gems.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4352 </if>
4353 </target>
4354
4355 <!-- ============= tweaks for making compilation static ========== -->
4356 <target name="tweak-makefiles" depends="init" if="compile.static">
4357 <antcall target="rtftohtml-add-static" />
4358 </target>
4359
4360 <target name="rtftohtml-add-static" depends="init" if="collection.building.enabled">
4361 <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" />
4362 </target>
4363
4364 <target name="run-collection-tests">
4365 <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
4366 <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>
4367 </if>
4368 <for param="testjar">
4369 <path>
4370 <fileset dir="${basedir}" includes="web/sites/*/collect/*/tests/tests.jar"/>
4371 </path>
4372 <sequential>
4373 <echo>Testing @{testjar}</echo>
4374 <java classname="org.junit.runner.JUnitCore" fork="true">
4375 <!--https://stackoverflow.com/questions/38676719/selenium-using-java-the-path-to-the-driver-executable-must-be-set-by-the-webdr-->
4376 <sysproperty key="webdriver.gecko.driver" path="${basedir}/ext/testing/geckodriver"/>
4377 <arg value="gstests.TestClass"/>
4378 <jvmarg value="-DSERVERURL=${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}${server.default.servlet} "/>
4379 <classpath>
4380 <fileset dir="${basedir}/ext/testing/lib/java">
4381 <include name="*.jar"/>
4382 </fileset>
4383 <files includes="@{testjar}"/>
4384 </classpath>
4385 </java>
4386 </sequential>
4387 </for>
4388 </target>
4389
4390 <target name="build-collection-tests">
4391 <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
4392 <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>
4393 </if>
4394 <for param="compiledir">
4395 <path>
4396 <dirset dir="${basedir}" includes="web/sites/*/collect/*/tests/src"/>
4397 </path>
4398 <sequential>
4399 <echo>Compiling @{compiledir}</echo>
4400 <if><bool><not><available file="@{compiledir}/../build" type="dir"/></not></bool>
4401 <mkdir dir="@{compiledir}/../build"/>
4402 </if>
4403 <javac
4404 srcdir="@{compiledir}"
4405 destdir="@{compiledir}/../build"
4406 includeantruntime="${compile.includeantruntime}"
4407 debug="${compile.debug}"
4408 deprecation="${compile.deprecation}"
4409 optimize="${compile.optimize}"
4410 encoding="${compile.encoding}">
4411 <classpath>
4412 <fileset dir="${basedir}/ext/testing/lib/java">
4413 <include name="*.jar"/>
4414 </fileset>
4415 </classpath>
4416 <include name="gstests/*.java"/>
4417 </javac>
4418 <jar destfile="@{compiledir}/../tests.jar">
4419 <fileset dir="@{compiledir}/../build">
4420 <include name="gstests/**"/>
4421 </fileset>
4422 <manifest>
4423 <attribute name="Built-By" value="${user.name}" />
4424 </manifest>
4425 </jar>
4426 </sequential>
4427 </for>
4428 </target>
4429</project>
Note: See TracBrowser for help on using the repository browser.