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

Last change on this file since 34601 was 34601, checked in by kjdon, 20 months ago

created new gsorg.root variable so we can easily change the value in one place

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