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

Last change on this file since 36879 was 36879, checked in by anupama, 16 months ago

GS3 shouldn't allow system commands to go through unless it's either from the same PC (IP) as the GS3 server machine (so cmdline building and activate.pl work), or the user is administrator, or the system command is a collection-level command and the user has permissions for this or all collections. If not the case, the user will be asked to login.

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