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

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

the lsb release kit environments can't connect to https greenstone.org as they don't support TLS1.2. I have copied all needed files (hopefully) over to community, so lets grab them from there instead.

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