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

Last change on this file since 32789 was 32789, checked in by Georgiy Litvinov, 5 years ago

Put clean target before configure. Otherwise there is no Makefile to build.

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