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

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