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

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

Undoing commit 34573, as Mojave was still fine with the mac leopard generated 32 bit IsisGdl (I wrongly thought I had tested the Mojave 64 bit IsisGdl and that it worked), whereas the 64 bit IsisGdl generated on Mojave does not appear to work on Mojave or Catalina. So as the 32 bit worked on more MacOS, and the 64 bit doesn't (yet) work any known Mac OS, putting it back. Testing other tutorials, as they're not affected by this single binary

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