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

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

HTTPS certification automation for Windows using ZeroSSL. 1. Comitting ZeroSSL win32 and win64 binaries with their PerlFoundation's Artistic License 2.0 licence. 2. build.xml has a windows target to automate the process and now branches to the right target depending on OS. No support yet for Mac will investigate whether there are other ACME clients like certbot for Mac in future. 3. When testing the final change (keystore.file name varies depending on OS), I unfortunately had used up the rate limits for this week's certification. Otherwise I had tested the target obtaining the https certificate on Windows several times. 4. Still need to add in optional test certification (the min-min-live parameter when dropped makes it obtain a test certificate.)

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