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

Last change on this file since 37380 was 37380, checked in by anupama, 14 months ago

Setting curl (mac uses this in place of wget) to ignoring expired https certificate.

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