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

Last change on this file since 35374 was 35371, checked in by kjdon, 3 years ago

if we are targetting everything else to java 1.6, we should also do the same for the core greenstone java code

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