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

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

The inclusion of chcp 850 in setup.bat was not sufficient when Tracie Feng was working on her machine that's set to Chinese locale. The additional changes described at http://trac.greenstone.org/changeset/33793 were found to be necessary also. So am activating these additional changes by uncommenting them. This commit also contains some minor changes to comments.

File size: 194.2 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="GSDL3HOME" value="${web.home}"/>
2490 <env key="PATH" path="${tomcat.path}"/>
2491 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
2492 <env key="CATALINA_HOME" value="${catalina.home}"/>
2493 <env key="CLASSPATH" path="${tomcat.classpath}"/>
2494 <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
2495 <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
2496 <env key="WNHOME" path="${wn.home}"/>
2497 <env key="FEDORA_HOME" path="${fedora.home}"/>
2498 <arg value="${catalina.home}/bin/startup.sh"/>
2499 </exec>
2500 <exec executable="${catalina.home}/bin/startup.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="true">
2501 <env key="JAVA_TOOL_OPTIONS" value="-Dfile.encoding=UTF-8"/>
2502 <env key="GSDLOS" value="windows"/>
2503 <env key="GSDL3HOME" value="${web.home}"/>
2504 <env key="Path" path="${tomcat.path}"/>
2505 <env key="PATH" path="${tomcat.path}"/>
2506 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
2507 <env key="CATALINA_HOME" value="${catalina.home}"/>
2508 <env key="CLASSPATH" path="${tomcat.classpath}"/>
2509 <env key="FEDORA_HOME" path="${fedora.home}"/>
2510 </exec>
2511 <!-- wait for the server to startup in case other targets need it running -->
2512 <waitfor maxwait="5" maxwaitunit="second">
2513 <and>
2514 <socket server="${tomcat.server}" port="${default.tomcat.port}"/>
2515 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/index.html"/>-->
2516 <http url="${local.http.url}${app.path}/index.html"/>
2517 </and>
2518 </waitfor>
2519
2520 </target>
2521
2522 <!--ant task http: http://www.jajakarta.org/ant/ant-1.6.1/docs/ja/manual/api/org/apache/tools/ant/taskdefs/condition/Http.html-->
2523 <target name="reconfigure" description="Reconfigure the message router">
2524 <waitfor maxwait="5" maxwaitunit="second">
2525 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c"/>-->
2526 <http url="${local.http.url}${app.path}${server.default.servlet}?a=s&amp;sa=c"/>
2527 </waitfor>
2528 </target>
2529
2530 <!--Command-line args to Ant: http://www.jguru.com/faq/view.jsp?EID=471794-->
2531 <target name="reconfigure-collection" description="Reconfigure the collection">
2532 <waitfor maxwait="5" maxwaitunit="second">
2533 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c&amp;sc=${collection}"/>-->
2534 <http url="${local.http.url}${app.path}${server.default.servlet}?a=s&amp;sa=c&amp;sc=${collection}"/>
2535 </waitfor>
2536 </target>
2537
2538 <!-- windows: do we want to launch a webrowser?? -->
2539 <!-- shouldn't this test whether anything is running first?
2540 It's safer to always attempt to stop tomcat: that way we won't be dependent on the right time
2541 to check whether the server is stopped or still running before attempting to start again.
2542 This target, which was recently called force-stop-tomcat for a while but is back to being
2543 called stop-tomcat, now hides the Java exception output that appears whenever tomcat is already
2544 stopped as happens when stop-tomcat is called consecutively. -->
2545 <target name="force-stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal">
2546 <!--<exec executable="${catalina.home}/bin/shutdown.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">-->
2547 <exec executable="${sudo.or.not}" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
2548 <env key="FEDORA_HOME" path="${fedora.home}"/>
2549 <env key="CATALINA_HOME" value="${catalina.home}"/>
2550 <arg value="${catalina.home}/bin/shutdown.sh"/>
2551 <arg line=">/dev/null 2>&amp;1"/>
2552 </exec>
2553 <exec executable="${catalina.home}/bin/shutdown.bat" osfamily="windows" dir="${catalina.home}/bin" spawn="false">
2554 <env key="JAVA_TOOL_OPTIONS" value="-Dfile.encoding=UTF-8"/>
2555 <env key="FEDORA_HOME" path="${fedora.home}"/>
2556 <env key="CATALINA_HOME" value="${catalina.home}"/>
2557 <arg line=">nul 2>&amp;1"/>
2558 </exec>
2559 </target>
2560
2561 <!-- Can also try the "socket" condition in place of the "http" condition
2562 And also use a <waitfor> in place of <condition>, such as:
2563 <waitfor maxwait="5" maxwaitunit="second" timeoutproperty="tomcat.isstopped"><http url="..."/></waitfor>
2564 The http URL resolves to host:port/greenstone3
2565 Condition uses <http/> rather than <socket/> for testing, since if the server was stopped, the socket
2566 might still be in use for some moments. We test the URL with the http condition since it's likelier to
2567 fail sooner if the server has indeed been stopped. -->
2568 <target name="check-tomcat-running">
2569 <condition property="tomcat.isrunning">
2570 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}"/>-->
2571 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}"/>--><!-- untrusted certificates won't work, so don't test https urls-->
2572 <http url="${local.http.url}"/><!-- testing the local http url instead -->
2573 </condition>
2574 </target>
2575
2576 <!--
2577 <target name="verbose-check-tomcat-running">
2578 <condition property="tomcat.isrunning" value="true" else="false">
2579 <http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}"/>
2580 <http url="${local.http.url}"/>
2581 </condition>
2582 <echo>Tomcat is running: ${tomcat.isrunning}</echo>
2583 </target>
2584 -->
2585 <target name="verbose-check-tomcat-running" depends="check-tomcat-running">
2586 <if>
2587 <bool>
2588 <istrue value="${tomcat.isrunning}"/>
2589 </bool>
2590 <echo>Tomcat is running: ${tomcat.isrunning}</echo>
2591 <else><echo>Tomcat is running: false</echo></else><!-- tomcat.isrunning not set -->
2592 </if>
2593 </target>
2594
2595 <!-- Need a copy of the check-tomcat-running target with a distinct property, because ant restart runs
2596 both stop and start, both of which need to do tomcat checks. Each property can be set only once during
2597 an invocation with ant. So ant restart will need two properties to store each of the tomcat checks -->
2598 <target name="check-tomcat-started">
2599 <condition property="tomcat.isstarted">
2600 <!--<http url="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}"/>-->
2601 <http url="${local.http.url}"/>
2602 </condition>
2603 </target>
2604
2605
2606
2607 <!-- stop-tomcat checks if the tomcat server is already running. If it appears to be running
2608 (regardless of whether tomcat was just starting to shut down), this target calls force-stop-tomcat
2609 to issue the shutdown command to tomcat. Then it waits for at most 15 seconds for the server to
2610 actually stop by checking the socket at which tomcat listens every second, printing a warning
2611 at the end of the max wait time of 15 seconds if tomcat was still running. -->
2612 <target name="stop-tomcat" description="Shutdown only Tomcat if running" depends="check-tomcat-running" if="tomcat.isrunning">
2613 <antcall target="force-stop-tomcat"/>
2614
2615 <property name="wait.numchecks" value="15"/>
2616 <echo>Waiting for the server to shutdown... (${wait.numchecks} seconds max)</echo>
2617 <waitfor maxwait="${wait.numchecks}" maxwaitunit="second" checkevery="1" checkeveryunit="second" timeoutproperty="tomcat.timedout">
2618 <not><socket server="${tomcat.server}" port="${default.tomcat.port}"/></not>
2619 </waitfor>
2620
2621 <if>
2622 <bool>
2623 <isset property="${tomcat.timedout}"/>
2624 </bool>
2625 <property name="tomcat.isrunning" value="true"/>
2626 <echo>WARNING: Checked the socket ${wait.numchecks} times, but port ${default.tomcat.port} is still busy.</echo>
2627 <else>
2628 <echo>Tomcat is stopped.</echo>
2629 <property name="tomcat.isrunning" value="false"/>
2630 </else>
2631 </if>
2632 </target>
2633
2634 <target name="restart-tomcat" description="Shutdown and restart only Tomcat" depends="init,stop-tomcat,force-start-tomcat"/>
2635
2636 <target name="setup-catalina-ant-tasks">
2637 <!-- Configure the custom Ant tasks for the Tomcat Manager application -->
2638 <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"
2639 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2640 <taskdef name="list" classname="org.apache.catalina.ant.ListTask"
2641 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2642 <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"
2643 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2644 <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"
2645 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2646 <taskdef name="roles" classname="org.apache.catalina.ant.RolesTask"
2647 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2648 <taskdef name="start" classname="org.apache.catalina.ant.StartTask"
2649 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2650 <taskdef name="stop" classname="org.apache.catalina.ant.StopTask"
2651 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2652 <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"
2653 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
2654 </target>
2655
2656 <!-- http://blog.andrewbeacock.com/2007/11/how-to-truncate-log-file-using-ubuntu.html
2657 Doing "cat </dev/null > packages/tomcat/logs/catalina.out" doesn't work as an ant target.
2658 It seems to have a problem with cat or </dev/null, with or without the < sign. -->
2659 <target name="reset-logs" description="Empties catalina.out, solr.log, greenstone.log, usage.log, server.log and contents of web/logs/tmp">
2660 <echo>Truncating catalina.out, solr.log, greenstone.log, usage.log and server.log, and emptying ${web.writablehome}/logs/tmp</echo>
2661 <exec executable="rm" os="${os.unix}" dir="${catalina.home}/logs" spawn="false">
2662 <arg value="-f"/>
2663 <arg value="catalina.out"/>
2664 </exec>
2665 <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
2666 <arg value="-f"/>
2667 <arg value="greenstone.log"/>
2668 </exec>
2669 <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
2670 <arg value="-f"/>
2671 <arg value="usage.log"/>
2672 </exec>
2673 <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
2674 <arg value="-f"/>
2675 <arg value="server.log"/>
2676 </exec>
2677
2678 <exec executable="touch" os="${os.unix}" dir="${catalina.home}/logs"
2679 spawn="false">
2680 <arg value="catalina.out"/>
2681 </exec>
2682 <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
2683 spawn="false">
2684 <arg value="greenstone.log"/>
2685 </exec>
2686 <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
2687 spawn="false">
2688 <arg value="usage.log"/>
2689 </exec>
2690 <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
2691 spawn="false">
2692 <arg value="server.log"/>
2693 </exec>
2694
2695 <exec executable="cmd" osfamily="windows" dir="${catalina.home}/logs" spawn="false">
2696 <arg line="/c echo. > catalina.out"/>
2697 </exec>
2698 <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
2699 <arg line="/c echo. > greenstone.log"/>
2700 </exec>
2701 <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
2702 <arg line="/c echo. > usage.log"/>
2703 </exec>
2704 <exec executable="cmd" osfamily="windows" dir="${web.writablehome}/logs" spawn="false">
2705 <arg line="/c echo. > server.log"/>
2706 </exec>
2707
2708 <!-- if ext/solr/logs/solr.log exists, truncate it -->
2709 <if><bool><available file="${solr-ext.home}/logs/solr.log" type="file"/></bool>
2710 <exec executable="rm" os="${os.unix}" dir="${solr-ext.home}/logs" spawn="false">
2711 <arg value="-f"/>
2712 <arg value="solr.log"/>
2713 </exec>
2714 <exec executable="touch" os="${os.unix}" dir="${solr-ext.home}/logs" spawn="false">
2715 <arg value="solr.log"/>
2716 </exec>
2717 <exec executable="cmd" osfamily="windows" dir="${solr-ext.home}/logs" spawn="false">
2718 <arg line="/c echo. > solr.log"/>
2719 </exec>
2720 </if>
2721
2722 <if>
2723 <bool><available file="${web.writablehome}/logs/tmp" type="dir"/></bool>
2724 <delete>
2725 <fileset dir="${web.writablehome}/logs/tmp" includes="**/*"/>
2726 </delete>
2727 </if>
2728 </target>
2729
2730 <target name="clear-tomcat-sessions" description="Clear the Tomcat Session info." depends="init">
2731 <exec executable="cmd" osfamily="windows" dir="${catalina.home}/work/Catalina/localhost/greenstone3" spawn="false">
2732 <arg line="/c echo. > SESSIONS.ser"/>
2733 </exec>
2734 <exec executable="rm" os="${os.unix}" dir="${catalina.home}/work/Catalina/localhost/greenstone3" spawn="false">
2735 <arg value="-f"/>
2736 <arg value="SESSIONS.ser"/>
2737 </exec>
2738
2739 </target>
2740 <!-- ======================= ant Targets ============================ -->
2741 <target name="prepare-ant" depends="init">
2742 <if>
2743 <bool>
2744 <not><available file="${packages.home}/ant/.flagfile"/></not>
2745 </bool>
2746 <property name="ant.download.version" value="apache-ant-1.9.13" />
2747 <get src="http://www.greenstone.org/gs3files/${ant.download.version}-bin.zip"
2748 dest="${packages.home}/${ant.download.version}-bin.zip"
2749 usetimestamp="true"/>
2750 <unzip src="${packages.home}/${ant.download.version}-bin.zip"
2751 dest="${packages.home}"/>
2752 <move todir="${packages.home}/ant">
2753 <fileset dir="${packages.home}/${ant.download.version}"/>
2754 </move>
2755 <echo file="${packages.home}/ant/.flagfile">
2756 the timestamp of this file is the time that ant was extracted from the zip files.
2757 it is used to figure out whether the files need to be refreshed or not in `ant prepare-ant`
2758 </echo>
2759
2760 <else>
2761 <echo>Ant has been prepared, will not prepare</echo>
2762 <echo>Delete ${packages.home}/ant/.flagfile to force refresh</echo>
2763 </else>
2764
2765 </if>
2766 </target>
2767
2768 <!-- ======================= Admin Targets ============================ -->
2769
2770 <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
2771 See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
2772 But you can do: echo mypassword | ant config-admin -->
2773 <target name="config-admin" description="Reset admin password">
2774 <input addproperty="admin.password" defaultvalue="admin" message="New admin password (3-20 characters):&gt;">
2775 <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
2776 </input>
2777 <!--<echo>PWD: ${admin.password}</echo>-->
2778 <antcall target="update-userdb">
2779 <param name="user.username" value="admin"/>
2780 <param name="user.password" value="${admin.password}"/>
2781 <param name="user.groups" value=""/>
2782 <param name="user.status" value=""/>
2783 <param name="user.comment" value="Password updated."/>
2784 <param name="user.email" value=""/>
2785 </antcall>
2786 </target>
2787
2788 <target name="config-user" description="Add or modify users" depends="get-user-data,update-userdb"/>
2789
2790 <target name="get-user-data" description="Get user details">
2791 <input addproperty="user.username" message="Username:&gt;"/>
2792 <input addproperty="user.password" defaultvalue="" message="Password (3-20 characters):&gt;">
2793 <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
2794 </input>
2795 <input addproperty="user.groups" defaultvalue="" message="Groups (comma-separated list, e.g. personal-collections-editor):&gt;"/>
2796 <input addproperty="user.status" defaultvalue="true" message="Enabled (true/false):&gt;"/>
2797 <input addproperty="user.comment" defaultvalue="" message="Comment:&gt;"/>
2798 <input addproperty="user.email" defaultvalue="" message="Email:&gt;"/>
2799 </target>
2800
2801 <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
2802 See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
2803 But you can do: echo mypassword | ant config-admin -->
2804 <target name="update-userdb" description="Add or modify users" depends="start-derby">
2805
2806 <!--
2807 We're now using derby networked server, so stopping and starting tomcat is not necessary.
2808 For embedded derby: stop tomcat if running, since derby db is embedded
2809 and only allows connections from one jvm instance at a time
2810 See http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html
2811 The ${tomcat.isrunning} property is set by the depends-target "check-tomcat-running" -->
2812
2813 <!-- Need the derby networked server to be running in order to modify the usersDB.
2814 The start-derby task will check if derby is already running (if not, ${derby.isstarted} will
2815 be false) and will only start up networked derby if it is not already running.
2816 The ${derby.isstarted} property is set by the depends-target "start-derby", since it won't
2817 set the property if called with antcall (like launching in a subshell). Have to use 'depends'.
2818 We'll check ${derby.isstarted} at the end to stop derby again if we had to start it up now.-->
2819 <!--<antcall target="start-derby"/>-->
2820
2821 <!-- wait a max of 5 seconds for the derbyserver to have started up -->
2822 <waitfor maxwait="5" maxwaitunit="second">
2823 <socket server="${derby.server}" port="${derby.server.port}"/>
2824 </waitfor>
2825
2826 <!--<echo>${admin.password}</echo>--> <!-- for testing -->
2827 <echo>gsdl3.writablehome: ${gsdl3.writablehome}</echo> <!-- for testing -->
2828 <echo>web.home: ${web.home}</echo> <!-- for testing -->
2829 <java classname="org.greenstone.gsdl3.util.ModifyUsersDB">
2830 <classpath refid="compile.classpath"/> <!--for ${web.lib}/gsdl3.jar and supporting files-->
2831 <sysproperty key="gsdl3.writablehome" value="${gsdl3.writablehome}" /> <!-- passes -D<syspropKey=syspropVal> to java class ModifyUsersDB. Available in java code as System.getProperty("syspropKey") -->
2832 <arg file="${web.home}/etc/usersDB"/>
2833 <arg value="${user.username}"/>
2834 <arg value="password=${user.password}"/>
2835 <arg value="groups=${user.groups}"/>
2836 <arg value="status=${user.status}"/>
2837 <arg value="comment=${user.comment}"/>
2838 <arg value="email=${user.email}"/>
2839 </java>
2840
2841 <!-- Need to stop networked derby again if we ran it for this target with the depends=start-derby call.
2842 The test here is for <not>derby.isstarted</not>, as the property would be the same as before
2843 derby was started, since properties are immutable within a single ant command. -->
2844 <if>
2845 <bool>
2846 <not><istrue value="${derby.isstarted}"/></not>
2847 </bool>
2848 <antcall target="force-stop-derby"/>
2849 </if>
2850
2851 </target>
2852
2853
2854 <!-- ======================= Axis Targets ============================ -->
2855
2856 <target name="prepare-axis" depends="init">
2857
2858 <if>
2859 <bool>
2860 <not><available file="${packages.home}/axis/.flagfile"/></not>
2861 </bool>
2862
2863 <get src="http://www.greenstone.org/gs3files/${axis.zip.version}"
2864 dest="${packages.home}/${axis.zip.version}"
2865 usetimestamp="true"/>
2866 <unzip src="${packages.home}/${axis.zip.version}"
2867 dest="${packages.home}"/>
2868 <move todir="${packages.home}/axis">
2869 <fileset dir="${packages.home}/${axis.dir.version}"/>
2870 </move>
2871 <!-- install axis into greenstone web app -->
2872 <copy todir="${web.lib}">
2873 <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/lib">
2874 <include name="*.jar"/>
2875 </fileset>
2876 </copy>
2877 <copy todir="${web.home}">
2878 <fileset dir="${packages.home}/axis/webapps/axis/">
2879 <include name="*.jsp"/>
2880 <include name="*.jws"/>
2881 </fileset>
2882 </copy>
2883 <copy tofile="${web.home}/axis.html" file="${packages.home}/axis/webapps/axis/index.html"/>
2884 <copy todir="${web.classes}">
2885 <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/classes">
2886 <include name="*.properties"/>
2887 </fileset>
2888 </copy>
2889 <echo file="${packages.home}/axis/.flagfile">
2890 the timestamp of this file is the time that axis was extracted from the zip files.
2891 it is used to figure out whether the files need to be refreshed or not in `ant prepare-axis`
2892 </echo>
2893
2894 <else>
2895 <echo>Axis has been prepared, will not prepare</echo>
2896 <echo>Delete ${packages.home}/axis/.flagfile to force refresh</echo>
2897 </else>
2898
2899 </if>
2900 </target>
2901
2902 <target name="soap-deploy-site" depends="init,get-sitename,get-siteuri,get-webservices,create-deployment-files,deploy-site"
2903 description="Deploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work."/>
2904
2905 <target name="deploy-site">
2906 <java classname="org.apache.axis.client.AdminClient">
2907 <classpath refid="compile.classpath"/>
2908 <arg value="-l"/>
2909 <arg value="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/servlet/AxisServlet"/>
2910 <arg file="${basedir}/resources/soap/deploy.wsdd"/>
2911 </java>
2912 <delete file="${basedir}/resources/soap/deploy.wsdd"/> <!--clean up, no longer used-->
2913 </target>
2914
2915 <target name="soap-undeploy-site" depends="get-undeploy-service-name"
2916 description="Undeploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work.">
2917 <filter token="servicesname" value="${axis.undeploy.servicename}"/>
2918 <copy file="${basedir}/resources/soap/undeploy-site.wsdd.template"
2919 tofile="${basedir}/resources/soap/undeploy.wsdd"
2920 filtering="true"
2921 overwrite="true"/>
2922 <java classname="org.apache.axis.client.AdminClient">
2923 <classpath refid="compile.classpath"/>
2924 <arg value="-l"/>
2925 <arg value="${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}/servlet/AxisServlet"/>
2926 <arg file="${basedir}/resources/soap/undeploy.wsdd"/>
2927 </java>
2928 <delete file="${basedir}/resources/soap/undeploy.wsdd"/> <!--clean up, no longer used-->
2929 </target>
2930
2931 <!-- this target used to deploy the default web service SOAPServer (base.webservice.name) on the localsite server
2932 with the default servicename of localsite-->
2933 <target name="deploy-localsite" depends="init"
2934 description="Deploy the SOAP server for localsite. Will start and stop Tomcat.">
2935 <antcall target="force-start-tomcat"/>
2936 <echo>Deploying ${base.webservice.name} web services for localsite under service name: localsite</echo>
2937 <antcall target="create-deployment-files">
2938 <param name="axis.sitename" value="localsite"/>
2939 <param name="axis.servicesname" value="${base.webservice.name}"/>
2940 <param name="axis.siteuri" value="localsite"/>
2941 </antcall>
2942 <antcall target="deploy-site">
2943 <param name="axis.sitename" value="localsite"/>
2944 <param name="axis.servicesname" value="${base.webservice.name}"/>
2945 <param name="axis.siteuri" value="localsite"/>
2946 </antcall>
2947 <echo>The Greenstone server has been started up. If you do not want it running, please type: ant stop.</echo>
2948 </target>
2949
2950 <target name="get-sitename" unless="axis.sitename">
2951 <input addproperty="axis.sitename" defaultvalue="localsite">What site do you want to deploy services for?
2952Press Enter for default:localsite</input>
2953 </target>
2954
2955 <target name="get-undeploy-service-name" unless="axis.undeploy.servicename">
2956 <input addproperty="axis.undeploy.servicename" defaultvalue="localsite">Please enter the full name of the service you wish to undeploy.
2957To find out which web services you've got deployed, point your browser to ${default.server.protocol}://${tomcat.server}:${default.tomcat.port}/greenstone3/services
2958Or press Enter for undeploying the default:localsite /&gt;</input>
2959 <echo>Name of service to undeploy: ${axis.undeploy.servicename}</echo>
2960 </target>
2961
2962 <target name="get-webservices" unless="axis.servicesname">
2963 <input addproperty="axis.servicesname" defaultvalue="${base.webservice.name}">Which set of web services do you want to deploy?
2964Choose from: ${web.services.list}
2965Or press Enter for default:${base.webservice.name} /&gt;</input>
2966 <echo>${axis.servicesname}</echo>
2967 </target>
2968
2969 <target name="get-siteuri" depends="get-sitename,get-webservices" unless="axis.siteuri">
2970 <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>
2971 <echo>Site: ${axis.sitename}, services: ${axis.servicesname}, servicesname: ${axis.siteuri}</echo>
2972 </target>
2973
2974 <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">
2975 <condition property="soap.method" value="provider='java:MSG' style='message' use='literal'">
2976 <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
2977 </condition>
2978
2979 <!--everything else defaults to java:RPC at present-->
2980 <condition property="soap.method" value="provider='java:RPC'">
2981 <not>
2982 <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
2983 </not>
2984 </condition>
2985 </target>
2986
2987 <target name="create-deployment-files" depends="set-soapmethod" if="axis.sitename">
2988 <filter token="sitename" value="${axis.sitename}"/>
2989 <filter token="siteuri" value="${axis.siteuri}"/>
2990 <filter token="servicesname" value="${axis.servicesname}"/>
2991 <filter token="soapmethod" value="${soap.method}"/>
2992 <copy file="${basedir}/resources/soap/site.wsdd.template"
2993 tofile="${basedir}/resources/soap/deploy.wsdd"
2994 filtering="true"
2995 overwrite="true"/>
2996 <!-- create the java files and compile them -->
2997 <copy file="${basedir}/resources/java/${axis.servicesname}.java.in"
2998 tofile="${src.gsdl3.home}/${axis.servicesname}${axis.sitename}.java"
2999 filtering="true"
3000 overwrite="true"/>
3001 <mkdir dir="${build.home}"/>
3002 <javac srcdir="${src.home}"
3003 destdir="${build.home}"
3004 includeantruntime="${compile.includeantruntime}"
3005 debug="${compile.debug}"
3006 deprecation="${compile.deprecation}"
3007 optimize="${compile.optimize}"
3008 encoding="${compile.encoding}">
3009 <classpath refid="compile.classpath"/>
3010 <include name="org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.java" />
3011 </javac>
3012 <mkdir dir="${web.classes}/org/greenstone/gsdl3"/>
3013 <copy file="${build.home}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
3014 tofile="${web.classes}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
3015 overwrite="true" />
3016 </target>
3017
3018
3019 <!-- ====================== Core targets ============================== -->
3020 <!-- core targets refer to the core gsdl3 java src -->
3021
3022 <target name="prepare-core"/>
3023
3024 <target name="configure-core"/>
3025
3026 <target name="update-core" depends="init,svnupdate-core,clean-core,compile-core"
3027 description="Update only the Greenstone core" />
3028
3029 <target name="svnupdate-core" unless="nosvn.mode">
3030 <exec executable="svn">
3031 <arg value="update"/>
3032 <arg value="${basedir}"/>
3033 <arg value="-r"/><arg value="${branch.revision}"/>
3034 </exec>
3035 </target>
3036
3037 <target name="clean-core"
3038 description="Clean only the Greenstone core">
3039 <!-- should this delete the gsdl3.jar from web/WEB-INF?? -->
3040 <delete dir="${build.home}"/>
3041 </target>
3042
3043 <target name="compile-core" depends="init"
3044 description="Compile only the Greenstone core">
3045 <mkdir dir="${build.home}"/>
3046
3047 <if><bool><isset property="with.jni"/></bool>
3048 <javac srcdir="${src.home}"
3049 destdir="${build.home}"
3050 includeantruntime="${compile.includeantruntime}"
3051 debug="${compile.debug}"
3052 deprecation="${compile.deprecation}"
3053 optimize="${compile.optimize}"
3054 encoding="${compile.encoding}">
3055 <classpath>
3056 <path refid="compile.classpath"/>
3057 </classpath>
3058 </javac>
3059 <else>
3060 <property name="gsprefix" value=""/>
3061 <javac srcdir="${src.home}"
3062 destdir="${build.home}"
3063 includeantruntime="${compile.includeantruntime}"
3064 debug="${compile.debug}"
3065 deprecation="${compile.deprecation}"
3066 optimize="${compile.optimize}"
3067 encoding="${compile.encoding}">
3068 <classpath>
3069 <path refid="compile.classpath"/>
3070 </classpath>
3071 <exclude name="org/greenstone/gsdl3/service/GS2MGPPRetrieve.java"/>
3072 <exclude name="org/greenstone/gsdl3/service/GS2MGPPSearch.java"/>
3073 <exclude name="org/greenstone/gsdl3/service/GS2MGSearch.java"/>
3074 <exclude name="org/greenstone/gsdl3/service/GS2MGRetrieve.java"/>
3075 <exclude name="org/greenstone/gsdl3/service/GoogleNgramMGPPSearch.java"/>
3076 <exclude name="org/greenstone/gsdl3/service/PhindPhraseBrowse.java"/>
3077 <exclude name="org/greenstone/gsdl3/util/GDBMWrapper.java"/>
3078 </javac>
3079 </else>
3080 </if>
3081 <jar destfile="${build.home}/gsdl3.jar">
3082 <fileset dir="${build.home}">
3083 <include name="org/greenstone/gsdl3/**"/>
3084 <include name="org/flax/**"/>
3085 <exclude name="**/Test.class"/>
3086 </fileset>
3087 <manifest>
3088 <attribute name="Built-By" value="${user.name}" />
3089 </manifest>
3090 </jar>
3091 <copy file="${build.home}/gsdl3.jar" todir="${web.lib}"/>
3092
3093 <jar destfile="${build.home}/gutil.jar">
3094 <fileset dir="${build.home}">
3095 <include name="org/greenstone/util/**"/>
3096 </fileset>
3097 <manifest>
3098 <attribute name="Built-By" value="${user.name}" />
3099 </manifest>
3100 </jar>
3101 <copy file="${build.home}/gutil.jar" todir="${web.lib}"/>
3102
3103 <!-- copy the localsite server in case we need it -->
3104 <copy file="${build.home}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" tofile="${web.classes}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" />
3105
3106 <!-- Greenstone Administrator Interface -->
3107 <jar destfile="${build.home}/GAI.jar">
3108 <fileset dir="${build.home}">
3109 <include name="org/greenstone/admin/**"/>
3110 </fileset>
3111 <manifest>
3112 <attribute name="Built-By" value="${user.name}" />
3113 </manifest>
3114 </jar>
3115 <copy file="${build.home}/GAI.jar" todir="${web.lib}"/>
3116 <copy file="${build.home}/GAI.jar" todir="${admin.dir}"/>
3117 <jar destfile="${build.home}/phind.jar">
3118 <fileset dir="${build.home}">
3119 <include name="org/greenstone/applet/phind/**"/>
3120 </fileset>
3121 <manifest>
3122 <attribute name="Built-By" value="${user.name}" />
3123 </manifest>
3124 </jar>
3125 <mkdir dir="${web.applet}"/>
3126 <copy file="${build.home}/phind.jar" todir="${web.applet}"/>
3127 <!-- phind also needs xercesImpl.jar and xml-apis.jar to be in web/applet -->
3128 <if>
3129 <bool><istrue value="${tomcat.islocal}"/></bool>
3130 <if><bool><available file="${catalina.home}/lib/xercesImpl.jar"/></bool><!-- moved for solr -->
3131 <copy file="${catalina.home}/lib/xercesImpl.jar" todir="${web.applet}"/>
3132 <copy file="${catalina.home}/lib/xml-apis.jar" todir="${web.applet}"/>
3133
3134 <else><!-- get from default GS3 web lib location-->
3135 <copy file="${web.lib}/xercesImpl.jar" todir="${web.applet}"/>
3136 <copy file="${web.lib}/xml-apis.jar" todir="${web.applet}"/>
3137 </else>
3138 </if>
3139 </if>
3140
3141
3142 <!-- skip anttasks for now
3143 <jar destfile="${build.home}/anttasks.jar">
3144 <fileset dir="${build.home}">
3145 <include name="org/greenstone/anttasks/**"/>
3146 </fileset>
3147 <manifest>
3148 <attribute name="Built-By" value="${user.name}" />
3149 </manifest>
3150 </jar>
3151 <copy file="${build.home}/anttasks.jar" todir="${basedir}/lib/java"/>-->
3152 <jar destfile="${build.home}/gsdl3test.jar">
3153 <fileset dir="${build.home}">
3154 <include name="org/greenstone/gsdl3/**/*Test.class"/>
3155 <include name="org/greenstone/testing/**"/>
3156 </fileset>
3157 <manifest>
3158 <attribute name="Built-By" value="${user.name}" />
3159 </manifest>
3160 </jar>
3161 <jar destfile="${build.home}/server.jar">
3162 <fileset dir="${build.home}">
3163 <include name="org/greenstone/server/**"/>
3164 <include name="org/greenstone/util/**"/>
3165 </fileset>
3166 <fileset file="${basedir}/resources/java/server.properties"/>
3167 <manifest>
3168 <attribute name="Built-By" value="${user.name}"/>
3169 </manifest>
3170 </jar>
3171 <copy file="${build.home}/server.jar" todir="${basedir}"/>
3172 </target>
3173
3174 <!-- === Eclipse targets == -->
3175 <target name="setup-for-eclipse">
3176
3177 <filter token="gsdlhome" value="${gs2build.home}"/>
3178 <filter token="gsdl3srchome" value="${basedir}"/>
3179 <filter token="gsdl3home" value="${basedir}/web"/>
3180
3181 <if>
3182 <bool><not><available file="${basedir}/TransformingLibrary.launch"/></not></bool>
3183 <copy file="${basedir}/TransformingLibrary.launch.in" tofile="${basedir}/TransformingLibrary.launch" filtering="true" overwrite="true"/>
3184 </if>
3185<!--
3186 <if>
3187 <bool><not><available file="${basedir}/LibraryCommandline.launch"/></not></bool>
3188 <copy file="${basedir}/LibraryCommandline.launch.in" tofile="${basedir}/LibraryCommandline.launch" filtering="true" overwrite="true"/>
3189 </if>
3190-->
3191 </target>
3192
3193 <!-- ================== Packages targets ================================ -->
3194 <!-- these targets refer to the greenstone source packages - these need
3195 updating less often, so are in separate targets to the core -->
3196 <target name="prepare-packages" depends="init"/>
3197
3198 <target name="update-packages" depends="init,svnupdate-packages,configure-packages,clean-packages,compile-packages"
3199 description="Update only the source packages"/>
3200
3201 <target name="svnupdate-packages" unless="nosvn.mode">
3202 <exec executable="svn">
3203 <arg value="update"/>
3204 <arg value="${src.packages.home}"/>
3205 <arg value="-r"/><arg value="${branch.revision}"/>
3206 </exec>
3207 </target>
3208
3209
3210 <target name="configure-packages" depends="init,configure-javagdbm"
3211 description="Configure only the packages."/>
3212
3213 <target name="configure-javagdbm" if="with.jni">
3214 <echo>
3215 Configuring JavaGDBM
3216 </echo>
3217
3218 <exec executable="${javagdbm.home}/configure" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
3219 <arg value="--prefix=${basedir}"/>
3220 <arg value="--libdir=${lib.jni}"/>
3221 <arg value="--with-gdbm=${gdbm.home}"/>
3222 <arg line="${cross.configure.args}"/>
3223 </exec>
3224 </target>
3225
3226 <target name="clean-packages" depends="init,clean-javagdbm" description="Clean only the packages"/>
3227
3228 <target name="clean-javagdbm" depends="init">
3229 <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
3230 <exec executable="make" os="${os.unix}"
3231 dir="${javagdbm.home}" failonerror="true">
3232 <arg value="clean"/>
3233 </exec>
3234 </if>
3235 </target>
3236
3237 <target name="distclean-packages" depends="init,distclean-javagdbm" description="Distclean only the packages"/>
3238
3239 <target name="distclean-javagdbm" depends="init">
3240 <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
3241 <exec executable="make" os="${os.unix}"
3242 dir="${javagdbm.home}" failonerror="true">
3243 <arg value="distclean"/>
3244 </exec>
3245 </if>
3246 </target>
3247
3248 <target name="compile-packages" description="Compile only the source packages">
3249 <!-- javagdbm -->
3250 <antcall target="compile-javagdbm"/>
3251 <!-- Search4j -->
3252 <antcall target="compile-search4j"/>
3253 </target>
3254
3255 <target name="compile-javagdbm" description="Compile JavaGDBM" if="with.jni">
3256
3257 <!-- unix: -->
3258 <echo>compile javagdbm</echo>
3259 <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
3260 <arg value="JAVACOPTIONS=-encoding UTF8"/>
3261 </exec>
3262 <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
3263 <arg value="install"/>
3264 </exec>
3265
3266 <!-- windows: Calling without the "compile" argument first will run winMake.bat with
3267 "all" which will then perform both the compile AND link targets in jni/win32.mak
3268 (thereby also generating gdbmjava.dll). Then we run the same command with
3269 the "install" argument to copy the gdbmjava.dll into the correct location. -->
3270 <echo>Windows: compile javagdbm</echo>
3271 <exec executable="${javagdbm.home}/winMake.bat" osfamily="windows" dir="${javagdbm.home}" failonerror="true">
3272 <env key="GSDL3SRCHOME" path="${basedir}"/>
3273 </exec>
3274 <exec executable="${javagdbm.home}/winMake.bat" osfamily="windows" dir="${javagdbm.home}" failonerror="true">
3275 <env key="GSDL3SRCHOME" path="${basedir}"/>
3276 <arg value="install"/>
3277 </exec>
3278
3279 <!-- install the jar file -->
3280 <echo>Install the javagdbm jar file ${javagdbm.home}/javagdbm.jar ${lib.jni}</echo>
3281 <copy file="${javagdbm.home}/javagdbm.jar" todir="${lib.jni}"/>
3282 </target>
3283
3284 <target name="compile-search4j">
3285
3286 <!-- windows -->
3287 <if><bool><istrue value="${current.os.iswindows}"/></bool>
3288 <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
3289 <arg value="/f"/>
3290 <arg value="win32.mak"/>
3291 <arg value='BINDIR="${basedir}\bin"'/>
3292 </exec>
3293 <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
3294 <arg value="/f"/>
3295 <arg value="win32.mak"/>
3296 <arg value="install"/>
3297 <arg value='BINDIR="${basedir}\bin"'/>
3298 </exec>
3299
3300 <!-- unix -->
3301 <else><if><bool><istrue value="${current.os.isunix}"/></bool>
3302 <exec executable="${src.packages.home}/search4j/configure" dir="${src.packages.home}/search4j" failonerror="true">
3303 <arg value="--bindir=${basedir}/bin"/>
3304 <arg value="${static.arg}"/>
3305 <arg line="${cross.configure.args}"/>
3306 </exec>
3307 <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true"/>
3308 <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true">
3309 <arg value="install"/>
3310 </exec>
3311
3312 <!-- else warn -->
3313 <else>
3314 <fail>this target does not support the current os</fail>
3315
3316 </else></if></else></if>
3317
3318 </target>
3319
3320 <target name="install-auxiliary-jar-files" depends="init">
3321
3322 <if>
3323 <bool><available file="${mg.home}/mg.jar"/></bool>
3324 <copy file="${mg.home}/mg.jar" todir="${lib.jni}"/>
3325 </if>
3326
3327 <if>
3328 <bool><available file="${mgpp.home}/mgpp.jar"/></bool>
3329 <copy file="${mgpp.home}/mgpp.jar" todir="${lib.jni}"/>
3330 </if>
3331
3332 <copy file="${lucene.home}/LuceneWrapper4.jar" todir="${web.lib}"/>
3333 </target>
3334
3335 <target name="install-jni-files" depends="init" if="with.jni">
3336 <antcall target="install-jni-files-linux"/>
3337 <antcall target="install-jni-files-windows"/>
3338 <antcall target="install-jni-files-macos"/>
3339 </target>
3340
3341 <target name="install-jni-files-linux" depends="init" if="current.os.isunixnotmac">
3342
3343 <if>
3344
3345 <bool><equals arg1="${os.bin.dir}" arg2="windows"/></bool>
3346 <!-- cross compiling to windows -->
3347 <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
3348 <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
3349 <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
3350 <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
3351 <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
3352 <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
3353
3354 <else>
3355 <!-- otherwise do the usual Unix copies -->
3356 <copy file="${mg.home}/jni/libmgretrievejni.so" todir="${lib.jni}"/>
3357 <copy file="${mg.home}/jni/libmgsearchjni.so" todir="${lib.jni}"/>
3358 <copy file="${mg.home}/jni/libmgpassjni.so" todir="${lib.jni}"/>
3359 <copy file="${mgpp.home}/jni/libmgppretrievejni.so" todir="${lib.jni}"/>
3360 <copy file="${mgpp.home}/jni/libmgppsearchjni.so" todir="${lib.jni}"/>
3361 <copy file="${mgpp.home}/jni/libmgpppassjni.so" todir="${lib.jni}"/>
3362 </else>
3363 </if>
3364
3365
3366 </target>
3367 <target name="install-jni-files-windows" depends="init" if="current.os.iswindows">
3368 <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
3369 <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
3370 <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
3371 <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
3372 <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
3373 <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
3374 </target>
3375 <target name="install-jni-files-macos" depends="init" if="current.os.ismac">
3376 <copy file="${mg.home}/jni/libmgretrievejni.jnilib" todir="${lib.jni}"/>
3377 <copy file="${mg.home}/jni/libmgsearchjni.jnilib" todir="${lib.jni}"/>
3378 <copy file="${mg.home}/jni/libmgpassjni.jnilib" todir="${lib.jni}"/>
3379 <copy file="${mgpp.home}/jni/libmgppretrievejni.jnilib" todir="${lib.jni}"/>
3380 <copy file="${mgpp.home}/jni/libmgppsearchjni.jnilib" todir="${lib.jni}"/>
3381 <copy file="${mgpp.home}/jni/libmgpppassjni.jnilib" todir="${lib.jni}"/>
3382 </target>
3383
3384 <!-- ========common-src targets =================================-->
3385 <!-- these are used to get common-src (for indexers, gdbm, sqlite etc) when
3386 collection building is not enabled -->
3387
3388 <target name="update-common-src" depends="init" if="collection.building.disabled">
3389 </target>
3390
3391 <target name="svnupdate-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
3392 <exec executable="svn">
3393 <arg value="update"/>
3394 <arg value="${common.src.home}"/>
3395 <arg value="-r"/><arg value="${branch.revision}"/>
3396 </exec>
3397 </target>
3398
3399 <target name="prepare-common-src" depends="init" if="collection.building.disabled" unless="common.src.present">
3400 <antcall target="checkout-common-src"/>
3401 <antcall target="unzip-windows-packages"/>
3402 </target>
3403
3404 <target name="checkout-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
3405 <echo>checking out common-src</echo>
3406 <exec executable="svn">
3407 <arg value="checkout"/>
3408 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src"/>
3409 <arg value="common-src"/>
3410 <arg value="-r"/><arg value="${branch.revision}"/>
3411 </exec>
3412 </target>
3413
3414 <target name="configure-common-src" depends="init">
3415<!--
3416 <echo>cross configure args: ${cross.configure.args}</echo>
3417-->
3418 <exec executable="${common.src.home}/configure" os="${os.unix}"
3419 dir="${common.src.home}" failonerror="true">
3420 <arg value="--prefix=${gs2build.home}"/> <!-- what value to use?? -->
3421 <arg value="--bindir=${gs2build.home}/bin/${os.bin.dir}"/> <!-- what value to use?? -->
3422 <arg line="${gs2.opt.args}"/>
3423 <arg line="${static.arg}"/>
3424 <arg line="${cross.configure.args}"/>
3425 <arg line="${allargs}"/>
3426 </exec>
3427 </target>
3428
3429 <target name="clean-common-src" depends="init">
3430 <!-- unix: -->
3431 <if><bool><available file="${common.src.home}/Makefile"/></bool>
3432 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
3433 <arg value="clean"/>
3434 </exec>
3435 </if>
3436 <!-- windows: -->
3437 <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
3438 <arg value="/f"/>
3439 <arg value="win32.mak"/>
3440 <arg value="clean"/>
3441 <arg value="GSDLHOME=${gs2build.home}"/>
3442 </exec>
3443 </target>
3444 <target name="distclean-common-src" depends="init">
3445 <!-- unix: -->
3446 <if><bool><available file="${common.src.home}/Makefile"/></bool>
3447 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
3448 <arg value="distclean"/>
3449 </exec>
3450 </if>
3451 <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->
3452 <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
3453 <arg value="/f"/>
3454 <arg value="win32.mak"/>
3455 <arg value="clean"/>
3456 <arg value="GSDLHOME=${gs2build.home}"/>
3457 </exec>
3458 </target>
3459 <target name="compile-common-src" depends="init">
3460 <!-- unix: -->
3461 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
3462 <arg value="${gs2.compile.target}"/>
3463 </exec>
3464 <!-- windows: -->
3465 <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
3466 <arg value="/f"/>
3467 <arg value="win32.mak"/>
3468 <arg value="GSDLHOME=${gs2build.home}"/>
3469 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
3470 <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
3471 <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
3472 <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
3473 <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
3474 </exec>
3475 </target>
3476
3477 <!-- ======= collection-building targets ===========================-->
3478
3479 <target name="update-collection-building" if="collection.building.enabled"
3480 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"
3481 description="Update (SVN update, configure, compile etc) only the collection building components"/>
3482
3483 <target name="svnupdate-collection-building" if="collection.building.enabled" depends="init,svnupdate-gs2build,svnupdate-cgi,svnupdate-gli" unless="nosvn.mode"
3484 description="SVN update the collection building components">
3485 </target>
3486
3487 <target name="prepare-collection-building" depends="init,prepare-gs2build,svnupdate-cgi,prepare-gli" if="collection.building.enabled">
3488 </target>
3489
3490 <target name="configure-collection-building" depends="init,configure-build-src" if="collection.building.enabled"
3491 description="Configure the collection building components">
3492 </target>
3493
3494 <target name="clean-collection-building" depends="init,clean-gli,clean-build-src"
3495 description="Clean only the collection building components"
3496 if="collection.building.enabled"/>
3497
3498 <target name="distclean-collection-building" depends="init,clean-build-src,distclean-build-src"
3499 description="Distclean only the collection building components"
3500 if="collection.building.enabled"/>
3501
3502 <target name="compile-collection-building" depends="init,compile-build-src,compile-gli" if="collection.building.enabled"
3503 description="Compile only the collection building components">
3504 <!-- make install for common-src -->
3505 <!-- unix: -->
3506 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
3507 <arg value="${gs2.install.target}"/>
3508 </exec>
3509
3510 <!-- windows: -->
3511 <exec executable="nmake" dir="${common.src.home}" osfamily="windows" failonerror="true">
3512 <arg value="/f"/>
3513 <arg value="win32.mak"/>
3514 <arg value="install"/>
3515 <arg value="GSDLHOME=${gs2build.home}"/>
3516 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
3517 <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
3518 <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
3519 <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
3520 <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
3521 <!--
3522 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
3523 <arg value="USE_SQLITE=0"/>--> <!-- why is this not on by default? -->
3524 </exec>
3525
3526 <!-- install gs2build indexers for windows -->
3527 <if>
3528 <bool><istrue value="${current.os.iswindows}"/></bool>
3529 <copy todir="${gs2build.home}/bin/windows">
3530 <fileset dir="${gs2build.home}/common-src/indexers/bin">
3531 <include name="*.*"/>
3532 </fileset>
3533 </copy>
3534 </if>
3535
3536 <!-- LuceneWrapper jar file not installed by default -->
3537 <mkdir dir="${gs2build.home}/bin/java"/>
3538 <copy file="${lucene.home}/LuceneWrapper4.jar" todir="${gs2build.home}/bin/java"/>
3539
3540 </target>
3541
3542 <!-- ============== gli targets ================================= -->
3543
3544 <!-- gliserver.pl, gsdlCGI.pm, metadata-server.pl and checksum.pl are updated alongside
3545 this in target svnupdate-collection-building -->
3546 <target name="svnupdate-gli" if="collection.building.enabled" depends="init" unless="nosvn.mode">
3547
3548 <exec executable="svn">
3549 <arg value="update"/>
3550 <arg value="${gli.home}"/>
3551 <arg value="-r"/><arg value="${branch.revision}"/>
3552 </exec>
3553
3554 </target>
3555
3556 <!-- gliserver.pl, gsdlCGI.pm, metadata-server.pl and checksum.pl are updated
3557 alongside this prepare-gli target in target prepare-collection-building -->
3558 <target name="prepare-gli" depends="init" if="collection.building.enabled" unless="gli.present">
3559 <!-- checkout -->
3560 <if><bool><and><not><istrue value="${nosvn.mode}"/></not><isset property="with.gli.and.gems"/></and></bool>
3561
3562 <exec executable="svn">
3563 <arg value="checkout"/>
3564 <arg value="${svn.root}/main/${branch.path}/gli"/>
3565 <arg value="-r"/><arg value="${branch.revision}"/>
3566 </exec>
3567
3568 </if>
3569 </target>
3570
3571 <!-- svn checkout gliserver.pl, gsdlCGI.pm for gli applet, as well as gsdlCGI.pm-dependent metadata-server.pl
3572 (checksum.pl is used by GS2 for depositdspace.dm and may eventually be used by GS3 too) -->
3573 <target name="svnupdate-cgi">
3574
3575 <exec executable="svn" dir="web/WEB-INF/cgi">
3576 <arg value="export"/>
3577 <arg value="-r"/><arg value="${branch.revision}"/>
3578 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/gliserver.pl"/>
3579 </exec>
3580 <exec executable="svn" dir="web/WEB-INF/cgi">
3581 <arg value="export"/>
3582 <arg value="-r"/><arg value="${branch.revision}"/>
3583 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/gsdlCGI.pm"/>
3584 </exec>
3585 <exec executable="svn" dir="web/WEB-INF/cgi">
3586 <arg value="export"/>
3587 <arg value="-r"/><arg value="${branch.revision}"/>
3588 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/metadata-server.pl"/>
3589 </exec>
3590 <exec executable="svn" dir="web/WEB-INF/cgi">
3591 <arg value="export"/>
3592 <arg value="-r"/><arg value="${branch.revision}"/>
3593 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/checksum.pl"/>
3594 </exec>
3595 </target>
3596
3597
3598 <target name="clean-gli" depends="init" if="collection.building.enabled">
3599 <!-- gli -->
3600 <property name="gli.home" value="${basedir}/gli"/>
3601 <!-- linux -->
3602 <exec executable="clean.sh" os="${os.unix}" dir="${gli.home}"
3603 resolveExecutable="true" failonerror="true"/>
3604 <!-- windows -->
3605 <exec executable="clean.bat" osfamily="windows" dir="${gli.home}"
3606 resolveExecutable="true" failonerror="true"/>
3607 </target>
3608
3609 <target name="compile-gli" depends="init" if="collection.building.enabled">
3610 <if><bool><isset property="with.gli.and.gems"/></bool>
3611 <!-- gli -->
3612 <property name="gli.home" value="${basedir}/gli"/>
3613
3614 <!-- linux -->
3615 <exec executable="makegli.sh" os="${os.unix}" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
3616 <!--remote gli-->
3617 <exec executable="makejar.sh" os="${os.unix}" dir="${gli.home}"
3618 resolveExecutable="true" failonerror="true"/>
3619 <!-- windows -->
3620 <exec executable="makegli.bat" osfamily="windows" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
3621 <!--remote gli-->
3622 <exec executable="makejar.bat" osfamily="windows" dir="${gli.home}"
3623 resolveExecutable="true" failonerror="true"/>
3624 <copy file="${gli.home}/GLIServer.jar" todir="${gs2build.home}/bin/java" />
3625 </if>
3626 </target>
3627
3628 <target name="gli" description="Run the Greenstone Librarian Interface" depends="init" if="collection.building.enabled">
3629 <exec executable="${basedir}/gli/gli.sh" os="${os.linux},${os.solaris}" dir="${basedir}/gli" spawn="true">
3630 <env key="gsdl3path" path="${basedir}"/>
3631 <env key="gsdlpath" path="${gs2build.home}"/>
3632 </exec>
3633 <exec executable="${basedir}/gli/gli.sh" os="${os.mac}" dir="${basedir}/gli" spawn="true">
3634 <env key="gsdl3path" path="${basedir}"/>
3635 <env key="gsdlpath" path="${gs2build.home}"/>
3636 <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${gdbm.home}/lib"/>
3637 </exec>
3638 <exec executable="${basedir}/gli/gli.bat" osfamily="windows" dir="${basedir}/gli" spawn="true">
3639 <env key="GSDL3PATH" path="${basedir}"/>
3640 <env key="GSDLPATH" path="${gs2build.home}"/>
3641 </exec>
3642 <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.
3643 </echo>
3644 </target>
3645
3646 <!-- ================ gs2build targets =========================== -->
3647
3648 <target name="svnupdate-gs2build" if="collection.building.enabled" depends="init" unless="nosvn.mode">
3649 <echo>svn updating gs2build</echo>
3650 <exec executable="svn">
3651 <arg value="update"/>
3652 <arg value="${gs2build.home}"/>
3653 <arg value="-r"/><arg value="${branch.revision}"/>
3654 </exec>
3655 </target>
3656
3657 <target name="prepare-gs2build" depends="init" if="collection.building.enabled" unless="gs2build.present">
3658 <antcall target="checkout-gs2build"/>
3659 <antcall target="prepare-pdfbox"/>
3660 <antcall target="prepare-imagemagick"/> <!-- has to be done before calling prepare-gnome-lib -->
3661 <antcall target="prepare-gnome-lib"/>
3662 <antcall target="unzip-windows-packages"/>
3663 <antcall target="checkout-winbin"/>
3664 <antcall target="get-windows-binaries"/>
3665 <antcall target="delete-winbin"/>
3666 </target>
3667
3668 <target name="checkout-gs2build" depends="init" if="collection.building.enabled" unless="nosvn.mode">
3669 <echo>checking out gs2build</echo>
3670 <exec executable="svn">
3671 <arg value="checkout"/>
3672 <arg value="${svn.root}/main/${branch.path}/gs2build"/>
3673 <arg value="-r"/><arg value="${branch.revision}"/>
3674 </exec>
3675 </target>
3676
3677 <!-- Gets the PDFBox extension into gs2build/ext if checkout.pdfbox.ext is set to true in build.properties
3678 (which it is by default) -->
3679 <target name="prepare-pdfbox" depends="init" if="collection.building.enabled">
3680 <if>
3681 <bool>
3682 <istrue value="${checkout.pdfbox.ext}"/>
3683 </bool>
3684
3685 <property name="pdfbox.ext.dir" value="${gs2build.home}/ext/pdf-box"/>
3686 <condition property="pdfbox.ext.present">
3687 <available file="${pdfbox.ext.dir}" type="dir" />
3688 </condition>
3689
3690 <!-- 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-->
3691 <if>
3692 <bool>
3693 <not><istrue value="${pdfbox.ext.present}"/></not>
3694 </bool>
3695
3696 <if>
3697 <bool>
3698 <not><istrue value="${gs2build.home}/ext/pdf-box-java.tar.gz"/></not>
3699 </bool>
3700
3701 <echo>Checking out the PDFBox extension into the GSDLHOME extension area</echo>
3702 <exec executable="svn">
3703 <arg value="export"/>
3704 <arg value="${svn.root}/gs2-extensions/pdf-box/trunk/pdf-box-java.tar.gz"/>
3705 <arg value="${gs2build.home}/ext/pdf-box-java.tar.gz"/>
3706 </exec>
3707 </if>
3708
3709 <echo>Extacting the PDFBox extension into the GSDLHOME extension area</echo>
3710 <untar compression="gzip"
3711 src="${gs2build.home}/ext/pdf-box-java.tar.gz"
3712 dest="${gs2build.home}/ext"/>
3713
3714 <delete file="${gs2build.home}/ext/pdf-box-java.tar.gz"/>
3715
3716 <else>
3717 <echo>The PDFBox extension already exists at ${pdfbox.ext.dir}</echo>
3718 </else>
3719 </if>
3720
3721 <else>
3722 <echo>**** Not preparing the PDFBox extension:</echo>
3723 <echo>The property checkout.pdfbox.ext in build.properties was not set or was set to false</echo>
3724 </else>
3725 </if>
3726 </target>
3727
3728 <target name="prepare-imagemagick" depends="init" if="collection.building.enabled">
3729 <if>
3730 <bool>
3731 <istrue value="${checkout.imagemagick.ext}"/>
3732 </bool>
3733
3734 <antcall target="checkout-imagemagick"/>
3735 <!--Compilation of imagemagick now happens during ant install, still before configuring the src code, as before -->
3736
3737 <else>
3738 <echo>**** Not preparing imagemagick:</echo>
3739 <echo>property checkout.imagemagick.ext in build.properties was not set or was set to false</echo>
3740 </else>
3741 </if>
3742 </target>
3743
3744 <target name="checkout-imagemagick" depends="init" if="collection.building.enabled" unless="nosvn.mode">
3745
3746 <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
3747 <condition property="imagemagick.src.present">
3748 <available file="${imagemagick.src.dir}" type="dir" />
3749 </condition>
3750
3751 <if>
3752 <bool>
3753 <not><istrue value="${imagemagick.src.present}"/></not>
3754 </bool>
3755
3756 <echo>checking out imagemagick source into the extension area</echo>
3757
3758 <exec executable="svn">
3759 <arg value="checkout"/>
3760 <arg value="${svn.root}/gs2-extensions/imagemagick/trunk/src"/>
3761 <arg value="${imagemagick.src.dir}"/>
3762 </exec>
3763
3764 <else>
3765 <echo>imagemagick source code already exists at ${imagemagick.src.dir}</echo>
3766 </else>
3767 </if>
3768 </target>
3769
3770 <!-- 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. -->
3771 <target name="compile-imagemagick" if="checkout.imagemagick.ext">
3772
3773 <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
3774 <property name="imagemagick.compiled.dir" value="${gs2build.home}/ext/imagemagick/${os.bin.dir}"/>
3775
3776 <condition property="imagemagick.src.present.firstcheck">
3777 <available file="${imagemagick.src.dir}" type="dir" />
3778 </condition>
3779 <condition property="imagemagick.compiled.present">
3780 <available file="${imagemagick.compiled.dir}" type="dir"/>
3781 </condition>
3782 <!--<condition property="imagemagick.bin.present">
3783 <available file="${basedir}/wherever/the/imgmagick/binary/is/to/be/found" type="dir" />
3784 </condition>-->
3785
3786 <!-- imagemagick will only be checked out if the user set the checkout.imagemagick.ext in build.properties -->
3787 <if>
3788 <bool>
3789 <isfalse value="${imagemagick.src.present.firstcheck}"/>
3790 </bool>
3791 <antcall target="checkout-imagemagick"/>
3792 </if>
3793
3794 <!-- keep track of whether the imagemagick src is now indeed present. Need to know this for a subsequent test -->
3795 <condition property="imagemagick.src.present">
3796 <available file="${imagemagick.src.dir}" type="dir" />
3797 </condition>
3798
3799 <if>
3800 <bool>
3801 <and>
3802 <istrue value="${imagemagick.src.present}"/> <!-- imagemagick src code is present -->
3803 <isfalse value="${imagemagick.compiled.present}"/> <!-- imagemagick src not compiled yet, so no imagemagick/os subfolder yet -->
3804 </and>
3805 </bool>
3806 <!-- then compile it. Only necessary for mac/linux, since windows has a stable working binary of imagemagick -->
3807 <exec executable="/bin/bash" dir="${imagemagick.src.dir}" failonerror="true">
3808 <arg value="CASCADE-MAKE.sh"/>
3809 </exec>
3810 </if>
3811 </target>
3812
3813
3814 <!-- Compile up gnome-lib src folder if: checkout.gnomelib.ext is turned on, and if not using the binary
3815 version (gnome-lib-minimal), and if the gnome-lib src folder is not already compiled up. -->
3816 <target name="compile-gnome-lib" if="checkout.gnomelib.ext">
3817
3818 <!-- http://stackoverflow.com/questions/3290307/sourcing-a-shell-profile-in-an-ant-build-file
3819 TODO: CASCADE-MAKE already sources devel.bash, but we still want to source it more globally,
3820 so that the rest of the GS3 compilation process also has access to those env variables -->
3821
3822 <property name="gnome.lib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
3823 <property name="gnome.lib.compiled.dir" value="${basedir}/gs2build/ext/gnome-lib/${os.bin.dir}"/>
3824
3825 <condition property="gnome.src.lib.present.firstcheck" value="true" else="false">
3826 <available file="${gnome.lib.src.dir}" type="dir" />
3827 </condition>
3828 <condition property="gnome.compiled.lib.present" value="true" else="false">
3829 <available file="${gnome.lib.compiled.dir}" type="dir"/>
3830 </condition>
3831 <condition property="gnome.lib.min.present" value="true" else="false">
3832 <available file="${basedir}/gs2build/ext/gnome-lib-minimal" type="dir" />
3833 </condition>
3834
3835 <!-- Make sure to checkout gnome-lib if it was not checked out at this stage
3836 since we're instructed to do so in th pre-condition to this target -->
3837 <if>
3838 <bool>
3839 <and>
3840 <isfalse value="${gnome.lib.min.present}"/>
3841 <isfalse value="${gnome.src.lib.present.firstcheck}"/>
3842 </and>
3843 </bool>
3844 <antcall target="checkout-gnome-lib"/>
3845 </if>
3846
3847 <!-- Keep track of whether we have the gnome-lib src folder now. Need to know this for a subsequent test -->
3848 <condition property="gnome.src.lib.present" value="true" else="false">
3849 <available file="${gnome.lib.src.dir}" type="dir" />
3850 </condition>
3851
3852 <!--<echo>MIN: ${gnome.lib.min.present}
3853 SRC LIB: ${gnome.src.lib.present}
3854 COMPILED: ${gnome.compiled.lib.present}</echo>-->
3855
3856 <if>
3857 <bool>
3858 <and>
3859 <isfalse value="${gnome.lib.min.present}"/> <!-- no gnome-lib-minimal binary present -->
3860 <istrue value="${gnome.src.lib.present}"/> <!-- gnome-lib folder for compilation is present-->
3861 <isfalse value="${gnome.compiled.lib.present}"/> <!-- gnome-lib not yet compiled, so no gnome-lib/os subfolder yet -->
3862 </and>
3863 </bool>
3864
3865 <!-- then compile it. Only necessary for mac/linux, since windows doesn't need gnome lib -->
3866 <exec executable="/bin/bash" dir="${gnome.lib.src.dir}" failonerror="true">
3867 <arg value="CASCADE-MAKE.sh"/>
3868 </exec>
3869 </if>
3870 </target>
3871
3872
3873 <target name="prepare-gnome-lib" depends="init" if="collection.building.enabled" unless="gnome-lib.present">
3874 <if>
3875 <bool>
3876 <istrue value="${checkout.gnomelib.ext}"/>
3877 </bool>
3878
3879 <antcall target="checkout-gnome-lib"/>
3880 <!--Compilation of gnome-lib happens during ant install, just before configuring (common-src and) build-src-->
3881
3882 <else>
3883 <echo>**** Not preparing gnome-lib:</echo>
3884 <echo>property checkout.gnomelib.ext in build.properties was not set or was set to false</echo>
3885 </else>
3886 </if>
3887 </target>
3888
3889
3890 <target name="checkout-gnome-lib" depends="init" if="collection.building.enabled" unless="nosvn.mode">
3891
3892 <property name="gnomelib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
3893 <condition property="gnome.src.present">
3894 <available file="${gnomelib.src.dir}" type="dir" />
3895 </condition>
3896
3897 <if>
3898 <bool>
3899 <not><istrue value="${gnome.src.present}"/></not>
3900 </bool>
3901
3902 <echo>checking out gnome-lib extension</echo>
3903 <exec executable="svn">
3904 <arg value="checkout"/>
3905 <arg value="${svn.root}/gs2-extensions/gnome-lib/trunk/src"/>
3906 <arg value="${gs2build.home}/ext/gnome-lib"/>
3907 </exec>
3908
3909 <else>
3910 <echo>gnomelib source code already exists at ${gnomelib.src.dir}</echo>
3911 </else>
3912 </if>
3913
3914 </target>
3915
3916 <target name="checkout-winbin" depends="init" if="current.os.iswindows"
3917 unless="nosvn.mode">
3918
3919 <exec executable="svn">
3920 <arg value="checkout"/>
3921 <arg value="${svn.root}/main/${branch.path}/binaries/windows"/>
3922 <arg value="-r"/><arg value="${branch.revision}"/>
3923 <arg value="winbin"/>
3924 </exec>
3925
3926 </target>
3927
3928 <target name="update-winbin" depends="init" if="current.os.iswindows" unless="nosvn.mode">
3929 <exec executable="svn">
3930 <arg value="update"/>
3931 <arg value="winbin"/>
3932 <arg value="-r"/><arg value="${branch.revision}"/>
3933 </exec>
3934
3935 </target>
3936
3937 <target name="get-windows-binaries" depends="init" if="collection.building.enabled.windows">
3938 <move todir="${gs2build.home}/bin/windows" failonerror="false">
3939 <fileset dir="${basedir}/winbin/bin"/>
3940 </move>
3941 </target>
3942
3943 <target name="delete-winbin" depends="init" if="collection.building.enabled.windows">
3944 <delete dir="${basedir}/winbin"/>
3945 </target>
3946
3947 <target name="unzip-windows-packages" depends="init" if="current.os.iswindows">
3948 <unzip src="${common.src.home}/packages/windows/crypt/crypt.zip"
3949 dest="${common.src.home}/packages/windows/crypt"/>
3950 <untar compression="gzip"
3951 src="${common.src.home}/packages/sqlite/${sqlite.targz.version}"
3952 dest="${common.src.home}/packages/sqlite"/>
3953 <unzip src="${common.src.home}/indexers/packages/windows/iconv/iconv.zip"
3954 dest="${common.src.home}/indexers/packages/windows/iconv"/>
3955 </target>
3956
3957 <target name="gs2build-edit-setup-bat" if="collection.building.enabled.windows">
3958 <!-- we want a windows path in the setup.bat file -->
3959 <pathconvert targetos="windows" property="gs2build.home.windows">
3960 <path path="${gs2build.home}"/>
3961 </pathconvert>
3962 <move file="${gs2build.home}/setup.bat" tofile="${gs2build.home}/setup-tmp.bat">
3963 <filterset>
3964 <filter token="gsdlhome" value="${gs2build.home.windows}"/>
3965 </filterset>
3966 </move>
3967 <move file="${gs2build.home}/setup-tmp.bat" tofile="${gs2build.home}/setup.bat" />
3968 </target>
3969
3970
3971 <target name="clean-build-src" depends="init" if="collection.building.enabled">
3972 <!-- unix: -->
3973 <if><bool><available file="${build.src.home}/Makefile"/></bool>
3974 <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
3975 <arg value="clean"/>
3976 </exec>
3977 </if>
3978 <!-- windows: -->
3979 <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
3980 <arg value="/f"/>
3981 <arg value="win32.mak"/>
3982 <arg value="clean"/>
3983 <arg value="GSDLHOME=${gs2build.home}"/>
3984 </exec>
3985 </target>
3986
3987
3988 <target name="distclean-build-src" depends="init,clean-build-src" if="collection.building.enabled">
3989 <!-- unix: -->
3990 <if><bool><available file="${build.src.home}/Makefile"/></bool>
3991 <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
3992 <arg value="distclean"/>
3993 </exec>
3994 </if>
3995 <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->
3996 <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
3997 <arg value="/f"/>
3998 <arg value="win32.mak"/>
3999 <arg value="clean"/>
4000 <arg value="GSDLHOME=${gs2build.home}"/>
4001 </exec>
4002 </target>
4003
4004 <target name="configure-build-src" depends="init" if="collection.building.enabled"
4005 description="Configure the build-src component">
4006 <exec executable="${build.src.home}/configure" os="${os.unix}"
4007 dir="${build.src.home}" failonerror="true">
4008 <arg value="--prefix=${gs2build.home}"/>
4009 <arg line="${gs2.opt.args} ${static.arg} ${cross.configure.args} ${allargs}"/>
4010 </exec>
4011 </target>
4012
4013 <!-- common-src is done separately and needs to be compiled first -->
4014 <target name="compile-build-src" depends="init" if="collection.building.enabled">
4015
4016 <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
4017 <arg line="${ldlpath.arg}"/>
4018 </exec>
4019
4020 <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
4021 <env key="GSDLOS" value="${os.bin.dir}"/>
4022 <arg value="install"/>
4023 </exec>
4024
4025 <!-- run the setup script -->
4026 <!-- <exec executable="${compile.windows.c++.setup}" osfamily="windows" failonerror="true"/>-->
4027 <!--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-->
4028 <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
4029 <arg value="/f"/>
4030 <arg value="win32.mak"/>
4031 <arg value="GSDLHOME=${gs2build.home}"/>
4032 </exec>
4033 <exec executable="nmake" dir="${build.src.home}" osfamily="windows" failonerror="true">
4034 <arg value="/f"/>
4035 <arg value="win32.mak"/>
4036 <arg value="install"/>
4037 <arg value="GSDLHOME=${gs2build.home}"/>
4038 </exec>
4039 </target>
4040
4041
4042 <!-- ======================== TESTING Targets ========================= -->
4043
4044 <target name="test" description="Run the (incomplete) JUnit test suite "
4045 depends="init">
4046 <mkdir dir="${basedir}/test"/>
4047 <junit printsummary="withOutAndErr"
4048 errorproperty="test.failed"
4049 failureproperty="test.failed"
4050 fork="${junit.fork}">
4051 <formatter type="plain"/>
4052 <classpath>
4053 <pathelement location="${build.home}/gsdl3test.jar"/>
4054 <path refid="compile.classpath"/>
4055 </classpath>
4056 <test name="${testcase}" if="testcase"/>
4057 <batchtest todir="${basedir}/test" unless="testcase">
4058 <fileset dir="${build.home}" includes="**/*Test.class" />
4059 </batchtest>
4060 </junit>
4061 <echo>
4062 *********************************************
4063 Test output can be found in directory 'test'
4064 *********************************************
4065 </echo>
4066 </target>
4067
4068 <!-- ======================== FLAX Targets ========================= -->
4069 <target name="prepare-flax" description="check out flax source code from another repository" if="install.flax">
4070 <echo>checking out flax ...</echo>
4071 <mkdir dir="${basedir}/src/java/org/flax"/>
4072 <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/flax"/>
4073 <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/action/flax"/>
4074 <mkdir dir="${web.home}/WEB-INF/classes/flax"/>
4075 <mkdir dir="${web.home}/interfaces/flax"/>
4076 <mkdir dir="${web.home}/sites/flax"/>
4077 <mkdir dir="${basedir}/flax-resources"/>
4078 <mkdir dir="${basedir}/flax-lib"/>
4079 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/flax"/>
4080 <arg value="src/java/org/flax"/></exec>
4081 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/flax"/>
4082 <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
4083 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/action/flax"/>
4084 <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
4085 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/WEB-INF/classes/flax"/>
4086 <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
4087 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/interfaces/flax"/>
4088 <arg value="${web.home}/interfaces/flax"/></exec>
4089 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/sites/flax"/>
4090 <arg value="${web.home}/sites/flax"/></exec>
4091 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/flax-resources"/>
4092 <arg value="flax-resources"/></exec>
4093 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/lib"/>
4094 <arg value="flax-lib"/></exec>
4095 <antcall target="flax-copy-del-files" />
4096 </target>
4097
4098 <target name="flax-copy-del-files" description="copy some flax files into the appropriate greenstone3 directories and delete some unwanted greenstone stuff">
4099 <copy file="${web.home}/WEB-INF/classes/flax/web.xml" todir="${web.home}/WEB-INF" overwrite="true" />
4100 <copy todir="${web.home}/WEB-INF/lib">
4101 <fileset dir="${basedir}/flax-lib">
4102 <include name="*.jar"/>
4103 </fileset>
4104 </copy>
4105 <!--<delete dir="${web.home}/sites/gateway"/>
4106 <delete dir="${web.home}/sites/localsite"/>-->
4107 </target>
4108
4109 <target name="update-flax" description="update flax from repository">
4110 <echo>updating flax ...</echo>
4111 <exec executable="svn"><arg value="update"/>
4112 <arg value="src/java/org/flax"/></exec>
4113 <exec executable="svn"><arg value="update"/>
4114 <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
4115 <exec executable="svn"><arg value="update"/>
4116 <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
4117 <exec executable="svn"><arg value="update"/>
4118 <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
4119 <exec executable="svn"><arg value="update"/>
4120 <arg value="${web.home}/interfaces/flax"/></exec>
4121 <exec executable="svn"><arg value="update"/>
4122 <arg value="${web.home}/web/sites/flax"/></exec>
4123 <exec executable="svn"><arg value="update"/>
4124 <arg value="flax-resources"/></exec>
4125 <exec executable="svn"><arg value="update"/>
4126 <arg value="flax-lib"/></exec>
4127 <antcall target="compile-core" />
4128 </target>
4129
4130 <!-- ========================End of FLAX Targets ========================= -->
4131
4132 <target name="compile-javadocs">
4133 <javadoc packagenames="org.greenstone.*"
4134 sourcepath="src/java"
4135 defaultexcludes="yes"
4136 destdir="docs/javadoc"
4137 author="true"
4138 version="true"
4139 use="true"
4140 windowtitle="Greenstone3 API">
4141 <doctitle><![CDATA[<h1>Greenstone3 API</h1>]]></doctitle>
4142 </javadoc>
4143 </target>
4144
4145<!-- ========== Some distribution targets ======================== -->
4146 <target name="remove-source">
4147 <if><bool><isset property="with.gli.and.gems"/></bool>
4148 <delete includeEmptyDirs="true">
4149 <fileset dir="." defaultexcludes="false">
4150 <patternset refid="greenstone3.source.component"/>
4151 </fileset>
4152 </delete>
4153
4154 <else>
4155 <delete includeEmptyDirs="true">
4156 <fileset dir="." defaultexcludes="false">
4157 <patternset refid="greenstone3.source.no.gli.component"/>
4158 </fileset>
4159 </delete>
4160 </else>
4161 </if>
4162 </target>
4163
4164 <target name="dist-tidy"
4165 description="'tidies-up' a greenstone3 installation for distribution."
4166 unless="${properties.keep.src}">
4167
4168 <!-- delete unneeded things -->
4169 <delete dir="${packages.home}/axis"/>
4170 <delete><fileset dir="${packages.home}" includes="*.zip"/></delete>
4171 <delete file="README-SVN.txt"/>
4172 <delete file="build.properties.svn"/>
4173
4174 <!-- delete source files -->
4175 <antcall target="remove-source"/>
4176
4177 <!-- create empty directories -->
4178 <mkdir dir="${web.writablehome}/applet"/>
4179 <mkdir dir="${web.writablehome}/logs"/>
4180 <mkdir dir="${web.writablehome}/logs/tmp"/>
4181
4182 <!-- Lines with ***** are commented out because these files are useful if we want hybrid installations -->
4183
4184 <!-- os specific tidy-ups -->
4185 <!-- linux, mac -->
4186 <if><bool><istrue value="${current.os.isunix}"/></bool>
4187 <!--*****<delete><fileset dir="." includes="*.bat"/></delete>-->
4188 <if><bool><isset property="with.gli.and.gems"/></bool>
4189 <!--*****<delete><fileset dir="gli" includes="*.bat"/></delete>-->
4190 </if>
4191 <!--*****<delete><fileset dir="gs2build" includes="*.bat"/></delete>-->
4192 <!--*****<delete><fileset dir="bin/script" includes="*.bat"/></delete>-->
4193 <delete file="${basedir}/gs2build/win32cfg.h"/>
4194 <delete file="${basedir}/gs2build/win32.mak"/>
4195 <delete dir="${basedir}/winutil"/>
4196 <delete failonerror="false"><fileset dir="${lib.jni}" includes="*.dll"/></delete>
4197
4198 <!-- windows -->
4199 <else><if><bool><istrue value="${current.os.iswindows}"/></bool>
4200 <!--*****<delete><fileset dir="." includes="*.sh,*.bash,*.csh"/></delete>-->
4201 <if><bool><isset property="with.gli.and.gems"/></bool>
4202 <!--*****<delete><fileset dir="gli" includes="*.sh,*.bash,*.csh"/></delete>-->
4203 </if>
4204 <!--*****<delete><fileset dir="gs2build" includes="*.sh,*.bash,*.csh"/></delete>-->
4205 <!--*****<delete><fileset dir="bin/script" includes="*.sh,*.bash,*.csh"/></delete>-->
4206 </if></else></if>
4207
4208 </target>
4209
4210 <!-- fix up executable permissions for binary release -->
4211 <target name="fix-execute-permissions">
4212 <echo>Setting binaries to executable</echo>
4213 <chmod perm="775">
4214 <fileset dir="."><patternset refid="greenstone3.executables"/></fileset>
4215 </chmod>
4216 </target>
4217
4218 <!-- fix up executable permissions for source code release -->
4219 <target name="fix-execute-permissions-source">
4220 <chmod perm="775">
4221 <fileset dir="."><patternset refid="greenstone3.source.executables"/></fileset>
4222 </chmod>
4223 </target>
4224
4225 <!-- for macs, set up the .app shortcuts to gsi, gli, client-gli and gems -->
4226 <target name="gen-mac-shortcuts">
4227 <if><bool><istrue value="${current.os.ismac}"/></bool>
4228 <filter token="gsdl3srchome" value="${basedir}"/>
4229 <copy file="${basedir}/gs3-server.app/Contents/document.wflow.in" tofile="${basedir}/gs3-server.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4230 <copy file="${basedir}/gli.app/Contents/document.wflow.in" tofile="${basedir}/gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4231 <copy file="${basedir}/client-gli.app/Contents/document.wflow.in" tofile="${basedir}/client-gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4232 <copy file="${basedir}/gems.app/Contents/document.wflow.in" tofile="${basedir}/gems.app/Contents/document.wflow" filtering="true" overwrite="true"/>
4233 </if>
4234 </target>
4235
4236 <!-- ============= tweaks for making compilation static ========== -->
4237 <target name="tweak-makefiles" depends="init" if="compile.static">
4238 <antcall target="rtftohtml-add-static" />
4239 </target>
4240
4241 <target name="rtftohtml-add-static" depends="init" if="collection.building.enabled">
4242 <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" />
4243 </target>
4244
4245 <target name="run-collection-tests">
4246 <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
4247 <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>
4248 </if>
4249 <for param="testjar">
4250 <path>
4251 <fileset dir="${basedir}" includes="web/sites/*/collect/*/tests/tests.jar"/>
4252 </path>
4253 <sequential>
4254 <echo>Testing @{testjar}</echo>
4255 <java classname="org.junit.runner.JUnitCore" fork="true">
4256 <!--https://stackoverflow.com/questions/38676719/selenium-using-java-the-path-to-the-driver-executable-must-be-set-by-the-webdr-->
4257 <sysproperty key="webdriver.gecko.driver" path="${basedir}/ext/testing/geckodriver"/>
4258 <arg value="gstests.TestClass"/>
4259 <jvmarg value="-DSERVERURL=${default.server.protocol}://${tomcat.server}:${default.tomcat.port}${app.path}${server.default.servlet} "/>
4260 <classpath>
4261 <fileset dir="${basedir}/ext/testing/lib/java">
4262 <include name="*.jar"/>
4263 </fileset>
4264 <files includes="@{testjar}"/>
4265 </classpath>
4266 </java>
4267 </sequential>
4268 </for>
4269 </target>
4270
4271 <target name="build-collection-tests">
4272 <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
4273 <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>
4274 </if>
4275 <for param="compiledir">
4276 <path>
4277 <dirset dir="${basedir}" includes="web/sites/*/collect/*/tests/src"/>
4278 </path>
4279 <sequential>
4280 <echo>Compiling @{compiledir}</echo>
4281 <if><bool><not><available file="@{compiledir}/../build" type="dir"/></not></bool>
4282 <mkdir dir="@{compiledir}/../build"/>
4283 </if>
4284 <javac
4285 srcdir="@{compiledir}"
4286 destdir="@{compiledir}/../build"
4287 includeantruntime="${compile.includeantruntime}"
4288 debug="${compile.debug}"
4289 deprecation="${compile.deprecation}"
4290 optimize="${compile.optimize}"
4291 encoding="${compile.encoding}">
4292 <classpath>
4293 <fileset dir="${basedir}/ext/testing/lib/java">
4294 <include name="*.jar"/>
4295 </fileset>
4296 </classpath>
4297 <include name="gstests/*.java"/>
4298 </javac>
4299 <jar destfile="@{compiledir}/../tests.jar">
4300 <fileset dir="@{compiledir}/../build">
4301 <include name="gstests/**"/>
4302 </fileset>
4303 <manifest>
4304 <attribute name="Built-By" value="${user.name}" />
4305 </manifest>
4306 </jar>
4307 </sequential>
4308 </for>
4309 </target>
4310</project>
Note: See TracBrowser for help on using the repository browser.