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

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

Tested new tomcat.allowLinking property on Windows too now and it behaves correctly. Cleaning up debug statements and moving properties in build.properties around so that https related proeprties remain grouped together as before.

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