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

Last change on this file since 34326 was 34111, checked in by ak19, 4 years ago

Undoing additions surrounding JAVA_TOOL_OPTIONS where file.encoding is set to utf-9, after discussing with Kathy and Dr Bainbridge. We think it possible that the changes to XMLConverter.java that enforce utf-8 as the char-encoding for reading in files will also fix the last remaining locale issue which required the JAVA_TOOL_OPTIONS of file.encoding=utf-8 to be passed in. Will still need to ask Shaoqun, in case she has a Win machine in Chinese locale, to test 3.09 vs the caveat for 3.10 that will contain this final commit. But our win machine generating the win nightlies runs overnight and is not accesible remotely. So the earlierst that test can be done is tomorrow.

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