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

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