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

Last change on this file since 34111 was 34111, checked in by ak19, 4 years ago

Undoing additions surrounding JAVA_TOOL_OPTIONS where file.encoding is set to utf-9, after discussing with Kathy and Dr Bainbridge. We think it possible that the changes to XMLConverter.java that enforce utf-8 as the char-encoding for reading in files will also fix the last remaining locale issue which required the JAVA_TOOL_OPTIONS of file.encoding=utf-8 to be passed in. Will still need to ask Shaoqun, in case she has a Win machine in Chinese locale, to test 3.09 vs the caveat for 3.10 that will contain this final commit. But our win machine generating the win nightlies runs overnight and is not accesible remotely. So the earlierst that test can be done is tomorrow.

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