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

Last change on this file since 32425 was 32425, checked in by ak19, 6 years ago

Forgot to do what Dr bainbridge had asked for: breadcrumb after ant install to indicate they can run ant setup-https-cert. Running that target will list the prerequisites.

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