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

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

On windows, only pass in min-min-live for setting up https-certification if not in testing mode.

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