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

Last change on this file since 32379 was 32379, checked in by Georgiy Litvinov, 3 years ago

Added solr context to global properties.

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