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

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

Some tidying up and using the recommended way to run ant exec tasks since we no longer need to echo values to the stdin of an exec task

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