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

Last change on this file since 36320 was 36129, checked in by kjdon, 2 years ago

because greenstone3.xml (if you are using the latest one from svn) uses GoogleSigninJDBCRealm whether we have enabled googlesignin or not (if no google sign in it defaults to old authentication method), I have removed all the tests for googlesignin enabled in build.xml - we always want to regenerate the googlesignin realm jar file

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