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

Last change on this file since 37020 was 37020, checked in by anupama, 17 months ago

New ant target unpack-cgimodule called during ant install command, that on a Unix system for perl >= 5.22 will unpack the common-src/cgi-bin/CGIModule.tar.gz into web/WEB-INF/cgi

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