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

Last change on this file since 33461 was 33461, checked in by ak19, 5 years ago

Implementing Diego Spano's suggested changes for tomcat's allowLinking configuration settings used to support symlinking from the web to folders outside the web app base folder. This confug setting needs to be set differently for tomcat 8. Its value used to be fixed to false in the past, so false becomes the new default. A new user configurable property is introduced in build.xml, tomcat.user.allowLinking. However, since apache's tomcat documentation says that the value should never be set to true for Windows or any OS where the filesystem is case insensitive, as this can affect security, build.xml internally uses a different new property called tomcat.allowLinking which works out the final value. For windows, this will always be false and a warning is printed when the user configurable property got overridden to false on Windows. When the user configurable property was set to true in any other case, a warning is printed on non-Windows OS about how the user should set the value to false if their OS has a case onsensitive file system. Finally, the calculated/sanitised value stored in tomcat.allowLinking propagates to greenstone.xml in place of the placeholders in the greenstone.xml.in and ultimately greenstone.xml.svn files

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