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

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

The isfalse test in ant surrounding the http testing mode works as expected. Having tried it out, it's now confirmed that you just uncomment the https.test.mode property OR set its value to false if not testing. Need to explicitly set this value to true if you want testing to happen. Added a message to indicate how to change the property depending on the behaviour you want.

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