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

Last change on this file since 35484 was 35459, checked in by davidb, 3 years ago

Adding in LIBDIR for Linux and Windows compiling of newly introduced search4j Java code

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