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

Last change on this file since 32429 was 32429, checked in by ak19, 6 years ago

solr should only be accessible locally (from localhost, specifically 127.0.0.1) which means over http. This conflicted with the previous design of the properties file for working with http and/or https. Now we have tomcat.port.https and localhost.port.http, both always set. In place of server.protocol that used to contain the default protocol, we now have server.protocols which can be set to a comma separated list of one or both of http and https. Drastic restructuring followed. I think I've tested all but https certification stuff.

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