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

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

More fixes after testing https targets on a binary.

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