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

Last change on this file since 36502 was 36502, checked in by davidb, 20 months ago

Splicing in of catalina opts that allow for webswing-server.war to be run. Only added in if war file detected

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