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

Last change on this file since 27859 was 27859, checked in by ak19, 8 years ago

Bugfix. On Windows, when GLI launches the GS3server, the perl path found is env.PERLPATH since GLI uses findperl.bat to locate the path to perl bin. By the time the ant target perl-for-building determines the perl path, env.PERLPATH needs to have a slash appended at the end, else the path to perl appears as binperl instead of bin\perl in packages\tomcat\conf\web.xml, and then metadata edited with the online meta editor don't get saved since the metadata-server.pl script can't find perl. This is not a problem if the GS3 server is not launched through GLI, since ant target perl-for-building goes into another branch of its logic to locate perlpath.

File size: 125.2 KB
Line 
1<?xml version="1.0"?>
2<!-- ======================================================================
3 March 2005
4
5 Greenstone3 build and install script
6
7 kjdon
8 ====================================================================== -->
9<project name="greenstone3" default="usage" basedir=".">
10 <echo>os.name: ${os.name}</echo>
11
12 <!-- ============ classpath =================== -->
13 <path id="project.classpath">
14 <fileset dir="lib/java">
15 <include name="**/*.jar"/>
16 </fileset>
17 </path>
18
19 <!-- ============ self defined tasks =================== -->
20 <taskdef name="mysetproxy" classname="org.greenstone.anttasks.MySetProxy" classpathref="project.classpath"/>
21 <taskdef name="getuserandpassword" classname="org.greenstone.anttasks.MyGetUserAndPassword" classpathref="project.classpath"/>
22 <taskdef name="rsr" classname="org.greenstone.anttasks.RegexSearchReplace" classpathref="project.classpath"/>
23 <!--<taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" classpathref="project.classpath"/>-->
24 <taskdef name="if" classname="ise.antelope.tasks.IfTask" classpathref="project.classpath"/>
25 <taskdef name="for" classname="net.sf.antcontrib.logic.ForTask" classpathref="project.classpath"/>
26 <taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask" classpathref="project.classpath"/>
27
28
29 <!-- ===================== Property Definitions =========================== -->
30
31 <!--
32
33 Each of the following properties are used in the build script.
34 Values for these properties are set by the first place they are
35 defined, from the following list:
36
37 * Definitions on the "ant" command line (ant -Dfoo=bar compile).
38
39 * Definitions from a "build.properties" file in the top level
40 source directory of this application.
41
42 * Definitions from a "build.properties" file in the user's
43 home directory.
44
45 * Default definitions in this build.xml file.
46
47 You will note below that property values can be composed based on the
48 contents of previously defined properties. This is a powerful technique
49 that helps you minimize the number of changes required when your development
50 environment is modified. Note that property composition is allowed within
51 "build.properties" files as well as in the "build.xml" script.
52
53 -->
54
55 <property name="os.linux" value="Linux"/>
56 <property name="os.mac" value="Mac OS X"/>
57 <property name="os.solaris" value="SunOS"/>
58 <property name="os.unix" value="${os.linux},${os.mac},${os.solaris}"/>
59 <property name="os.windows" value="Windows 95,Windows 98,Windows 2000,Windows 2003,Windows XP,Windows NT,Windows ME,Windows Vista,Windows 7"/> <!-- check this!!!-->
60
61 <!-- this is true for linux and macs -->
62 <condition property="current.os.isunix">
63 <os family="unix"/>
64 </condition>
65
66 <condition property="current.os.isunixnotmac">
67 <and>
68 <os family="unix"/>
69 <not>
70 <os family="mac"/>
71 </not>
72 </and>
73 </condition>
74
75 <condition property="current.os.ismac">
76 <os family="mac"/>
77 </condition>
78
79 <condition property="current.os.iswindows">
80 <os family="windows"/>
81 </condition>
82
83 <!-- create build.properties if it has not been created yet -->
84 <if>
85 <bool><not><available file="build.properties"/></not></bool>
86 <copy file="build.properties.in" tofile="build.properties"/>
87 </if>
88
89 <!-- create the packages dir if it has not been created yet -->
90 <mkdir dir="packages"/>
91
92 <!--the first three properties have to be put on the top to be used by build.properties-->
93 <property name="gs2build.home" value="${basedir}${file.separator}gs2build"/>
94 <property name="src.packages.home" value="${basedir}/src/packages"/>
95 <property name="flax.svn.root" value="http://svn.greenstone.org/flax"/>
96
97 <property file="build.properties"/>
98 <if><bool><available file="${user.home}/build.properties"/></bool>
99 <property file="${user.home}/build.properties"/>
100 </if>
101
102 <!-- now we've read in properties, apply defaults -->
103 <property name="disable.collection.building" value="false"/>
104
105 <!-- get properties from the environment -->
106 <property environment="env"/>
107
108 <!-- get the filesets defining components and executables -->
109 <import file="resources/xml/components.xml"/>
110 <import file="resources/xml/executables.xml"/>
111
112 <!-- version properties for external packages -->
113 <!-- for Java versions < 1.4, we print out the message that Java is too old.
114 For Java 1.4, we use Tomcat 5.5, for Java5 and higher, we use Tomcat 7.0-->
115 <condition property="tomcat.version" value="apache-tomcat-5.5.25" else="apache-tomcat-7.0.26">
116 <equals arg1="1.4" arg2="${ant.java.version}"/>
117 </condition>
118 <condition property="tomcat.version.major" value="5" else="7">
119 <equals arg1="1.4" arg2="${ant.java.version}"/>
120 </condition>
121 <condition property="privileged.attribute" value="privileged='true'" else="">
122 <equals arg1="7" arg2="${tomcat.version.major}"/>
123 </condition>
124
125 <property name="axis.zip.version" value="axis-bin-1_4.zip"/>
126 <property name="axis.dir.version" value="axis-1_4"/>
127 <property name="sqlite.targz.version" value="sqlite-autoconf-3070602.tar.gz"/>
128
129 <property name="build.home" value="${basedir}/build"/>
130 <property name="src.home" value="${basedir}/src/java"/>
131
132 <if><bool><istrue value="${gsdl3home.isreadonly}"/></bool>
133 <property name="readonly-packages.home" value="${basedir}/packages"/>
134 <property name="packages.home" value="${gsdl3.writablehome}/packages"/>
135 <else>
136 <property name="packages.home" value="${basedir}/packages"/>
137 </else>
138 </if>
139
140 <!-- this may be set in build.properties, e.g. if you move the web dir to
141 tomcats webapps directory -->
142 <property name="web.home" value="${basedir}/web"/>
143 <property name="web.writablehome" value="${gsdl3.writablehome}"/>
144
145 <!-- jar files needed by applets go here -->
146 <property name="web.applet" value="${web.home}/applet"/>
147
148 <!-- jar files needed by the servlet (and extra ones) go here -->
149 <property name="web.lib" value="${web.home}/WEB-INF/lib"/>
150 <property name="web.writablelib" value="${web.writablehome}/WEB-INF/lib"/>
151 <!-- other files needed by the servlet go here -->
152 <property name="web.classes" value="${web.home}/WEB-INF/classes"/>
153 <property name="web.writableclasses" value="${web.writablehome}/WEB-INF/classes"/>
154
155 <if>
156 <bool><istrue value="${gsdl3home.isreadonly}"/></bool>
157 <echo>Greenstone3 home directory is read-only</echo>
158 <echo> => Writable area is: ${gsdl3.writablehome}</echo>
159
160 <condition property="gsdl3.writablehome.already-exists">
161 <available file="${gsdl3.writablehome}" type="dir"/>
162 </condition>
163
164 <if>
165 <bool><not><istrue value="${gsdl3.writablehome.already-exists}"/></not></bool>
166
167 <!-- set up writable area -->
168 <echo>No previous Greenstone home writable area detected</echo>
169 <echo> => Setting up area</echo>
170 <mkdir dir="${gsdl3.writablehome}"/>
171 <mkdir dir="${gsdl3.writablehome}/packages"/>
172 <mkdir dir="${gsdl3.writablehome}/logs"/>
173
174 <chmod perm="a+rwx" dir="${gsdl3.writablehome}"/>
175 <chmod perm="a+rwx" dir="${gsdl3.writablehome}/packages"/>
176 <chmod perm="a+rwx" dir="${gsdl3.writablehome}/logs"/>
177
178 <!-- copy over packages tomcat folder -->
179
180 <if>
181 <bool><istrue value="${current.os.iswindows}"/></bool>
182 <copy todir="${gsdl3.writablehome}/packages/tomcat"
183 preservelastmodified="true"
184 failonerror="true" >
185 <fileset dir="${readonly-packages.home}/tomcat" includes="**"/>
186 </copy>
187
188 <else>
189 <!-- else assume Unix -->
190 <!-- Can't go through the OS-independant <copy> task as it fails to preserve exec permissions -->
191 <echo>Copying to ${gsdl3.writablehome}/packages/tomcat</echo>
192 <exec executable="cp" output="/dev/null" spawn="false">
193 <arg value="-r"/>
194 <arg value="${readonly-packages.home}/tomcat"/>
195 <arg value="${gsdl3.writablehome}/packages/."/>
196 </exec>
197
198 </else>
199 </if>
200
201 <echo> => Copying Greenstone's web/WEB-INF to writable area</echo>
202 <copy todir="${gsdl3.writablehome}/WEB-INF"
203 preservelastmodified="true"
204 failonerror="true" >
205 <fileset dir="${web.home}/WEB-INF" includes="**"/>
206 </copy>
207
208 <copy todir="${gsdl3.writablehome}"
209 preservelastmodified="true"
210 failonerror="true" >
211 <fileset dir="${web.home}" includes="index.html"/>
212 </copy>
213
214 </if>
215 </if>
216
217
218 <!--- flax: the WordNet home -->
219 <property name="wn.home" value="${web.home}/WEB-INF/classes/flax/WordNet"/>
220
221 <!-- jni libraries and java wrappers go here -->
222 <property name="lib.jni" value="${basedir}/lib/jni"/>
223
224 <!-- other jar files needed for installation (but not runtime) go here -->
225 <property name="lib.java" value="${basedir}/lib/java"/>
226
227 <property name="javadocs" value="${basedir}/docs/javadoc"/>
228
229 <property name="app.name" value="greenstone3"/>
230 <property name="app.path" value="/${app.name}"/>
231
232 <property name="admin.dir" value="${basedir}/admin"/>
233
234 <!-- defaults - set these on the command line or in build.properties or
235 they will take these default values-->
236 <property name="app.version" value="trunk"/>
237 <property name="branch.path" value="trunk"/>
238 <property name="branch.revision" value="HEAD"/>
239
240 <!--constants -->
241 <property name="svn.root" value="http://svn.greenstone.org"/>
242
243 <!-- catalina home is set to tomcat basedir if already installed, otherwise
244 use greenstone's tomcat -->
245 <condition property="catalina.home" value="${tomcat.installed.path}" else="${packages.home}/tomcat">
246 <and>
247 <isset property="tomcat.installed.path"/>
248 <not>
249 <equals arg1="" arg2="${tomcat.installed.path}"/>
250 </not>
251 </and>
252 </condition>
253
254
255 <!-- is there a better way to do this?? what about solaris?? -->
256 <condition property="os.bin.dir" value="${cross.os}">
257 <istrue value="${compile.cross}"/>
258 </condition>
259 <condition property="os.bin.dir" value="windows">
260 <os family="windows"/>
261 </condition>
262 <condition property="os.bin.dir" value="darwin">
263 <os family="mac"/>
264 </condition>
265 <condition property="os.bin.dir" value="linux">
266 <and>
267 <os family="unix"/>
268 <not>
269 <os family="mac"/>
270 </not>
271 </and>
272 </condition>
273
274
275 <condition property="collection.building.disabled">
276 <and>
277 <isset property="disable.collection.building"/>
278 <istrue value="${disable.collection.building}"/>
279 </and>
280 </condition>
281
282 <condition property="collection.building.enabled">
283 <not>
284 <istrue value="${disable.collection.building}"/>
285 </not>
286 </condition>
287
288 <condition property="collection.building.enabled.windows">
289 <and>
290 <istrue value="${collection.building.enabled}"/>
291 <isset property="current.os.iswindows"/>
292 </and>
293 </condition>
294
295 <condition property="collection.building.enabled.unix">
296 <and>
297 <istrue value="${collection.building.enabled}"/>
298 <isset property="current.os.isunix"/>
299 </and>
300 </condition>
301
302 <condition property="static.arg" value="LDFLAGS=-static" else=" ">
303 <isset property="compile.static"/>
304 </condition>
305
306 <!-- If building a release then we want to adjust environment variables so that the support library can be seen during compilation -->
307 <if><bool><isset property="use.gnomelib.ext"/></bool>
308 <property name="gnome-lib-dir" value="${basedir}/ext/gnome-lib-minimal/${os.bin.dir}"/>
309
310 <if><bool><isset property="env.CFLAGS"/></bool>
311 <property name="cflags.arg" value="CFLAGS=&quot;-I${gnome-lib-dir}/include ${env.CFLAGS}&quot;"/>
312 <else>
313 <property name="cflags.arg" value="CFLAGS=&quot;-I${gnome-lib-dir}/include&quot;"/>
314 </else>
315 </if>
316
317 <if><bool><isset property="env.CPPFLAGS"/></bool>
318 <property name="cppflags.arg" value="CPPFLAGS=&quot;-I${gnome-lib-dir}/include ${env.CPPFLAGS}&quot;"/>
319 <else>
320 <property name="cppflags.arg" value="CPPFLAGS=&quot;-I${gnome-lib-dir}/include&quot;"/>
321 </else>
322 </if>
323
324 <if><bool><isset property="env.CXXFLAGS"/></bool>
325 <property name="cxxflags.arg" value="CXXFLAGS=&quot;-I${gnome-lib-dir}/include ${env.CXXFLAGS}&quot;"/>
326 <else>
327 <property name="cxxflags.arg" value="CXXFLAGS=&quot;-I${gnome-lib-dir}/include&quot;"/>
328 </else>
329 </if>
330
331 <if><bool><isset property="env.LDFLAGS"/></bool>
332 <property name="ldflags.arg" value="LDFLAGS=&quot;-L${gnome-lib-dir}/lib ${env.LDFLAGS}&quot;"/>
333 <else>
334 <property name="ldflags.arg" value="LDFLAGS=&quot;-L${gnome-lib-dir}/lib&quot;"/>
335 </else>
336 </if>
337
338 <if><bool><isset property="env.PATH"/></bool>
339 <property name="path.arg" value="PATH=&quot;${gnome-lib-dir}/bin:${env.PATH}&quot;"/>
340 <else>
341 <property name="path.arg" value="PATH=&quot;${gnome-lib-dir}/bin&quot;"/>
342 </else>
343 </if>
344
345 <if><bool><isset property="env.PKG_CONFIG_PATH"/></bool>
346 <property name="pcpath.arg" value="PKG_CONFIG_PATH=&quot;${gnome-lib-dir}/lib/pkgconfig:${env.PKG_CONFIG_PATH}&quot;"/>
347 <else>
348 <property name="pcpath.arg" value="PKG_CONFIG_PATH=&quot;${gnome-lib-dir}/lib/pkgconfig&quot;"/>
349 </else>
350 </if>
351
352 <if><bool><equals arg1="${os.bin.dir}" arg2="darwin"/></bool>
353 <if><bool><isset property="env.DYLD_LIBRARY_PATH"/></bool>
354 <property name="ldlpath.arg" value="DYLD_LIBRARY_PATH=&quot;${gnome-lib-dir}/lib:${env.DYLD_LIBRARY_PATH}&quot;"/>
355 <else>
356 <property name="ldlpath.arg" value="DYLD_LIBRARY_PATH=&quot;${gnome-lib-dir}/lib&quot;"/>
357 </else>
358 </if>
359 <else>
360 <if><bool><isset property="env.LD_LIBRARY_PATH"/></bool>
361 <property name="ldlpath.arg" value="LD_LIBRARY_PATH=&quot;${gnome-lib-dir}/lib:${env.LD_LIBRARY_PATH}&quot;"/>
362 <else>
363 <property name="ldlpath.arg" value="LD_LIBRARY_PATH=&quot;${gnome-lib-dir}/lib&quot;"/>
364 </else>
365 </if>
366 </else>
367 </if>
368
369 <else>
370 <if><bool><isset property="env.CFLAGS"/></bool>
371 <property name="cflags.arg" value="CFLAGS=&quot;${env.CFLAGS}&quot;"/>
372 <else>
373 <property name="cflags.arg" value=" "/>
374 </else>
375 </if>
376
377 <if><bool><isset property="env.CPPFLAGS"/></bool>
378 <property name="cppflags.arg" value="CPPFLAGS=&quot;${env.CPPFLAGS}&quot;"/>
379 <else>
380 <property name="cppflags.arg" value=" "/>
381 </else>
382 </if>
383
384 <if><bool><isset property="env.CXXFLAGS"/></bool>
385 <property name="cxxflags.arg" value="CXXFLAGS=&quot;${env.CXXFLAGS}&quot;"/>
386 <else>
387 <property name="cxxflags.arg" value=" "/>
388 </else>
389 </if>
390
391 <if><bool><isset property="env.LDFLAGS"/></bool>
392 <property name="ldflags.arg" value="LDFLAGS=&quot;${env.LDFLAGS}&quot;"/>
393 <else>
394 <property name="ldflags.arg" value=" "/>
395 </else>
396 </if>
397
398 <if><bool><isset property="env.PATH"/></bool>
399 <property name="path.arg" value="PATH=&quot;${env.PATH}&quot;"/>
400 <else>
401 <property name="path.arg" value=" "/>
402 </else>
403 </if>
404
405 <if><bool><isset property="env.PKG_CONFIG_PATH"/></bool>
406 <property name="pcpath.arg" value="PKG_CONFIG_PATH=&quot;${env.PKG_CONFIG_PATH}&quot;"/>
407 <else>
408 <property name="pcpath.arg" value=" "/>
409 </else>
410 </if>
411
412 <if><bool><equals arg1="${os.bin.dir}" arg2="darwin"/></bool>
413 <if><bool><isset property="env.DYLD_LIBRARY_PATH"/></bool>
414 <property name="ldlpath.arg" value="DYLD_LIBRARY_PATH=&quot;${env.DYLD_LIBRARY_PATH}&quot;"/>
415 <else>
416 <property name="ldlpath.arg" value=" "/>
417 </else>
418 </if>
419 <else>
420 <if><bool><isset property="env.LD_LIBRARY_PATH"/></bool>
421 <property name="ldlpath.arg" value="LD_LIBRARY_PATH=&quot;${env.LD_LIBRARY_PATH}&quot;"/>
422 <else>
423 <property name="ldlpath.arg" value=" "/>
424 </else>
425 </if>
426 </else>
427 </if>
428 </else>
429 </if>
430 <property name="allargs" value="${cflags.arg} ${cxxflags.arg} ${cppflags.arg} ${ldflags.arg} ${path.arg} ${ldlpath.arg} ${pcpath.arg}"/>
431
432 <condition property="opt.cross.build"
433 value="--build=${cross.build}" else=" ">
434 <isset property="cross.build"/>
435 </condition>
436
437
438 <condition property="cross.configure.args"
439 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=" ">
440 <istrue value="${compile.cross}"/>
441 </condition>
442
443<!-- if you want to disable wvware, do so here: set the value (not else) field to contain minus-minus-disable-wvware -->
444 <condition property="gs2.opt.args" value=" " else="--disable-mg --disable-mgpp --disable-accentfold --disable-gdbm --disable-sqlite">
445 <istrue value="${with.jni}"/>
446 </condition>
447 <condition property="gs2.compile.target" value="with-jni" else="without-jni">
448 <istrue value="${with.jni}"/>
449 </condition>
450 <condition property="gs2.install.target" value="install-with-jni" else="install-without-jni">
451 <istrue value="${with.jni}"/>
452 </condition>
453 <condition property="gs2.windows.enablejni" value="1" else="0">
454 <istrue value="${with.jni}"/>
455 </condition>
456 <condition property="gs2.windows.enablemg" value="1" else="0">
457 <istrue value="${with.jni}"/>
458 </condition>
459 <condition property="gs2.windows.enablemgpp" value="1" else="0">
460 <istrue value="${with.jni}"/>
461 </condition>
462 <!-- Should accent folding not also be set here ?? -->
463 <condition property="gs2.windows.usegdbm" value="1" else="0">
464 <istrue value="${with.jni}"/>
465 </condition>
466 <condition property="gs2.windows.usesqlite" value="1" else="0">
467 <istrue value="${with.jni}"/>
468 </condition>
469
470 <!-- where is search4j tool -->
471 <condition property="search4j.exec" value="bin/search4j.exe" else="bin/search4j">
472 <isset property="current.os.iswindows"/>
473 </condition>
474
475
476 <!-- ============= Base dirs for each package and component ============ -->
477 <property name="src.gsdl3.home" value="${src.home}/org/greenstone/gsdl3"/>
478 <property name="anttasks.home" value="${src.home}/org/greenstone/anttasks"/>
479 <property name="gli.home" value="${basedir}/gli"/>
480 <property name="javagdbm.home" value="${src.packages.home}/javagdbm"/>
481
482 <condition property="common.src.home" value="${basedir}/common-src" else="${gs2build.home}${file.separator}common-src">
483 <istrue value="${disable.collection.building}"/>
484 </condition>
485
486 <property name="build.src.home" value="${gs2build.home}/build-src"/>
487 <property name="gdbm.home" value="${common.src.home}/packages/gdbm"/>
488 <property name="mg.home" value="${common.src.home}/indexers/mg"/>
489 <property name="mgpp.home" value="${common.src.home}/indexers/mgpp"/>
490 <property name="lucene.home" value="${common.src.home}/indexers/lucene-gs"/>
491
492 <!-- ==================== Compilation Control Options ==================== -->
493
494 <!--
495
496 These properties control option settings on the Javac compiler when it
497 is invoked using the <javac> task.
498
499 compile.debug Should compilation include the debug option?
500
501 compile.deprecation Should compilation include the deprecation option?
502
503 compile.optimize Should compilation include the optimize option?
504
505 -->
506
507 <property name="compile.debug" value="true"/>
508 <property name="compile.deprecation" value="true"/>
509 <property name="compile.optimize" value="true"/>
510
511 <!--
512
513 Rather than relying on the CLASSPATH environment variable, Ant includes
514 features that makes it easy to dynamically construct the classpath you
515 need for each compilation. The example below constructs the compile
516 classpath to include the servlet.jar file, as well as the other components
517 that Tomcat makes available to web applications automatically, plus anything
518 that you explicitly added.
519
520 -->
521
522 <!-- All elements that Tomcat 5 exposes to applications -->
523 <path id="tomcat5">
524 <pathelement location="${catalina.home}/common/classes"/>
525 <fileset dir="${catalina.home}/common/endorsed">
526 <include name="*.jar"/>
527 </fileset>
528 <fileset dir="${catalina.home}/common/lib">
529 <include name="*.jar"/>
530 </fileset>
531 <!-- seems to be empty, but will leave in just in case some people make use of this to customise their install: -->
532 <pathelement location="${catalina.home}/shared/classes"/>
533 <fileset dir="${catalina.home}/shared/lib">
534 <include name="*.jar"/>
535 </fileset>
536 </path>
537
538 <!-- All elements that Tomcat 7 exposes to applications -->
539 <path id="tomcat7">
540 <fileset dir="${catalina.home}/lib">
541 <include name="*.jar"/>
542 </fileset>
543 </path>
544
545 <path id="compile.classpath">
546 <!-- Include all jar files and libraries in our jni lib directory -->
547 <pathelement location="${lib.jni}"/>
548 <fileset dir="${lib.jni}">
549 <include name="*.jar"/>
550 </fileset>
551 <!-- Include all jar files in our web lib directory -->
552 <pathelement location="${web.lib}"/>
553 <fileset dir="${web.lib}">
554 <include name="*.jar"/>
555 </fileset>
556
557 <pathelement location="${lib.java}"/>
558 <fileset dir="${lib.java}">
559 <include name="*.jar"/>
560 </fileset>
561
562 <!-- include the jar files from the source packages -->
563 <!-- mg and mgpp get installed into lib/jni but they may not be there yet
564 so we add them in by name -->
565 <!-- *** is there any way to make this optional, based on ${with.jni}? -->
566 <pathelement location="${lib.jni}/mg.jar"/>
567 <pathelement location="${lib.jni}/mgpp.jar"/>
568
569 <!-- Include all elements that Tomcat exposes to applications -->
570 <path refid="tomcat${tomcat.version.major}"/>
571
572 </path>
573
574 <path id="local.tomcat.classpath">
575 <!-- explicitly include the jni java wrappers in the classpath -->
576 <pathelement location="${lib.jni}"/>
577 <fileset dir="${lib.jni}">
578 <include name="*.jar"/>
579 </fileset>
580
581 <pathelement location="${web.writablelib}"/>
582 <fileset dir="${web.writablelib}">
583 <include name="derby.jar"/>
584 </fileset>
585 </path>
586
587 <path id="local.tomcat.path">
588 <pathelement location="${basedir}/bin/script"/>
589 <pathelement location="${basedir}/bin"/>
590 <pathelement location="${lib.jni}"/>
591 <pathelement path="${env.PATH}"/>
592 <pathelement path="${env.Path}"/>
593 <pathelement path="${wn.home}/bin"/>
594 </path>
595
596 <target name="test-setup">
597 <echo>ant java version=${ant.java.version}</echo>
598 <echo>is unix : ${current.os.isunix}</echo>
599 <echo>is mac : ${current.os.ismac}</echo>
600 <echo>is unixnotmac : ${current.os.isunixnotmac}</echo>
601 <echo>is windows : ${current.os.iswindows}</echo>
602 <echo>os.unix: ${os.unix}</echo>
603 </target>
604
605 <!-- Appends the current env to the file environment.txt. For debugging env vars used by the release-kit. -->
606 <target name="write-env">
607 <echo message="*****************ENVIRONMENT OUTPUT:****************${line.separator}" file="environment.txt" append="true" />
608
609 <if><bool><istrue value="${current.os.iswindows}"/></bool>
610 <exec executable="set" dir="${basedir}" failonerror="false" output="environment.txt" append="true" />
611 <else>
612 <exec executable="env" dir="${basedir}" failonerror="false" output="environment.txt" append="true" />
613 </else>
614 </if>
615
616 <echo message="${line.separator}" file="environment.txt" append="true" />
617 </target>
618
619
620 <!-- ==================== Primary and Global Targets ============================= -->
621
622 <target name="prepare" depends="accept-properties,init,prepare-core,prepare-packages,prepare-common-src,prepare-collection-building,prepare-tomcat,prepare-axis,prepare-web,prepare-collections,prepare-solr-ext, prepare-flax"
623 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.">
624
625 <!-- make sure .sh files are executable -->
626 <chmod dir="${basedir}" perm="ugo+rx"
627 includes="*.sh"/>
628 <chmod dir="${basedir}/bin/script" perm="ugo+rx"
629 includes="*.sh,*.pl"/>
630
631 <!-- if the user has set checkout.gnomelib.ext to true, and is using a compiled version of gnome-lib
632 (it would have been compiled up by this stage), remind them to source devel.bash before compiling -->
633 <condition property="run.source.devel">
634 <available file="${basedir}/gs2build/ext/gnome-lib/${os.bin.dir}" type="dir"/>
635 </condition>
636 <if><bool>
637 <and>
638 <istrue value="${checkout.gnomelib.ext}"/>
639 <istrue value="${run.source.devel}"/>
640 </and>
641 </bool>
642<!-- This is automatically done now in the gs2build/common-src/packages/configure script if the
643 gnomelib.ext directory is detected
644
645 <echo>
646 *********************************************
647 As you have set checkout.gnomelib.ext,
648 before running ant install next,
649 run source devel.bash from
650 ${basedir}/gs2build/ext/gnome-lib
651 *********************************************</echo>
652-->
653 </if>
654 </target>
655
656 <!-- 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 -->
657 <target name="install" depends="init,install-common-src,install-collection-building,install-runtime,setup-for-eclipse"
658 description="Install Greenstone 3. Use this when you first checkout the code: 'ant prepare new-install'."/>
659
660 <target name="install-common-src" depends="init"
661 description="Install (configure, compile, install) only the common-src package (shared code from Greenstone 2). " >
662 <antcall target="configure-common-src"/>
663 <antcall target="compile-common-src"/>
664 <antcall target="install-auxiliary-jar-files"/>
665 <antcall target="install-jni-files"/>
666 </target>
667
668 <target name="install-collection-building" depends="init" if="collection.building.enabled"
669 description="Install (configure, compile, install) the Greenstone 2 collection building package." >
670 <antcall target="configure-collection-building"/>
671 <antcall target="tweak-makefiles" />
672 <antcall target="compile-collection-building"/>
673 </target>
674
675
676 <target name="install-runtime" depends="init,configure,configure-packages,configure-core,compile-web,compile-packages,compile-core,compile-classpath-jars"
677 description="Install (configure, compile, install) the runtime system. Needs either common-src or collection-building to have been installed first." />
678
679 <target name="svnupdate" depends="init,svnupdate-packages,svnupdate-core,svnupdate-common-src,svnupdate-collection-building,svnupdate-web"
680 description="Do a `svn update` for all sources. Doesn't recompile the code. You need to be online to run this."/>
681
682 <target name="configure" depends="init,configure-tomcat,configure-web"
683 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."/>
684
685 <target name="clean" depends="init,clean-packages,clean-core,clean-common-src,clean-collection-building,clean-classpath-jars"
686 description="Remove all old compiled code. Includes runtime and collection-building if necessary"/>
687
688 <target name="distclean" depends="init,distclean-packages,clean-core,distclean-common-src,distclean-collection-building,clean-classpath-jars"
689 description="Remove all compiled code and also any Makefiles etc generated during configure-c++. Includes runtime and collection-building as necessary"/>
690
691 <target name="update" depends="init,svnupdate,clean,install"
692 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'"/>
693
694
695 <target name="perl-for-building" depends="init">
696 <!-- uses perl.path if set in build.properties, otherwise try for
697 environment variable PERLPATH, and failing that assumes 'perl'
698 is on environment PATH -->
699 <!-- 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 -->
700 <if><bool><available file="${gs2build.home}"/></bool>
701
702 <if><bool><not><isset property="perl.path"/></not></bool>
703
704 <if>
705 <bool>
706 <and>
707 <isset property="env.PERLPATH"/>
708 <not><equals arg1="${env.PERLPATH}" arg2=""/></not>
709 </and>
710 </bool>
711 <!-- set perlpath to env.PERLPATH.
712 This is the path to perl\bin that's found by findperl.bat when the server is launched
713 through GLI instead of the console.
714 For windows, this env.PERLPATH is the bin folder and needs a backslash at end, since it
715 will appear suffixed with "perl.exe" in the perl setting in packages\tomcat\config\web.xml.
716 This web.xml's path to perl is then used to find perl when running the perl scripts in the
717 cgi folder, so without a slash appended at this point it becomes "binperl" in web.xml, and
718 things will break when GLI launches the server on Windows and the online GS3 metadata editor
719 is used to save user-edited metadata. -->
720 <if><bool><istrue value="${current.os.iswindows}"/></bool>
721 <property name="perl.path" value="${env.PERLPATH}\"/>
722 <else>
723 <property name="perl.path" value="${env.PERLPATH}"/>
724 </else>
725 </if>
726
727 <else>
728 <echo>
729 Using PATH environment variable to locate Perl.
730 </echo>
731 <exec executable="which" os="${os.unix}" spawn="false" outputproperty="full.perl.path">
732 <arg value="perl" />
733 </exec>
734
735 <exec executable="${gs2build.home}/bin/windows/which" os="${os.windows}" spawn="false" outputproperty="full.perl.path">
736 <arg value="perl" />
737 </exec>
738
739 <stringutil string="${full.perl.path}" property="partial.perl.path">
740 <replace regex="\/[^\/]*$" replacement="/" />
741 </stringutil>
742 <stringutil string="${partial.perl.path}" property="perl.path">
743 <replace regex="\\[^\\]*$" replacement="\\" />
744 </stringutil>
745 <if><bool><istrue value="${current.os.isunix}"/></bool>
746 <if><bool><not><equals arg1="${full.perl.path}" arg2="/usr/bin/perl"/></not></bool>
747 <echo>
748 Non-standard location of Perl found: ${full.perl.path}
749 Set the environment variable PERLPATH or the perl.path property in
750 build.properties to explicitly control the version of Perl used.
751 </echo>
752 </if>
753 </if>
754 </else>
755 </if>
756 </if>
757
758 <!-- full.perl.path is for pretty-printing only, e.g. used in target "start" -->
759 <if><bool><isset property="perl.path"/></bool>
760 <property name="full.perl.path" value="${perl.path}${file.separator}perl"/>
761 <else>
762 <property name="full.perl.path" value="perl (will use the enviroment variable PATH to find this executable)"/>
763 </else>
764 </if>
765
766 <!-- gs2build not available, perl.path -->
767 <else>
768 <property name="perl.path" value=""/>
769 </else>
770 </if>
771 <stringutil string="${perl.path}" property="escaped.perl.path">
772 <replace regex="\\" replacement="\\\\" />
773 </stringutil>
774 </target>
775
776 <target name="get-default-servlet-url">
777 <echo>http://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}</echo>
778 </target>
779
780 <target name="start" depends="init,configure-tomcat,configure-web,start-tomcat"
781 description="Startup the Tomcat server." >
782 <echo>${app.name} (${app.version}) server running using Apache Tomcat and Java</echo>
783 <echo>Tomcat: ${catalina.home}</echo>
784 <echo>Java : ${java.home}</echo>
785 <if><bool><available file="${build.src.home}"/></bool>
786 <echo>Perl : ${full.perl.path}</echo>
787 </if>
788 <if><bool><isset property="install.flax"/></bool>
789 <property name="url" value="http://${tomcat.server}:${tomcat.port}${app.path}/flax"/>
790 <else>
791 <property name="url" value="http://${tomcat.server}:${tomcat.port}${app.path}/"/>
792 </else>
793 </if>
794 <echo>URL : ${url}</echo>
795 <!-- assuming that index.html is not needed here -->
796
797 <!--Now write out the url with oaiserver suffix as the baseURL property in OAIConfig.xml-->
798 <available file="${web.classes}/OAIConfig.xml.in" property="oaiconfig.present"/>
799 <antcall target="init-oaiconfig">
800 <param name="url" value="${url}"/>
801 </antcall>
802 </target>
803
804 <target name="init-oaiconfig" if="oaiconfig.present">
805 <echo>Writing out baseURL ${url}oaiserver to ${web.writableclasses}/OAIConfig.xml</echo>
806 <copy file="${web.classes}/OAIConfig.xml.in" tofile="${web.writableclasses}/OAIConfig.xml"/>
807 <rsr file="${web.writableclasses}/OAIConfig.xml" pattern="&lt;baseURL&gt;.*&lt;/baseURL&gt;" replacement="&lt;baseURL&gt;${url}oaiserver&lt;/baseURL&gt;" />
808 </target>
809
810 <target name="stop" depends="init,stop-tomcat"
811 description="Shutdown the Tomcat server."/>
812
813 <target name="restart" description="Shutdown and restart Tomcat" depends="init,stop,start"/>
814
815 <!-- =========== Help targets =================================== -->
816
817 <property name="install-command" value="ant [options] prepare install"/>
818
819 <target name="usage" description="Print a help message">
820 <echo message=" Execute 'ant -projecthelp' for a list of targets."/>
821 <echo message=" Execute 'ant -help' for Ant help."/>
822 <echo>
823 To install Greenstone3, run '${install-command}'.
824 There are properties defined in build.properties. The install
825 process will ask you if these properties are set correctly.
826 To avoid this prompt, use the '-Dproperties.accepted=yes'
827 option.
828 To log the output, use the '-logfile build.log' option.
829 The README.txt file has more information about the ant targets
830 and install process.
831 </echo>
832 </target>
833
834 <target name="help" depends="usage" description="Print a help message"/>
835
836 <target name="debug" depends="init" description="Display all the currently used properties">
837 <echoproperties/>
838 </target>
839
840 <!-- ====== initialization and setup targets ================== -->
841
842 <target name="accept-properties" unless="properties.accepted">
843 <input addproperty="properties.ok" validargs="y,n">The following properties (among others) are being used from a build.properties file found in this directory:
844 tomcat.server=${tomcat.server}
845 tomcat.port=${tomcat.port}
846 tomcat.installed.path=${tomcat.installed.path} (this is the location of Tomcat's base dir if it is already installed)
847 proxy.host=${proxy.host}
848 proxy.port=${proxy.port}
849 disable.collection.building=${disable.collection.building}
850 If these are not acceptable, please change them and rerun this target. Continue [y/n]?
851 </input>
852 <condition property="do.abort">
853 <equals arg1="n" arg2="${properties.ok}"/>
854 </condition>
855 <fail if="do.abort">Build aborted by user. Please change your properties settings and re-run the target</fail>
856 </target>
857
858 <!-- this sets up some initial properties -->
859 <target name="init">
860
861 <!-- has the gs3-setup script been run?? -->
862 <condition property="gs3-setup-not-done">
863 <not>
864 <isset property="env.GSDL3HOME"/>
865 </not>
866 </condition>
867
868 <!--<fail if="gs3-setup-not-done" message="please run 'gs3-setup' (Windows) or 'source gs3-setup.sh' (Linux/Mac) before running this target."/>-->
869
870 <condition property="java.too.old">
871 <or>
872 <equals arg1="1.1" arg2="${ant.java.version}"/>
873 <equals arg1="1.2" arg2="${ant.java.version}"/>
874 <equals arg1="1.3" arg2="${ant.java.version}"/>
875 </or>
876 </condition>
877 <fail if="java.too.old" message="You need Java 1.4 or greater to run Greenstone 3"/>
878
879 <available file="${basedir}/gli" property="gli.present"/>
880 <available file="${basedir}/common-src" property="common.src.present"/>
881 <available file="${basedir}/gs2build" property="gs2build.present"/>
882 <available file="${gnome-lib-dir}" property="gnome-lib.present"/>
883
884 <condition property="tomcat.islocal">
885 <or>
886 <not><isset property="tomcat.installed.path"/></not>
887 <equals arg1="" arg2="${tomcat.installed.path}"/>
888 </or>
889 </condition>
890
891 <echo>tomcat.port = ${tomcat.port}</echo>
892
893 <condition property="proxy.present">
894 <and>
895 <isset property="proxy.host"/>
896 <not><equals arg1="" arg2="${proxy.host}"/></not>
897 </and>
898 </condition>
899
900 <!--
901 the next block checks if the bundled tomcat is present in the 'packages' directory,
902 and checks for the lethal combination of tomcat 7 and java 1.4. Test for
903 tomcat6 is based on the presence of a file inserted by greenstone into the tomcat6
904 download, as there is no other surefire way to check tomcat version under java 1.4
905 -->
906 <condition property="packages.tomcat.ispresent" value="true" else="false">
907 <available file="packages/tomcat"/>
908 </condition>
909 <condition property="packages.tomcat.istomcat7" value="true" else="false">
910 <available file="packages/tomcat/tomcat7.txt"/>
911 </condition>
912 <if>
913 <bool>
914 <and>
915 <istrue value="${packages.tomcat.ispresent}"/>
916 <istrue value="${packages.tomcat.istomcat7}"/>
917 <equals arg1="1.4" arg2="${ant.java.version}"/>
918 </and>
919 </bool>
920 <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>
921 </if>
922
923 </target>
924
925 <target name="setup-proxy" depends="init" if="proxy.present">
926 <condition property="ask.user">
927 <or>
928 <equals arg1="" arg2="${proxy.user}"/>
929 <equals arg1="" arg2="${proxy.password}"/>
930 </or>
931 </condition>
932
933 <getuserandpassword message="Using proxy: ${proxy.host}:${proxy.port}" if="ask.user" username="${proxy.user}" userproperty="proxy.username" pwordproperty="proxy.password"/>
934 <mysetproxy proxyhost="${proxy.host}" proxyport="${proxy.port}" proxyuser="${proxy.username}" proxypassword="${proxy.password}"/>
935 </target>
936
937 <!-- ========== Web app Targets ================================ -->
938
939 <target name="prepare-web" depends="init">
940 <mkdir dir="${web.writablehome}/applet"/>
941 <mkdir dir="${web.writablehome}/logs"/>
942 <mkdir dir="${web.writablehome}/logs/tmp"/>
943 </target>
944
945 <!-- 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.
946 The test for whether we need it assumes we won't be trying to compile GS3 against Java versions less than 1.4. -->
947 <target name="configure-java-version" depends="init"
948 description="Activates or deactivates some jar libraries as needed depending on your java version">
949
950 <available property="have.xalan.jar" file="${web.lib}/xalan.jar"/>
951 <condition property="need.xalan.jar">
952 <or>
953 <not><equals arg1="1.4" arg2="${ant.java.version}"/></not>
954 </or>
955 </condition>
956
957 <!-- if they have xalan.jar but dont need it -->
958 <if>
959 <bool>
960 <and>
961 <isset property="have.xalan.jar"/>
962 <not><isset property="need.xalan.jar"/></not>
963 </and>
964 </bool>
965 <antcall target="deactivate-xalan-jar"/>
966 </if>
967
968 <!-- if they need xalan.jar but dont have it -->
969 <if>
970 <bool>
971 <and>
972 <not><isset property="have.xalan.jar"/></not>
973 <isset property="need.xalan.jar"/>
974 </and>
975 </bool>
976 <antcall target="activate-xalan-jar"/>
977 </if>
978
979 </target>
980
981 <target name="activate-xalan-jar">
982 <echo>activating xalan.jar</echo>
983 <copy file="${web.lib}/xalan.jar.tmp" tofile="${web.lib}/xalan.jar"/>
984 <if>
985 <bool>
986 <and>
987 <isset property="current.os.ismac"/>
988 <available file="${catalina.home}/common/endorsed" type="dir"/>
989 </and>
990 </bool>
991 <copy file="${web.lib}/xalan.jar.tmp" tofile="${catalina.home}/common/endorsed/xalan.jar"/>
992 </if>
993 </target>
994
995 <target name="deactivate-xalan-jar">
996 <echo>deactivating xalan.jar</echo>
997 <delete file="${web.lib}/xalan.jar"/>
998 <!-- should we be deleting common/endorsed/xalan.jar on mac?? -->
999 </target>
1000
1001
1002 <target name="prepare-collections" depends="init"
1003 description="Unpack all the collections from their svn zipped versions">
1004 <property name="collect.dir" value="${web.home}/sites/localsite/collect"/>
1005 <property name="index.zip" value="index.zip"/>
1006
1007 <echo message="installing collections..."/>
1008 <antcall target="gs2mgdemo-install"/>
1009 <antcall target="gs2mgppdemo-install"/>
1010 <antcall target="gberg-install"/>
1011 <antcall target="lucene-jdbm-demo-install"/>
1012 </target>
1013
1014 <target name="gs2mgdemo-prepare" if="collect.dir">
1015 <property name="gs2mgdemo.dir" value="${collect.dir}/gs2mgdemo"/>
1016
1017 <condition property="gs2mgdemo.present">
1018 <and>
1019 <available file="${gs2mgdemo.dir}/${index.zip}"/>
1020 </and>
1021 </condition>
1022 </target>
1023
1024 <target name="gs2mgdemo-install" if="gs2mgdemo.present" depends="gs2mgdemo-prepare">
1025 <unzip dest="${gs2mgdemo.dir}" src="${gs2mgdemo.dir}/${index.zip}" />
1026 <echo>collection gs2mgdemo installed</echo>
1027 </target>
1028
1029 <target name="gs2mgppdemo-prepare" if="collect.dir">
1030 <property name="gs2mgppdemo.dir" value="${collect.dir}/gs2mgppdemo"/>
1031
1032 <condition property="gs2mgppdemo.present">
1033 <and>
1034 <available file="${gs2mgppdemo.dir}/${index.zip}"/>
1035 </and>
1036 </condition>
1037 </target>
1038
1039 <target name="gs2mgppdemo-install" if="gs2mgppdemo.present" depends="gs2mgppdemo-prepare">
1040 <unzip dest="${gs2mgppdemo.dir}" src="${gs2mgppdemo.dir}/${index.zip}" />
1041 <echo>collection gs2mgppdemo installed</echo>
1042 </target>
1043
1044 <target name="gberg-prepare" if="collect.dir">
1045 <property name="gberg.dir" value="${collect.dir}/gberg"/>
1046 <available file="${gberg.dir}/index/${index.zip}" property="gberg.present"/>
1047 </target>
1048
1049 <target name="gberg-install" if="gberg.present" depends="gberg-prepare">
1050 <unzip dest="${gberg.dir}/index" src="${gberg.dir}/index/${index.zip}"/>
1051 <echo>collection gberg installed</echo>
1052 </target>
1053
1054 <target name="lucene-jdbm-demo-prepare" if="collect.dir">
1055 <property name="lucene-jdbm-demo.dir" value="${collect.dir}/lucene-jdbm-demo"/>
1056 <available file="${lucene-jdbm-demo.dir}/${index.zip}" property="lucene-jdbm-demo.present"/>
1057 </target>
1058
1059 <target name="lucene-jdbm-demo-install" if="lucene-jdbm-demo.present" depends="lucene-jdbm-demo-prepare">
1060 <unzip dest="${lucene-jdbm-demo.dir}" src="${lucene-jdbm-demo.dir}/${index.zip}"/>
1061 <echo>collection lucene-jdbm-demo installed</echo>
1062 </target>
1063
1064
1065 <target name="prepare-solr-ext" depends="init" >
1066 <property name="solr-ext.home" value="${basedir}/ext/solr"/>
1067 <exec executable="ant.bat" os="${os.windows}" dir="${solr-ext.home}" spawn="false">
1068 <arg value="add-service"/>
1069 </exec>
1070 <exec executable="ant" os="${os.unix}" dir="${solr-ext.home}" spawn="false">
1071 <arg value="add-service"/>
1072 </exec>
1073 <antcall target="solr-jdbm-demo-install"/>
1074 </target>
1075
1076 <target name="solr-jdbm-demo-prepare" if="collect.dir">
1077 <property name="solr-jdbm-demo.dir" value="${collect.dir}/solr-jdbm-demo"/>
1078 <available file="${solr-jdbm-demo.dir}/${index.zip}" property="solr-jdbm-demo.present"/>
1079 </target>
1080
1081 <target name="solr-jdbm-demo-install" if="solr-jdbm-demo.present" depends="solr-jdbm-demo-prepare">
1082 <unzip dest="${solr-jdbm-demo.dir}" src="${solr-jdbm-demo.dir}/${index.zip}"/>
1083 <echo>collection solr-jdbm-demo installed</echo>
1084 </target>
1085
1086
1087 <target name="set-perl-shebangs" depends="perl-for-building">
1088 <if>
1089 <bool>
1090 <and><isset property="perl.path"/>
1091 <not><equals arg1="${perl.path}" arg2=""/></not>
1092 </and>
1093 </bool>
1094
1095 <if><bool><istrue value="${current.os.iswindows}"/></bool>
1096 <property name="perl.exec" value="${perl.path}perl.exe"/>
1097 <else>
1098 <property name="perl.exec" value="${perl.path}perl"/>
1099 </else>
1100 </if>
1101
1102 <!--<echo>**** PERLPATH: ${perl.path}</echo>-->
1103 <echo>**** Setting perl shebangs to Perl Exec: ${perl.exec}</echo>
1104
1105 <!-- set the shebangs in the cgi files to point to the correct perlpath -->
1106 <if>
1107 <bool><not><equals arg1="${web.home}" arg2="${web.writablehome}"></equals></not></bool>
1108 <mkdir dir="${web.writablehome}"/>
1109 <copy file="${web.home}/WEB-INF/cgi/gliserver.pl" tofile="${web.writablehome}/WEB-INF/cgi/gliserver.pl" overwrite="true"/>
1110 <copy file="${web.home}/WEB-INF/cgi/metadata-server.pl" tofile="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" overwrite="true"/>
1111 <copy file="${web.home}/WEB-INF/cgi/checksum.pl" tofile="${web.writablehome}/WEB-INF/cgi/checksum.pl" overwrite="true"/>
1112 </if>
1113
1114 <rsr file="${web.writablehome}/WEB-INF/cgi/gliserver.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1115 <rsr file="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1116 <rsr file="${web.writablehome}/WEB-INF/cgi/checksum.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
1117 <else>
1118 <echo>WARNING: perl.path is empty. Unable to set the shebangs in the perl files in ${web.writablehome}/WEB-INF/cgi</echo>
1119 </else>
1120 </if>
1121 </target>
1122
1123 <target name="configure-web" depends="init,perl-for-building"
1124 description="Configure only the web app config files">
1125 <!-- we want a unix path in the global.properties file -->
1126 <pathconvert targetos="unix" property="src.gsdl3.home.unix">
1127 <path path="${web.home}"/>
1128 </pathconvert>
1129 <pathconvert targetos="unix" property="src.gsdl3.writablehome.unix">
1130 <path path="${web.writablehome}"/>
1131 </pathconvert>
1132
1133 <antcall target="set-perl-shebangs" inheritAll="true" />
1134
1135 <filter token="gsdlhome" value="${gs2build.home}"/>
1136 <filter token="gsdl3srchome" value="${basedir}"/>
1137 <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
1138 <filter token="gsdl3writablehome" value="${src.gsdl3.writablehome.unix}"/>
1139 <filter token="gsdl3version" value="${app.version}"/>
1140 <filter token="tomcat.server" value="${tomcat.server}"/>
1141 <filter token="tomcat.port" value="${tomcat.port}"/>
1142 <filter token="perlpath" value="${escaped.perl.path}"/>
1143 <filter token="disable.collection.building" value="${disable.collection.building}"/>
1144 <copy file="${web.home}/WEB-INF/cgi/gsdl3site.cfg.in" tofile="${web.writablehome}/WEB-INF/cgi/gsdl3site.cfg" filtering="true" overwrite="true"/>
1145
1146 <copy file="${basedir}/resources/java/global.properties.in" tofile="${web.writableclasses}/global.properties" filtering="true" overwrite="true"/>
1147 <copy file="${basedir}/resources/java/log4j.properties.in" tofile="${web.writableclasses}/log4j.properties" filtering="true" overwrite="true"/>
1148 <if><bool><istrue value="${gsdl3home.isreadonly}"/></bool>
1149 <!-- uncomment the writablehome properties -->
1150 <rsr file="${web.writableclasses}/global.properties" pattern="^#gsdl3\.(writable{1})?home" replacement="gsdl3.$1home" />
1151 </if>
1152 <chmod file="${web.writableclasses}/global.properties" perm="644"/>
1153 <chmod file="${web.writableclasses}/log4j.properties" perm="644"/>
1154 </target>
1155
1156 <target name="compile-web" depends="init">
1157 <javac srcdir="${web.classes}"
1158 destdir="${web.classes}"
1159 debug="${compile.debug}"
1160 deprecation="${compile.deprecation}"
1161 optimize="${compile.optimize}">
1162 <classpath><path refid="compile.classpath"/></classpath>
1163 </javac>
1164 </target>
1165
1166 <target name="compile-classpath-jars" depends="init">
1167 <if><bool><available file="admin/cp.mf"/></bool>
1168 <jar destfile="admin/cp.jar" manifest="admin/cp.mf"/>
1169 </if>
1170 <if><bool><available file="${lib.java}/cp.mf"/></bool>
1171 <jar destfile="${lib.java}/cp.jar" manifest="${lib.java}/cp.mf"/>
1172 </if>
1173 <if><bool><available file="${lib.jni}/cp.mf"/></bool>
1174 <jar destfile="${lib.jni}/cp.jar" manifest="${lib.jni}/cp.mf"/>
1175 </if>
1176 <if><bool><available file="${web.lib}/cp.mf"/></bool>
1177 <jar destfile="${web.lib}/cp.jar" manifest="${web.lib}/cp.mf"/>
1178 </if>
1179 <jar destfile="cp.jar">
1180 <manifest>
1181 <attribute name="Class-Path" value="server.jar admin/cp.jar lib/java/cp.jar lib/jni/cp.jar web/WEB-INF/lib/cp.jar"/>
1182 </manifest>
1183 </jar>
1184 </target>
1185
1186 <target name="clean-classpath-jars" depends="init">
1187 <delete file="admin/cp.jar"/>
1188 <delete file="${lib.java}/cp.jar"/>
1189 <delete file="${lib.jni}/cp.jar"/>
1190 <delete file="${web.lib}/cp.jar"/>
1191 <delete file="cp.jar"/>
1192 </target>
1193
1194
1195 <target name="svnupdate-web" unless="nosvn.mode">
1196 <exec executable="svn">
1197 <arg value="update"/>
1198 <arg value="${web.writablehome}"/>
1199 <arg value="-r"/><arg value="${branch.revision}"/>
1200 </exec>
1201 </target>
1202
1203 <target name="update-web" depends="init,svnupdate-web,configure-web"
1204 description="update only the web stuff (config files)"/>
1205
1206 <!-- ======================= Tomcat Targets ========================== -->
1207
1208 <!-- this target downloads and installs Tomcat -->
1209 <!-- we download tomcat (version 7 for Java 1.5 and later, version 5 for Java 1.4 plus the 1.4 compatibility package). -->
1210 <target name="prepare-tomcat" depends="init,setup-proxy" if="tomcat.islocal"
1211 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">
1212 <if>
1213 <bool>
1214 <not><available file="${packages.home}/tomcat/.flagfile"/></not>
1215 </bool>
1216
1217 <!-- check that packages dir is there -->
1218 <mkdir dir="${packages.home}"/>
1219 <get src="http://www.greenstone.org/gs3files/${tomcat.version}.zip"
1220 dest="${packages.home}/${tomcat.version}.zip"
1221 usetimestamp="true"/>
1222 <unzip src="${packages.home}/${tomcat.version}.zip"
1223 dest="${packages.home}"/>
1224
1225 <!-- If we are using Java 1.4, we'd be using tomcat 5.5 in which case
1226 we would need to have the tomcat compat package to work with Java 1.4-->
1227 <if>
1228 <bool><equals arg1="1.4" arg2="${ant.java.version}"/></bool>
1229 <get src="http://www.greenstone.org/gs3files/${tomcat.version}-compat.zip"
1230 dest="${packages.home}/${tomcat.version}-compat.zip"
1231 usetimestamp="true"/>
1232 <unzip src="${packages.home}/${tomcat.version}-compat.zip"
1233 dest="${packages.home}"/>
1234 </if>
1235
1236 <!-- delete any existing tomcat -->
1237 <delete dir="${packages.home}/tomcat"/>
1238 <move todir="${packages.home}/tomcat">
1239 <fileset dir="${packages.home}/${tomcat.version}"/>
1240 </move>
1241 <!--
1242 <copy file="${basedir}/resources/tomcat/setclasspath.bat"
1243 tofile="${packages.home}/tomcat/bin/setclasspath.bat"
1244 overwrite="true"/>
1245 <copy file="${basedir}/resources/tomcat/setclasspath.sh"
1246 tofile="${packages.home}/tomcat/bin/setclasspath.sh"
1247 overwrite="true"/>
1248 -->
1249 <!-- make sure we have execute permission for the .sh files -->
1250 <chmod dir="${packages.home}/tomcat/bin" perm="ugo+rx"
1251 includes="*.sh"/>
1252
1253 <echo file="${packages.home}/tomcat/.flagfile">
1254 the timestamp of this file is the time that tomcat was extracted from the zip files.
1255 it is used to figure out whether the files need to be refreshed or not in `ant prepare-tomcat`
1256 </echo>
1257
1258 <!-- this is not strictly a prepare tomcat thing, but if one changes
1259 Java, then they need to change tomcat as well, so might as well call
1260 it here -->
1261 <antcall target="configure-java-version"/>
1262 <else>
1263 <echo>Tomcat has been prepared, will not prepare</echo>
1264 <echo>Delete ${packages.home}/tomcat/.flagfile to force refresh</echo>
1265 </else>
1266
1267 </if>
1268
1269 </target>
1270
1271 <target name="configure-tomcat" depends="init,configure-tomcat-local,configure-tomcat-external"/>
1272
1273 <target name="configure-tomcat-local" depends="init,perl-for-building" if="tomcat.islocal">
1274 <!-- re-setup the server.xml file -->
1275 <copy file="${basedir}/resources/tomcat/server_tomcat${tomcat.version.major}.xml"
1276 tofile="${packages.home}/tomcat/conf/server.xml" overwrite="true">
1277 <filterset>
1278 <filter token="port" value="${tomcat.port}"/>
1279 <filter token="shutdown-port" value="${tomcat.shutdown.port}"/>
1280 </filterset>
1281 </copy>
1282 <!-- set up the greenstone3 context -->
1283 <copy file="${basedir}/resources/tomcat/greenstone3.xml" tofile="${packages.home}/tomcat/conf/Catalina/localhost/greenstone3.xml" overwrite="true">
1284 <filterset>
1285 <filter token="gsdl3webhome" value="${web.home}"/>
1286 <filter token="gsdl3webwritablehome" value="${web.writablehome}"/>
1287 <filter token="privilegedattribute" value ="${privileged.attribute}"/>
1288 </filterset>
1289 </copy>
1290
1291 <!-- set up the greenstone3 web.xml file -->
1292 <copy file="${basedir}/resources/tomcat/web.xml" tofile="${packages.home}/tomcat/conf/web.xml" overwrite="true">
1293 <filterset>
1294 <filter token="perlpath" value="${perl.path}"/>
1295 </filterset>
1296 </copy>
1297 </target>
1298
1299 <target name="configure-tomcat-external" depends="init" unless="tomcat.islocal">
1300 <!-- re-setup the server.xml file -->
1301 <!-- need to edit the config file, or do we get the user to do this???-->
1302 </target>
1303
1304
1305 <!-- This target runs tomcat's "bin/catalina.bat(.sh) jpda start"
1306 to allow debugging the running GS3 server in Eclipse. See the instructions at
1307 http://www.wikijava.org/wiki/Debugging_a_servlet_with_tomcat_and_Eclipse_tutorial
1308 on how to use this with eclipse
1309 -->
1310 <target name="debug-start-tomcat" description="Startup Tomcat for debugger" depends="init" if="tomcat.islocal">
1311 <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
1312 <property name="tomcat.path" refid="local.tomcat.path"/>
1313
1314 <if><bool>
1315 <isset property="fedora.maxpermsize"/></bool>
1316 <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx400M ${fedora.maxpermsize}"/>
1317 <else>
1318 <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx400M"/>
1319 </else>
1320 </if>
1321
1322 <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
1323 <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
1324
1325 <exec executable="${catalina.home}/bin/catalina.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
1326 <arg value="jpda" />
1327 <arg value="start" />
1328 <env key="JPDA_ADDRESS" value="8000"/> <!-- for debugging Tomcat in Eclipse -->
1329 <env key="JPDA_TRANSPORT" value="dt_socket"/> <!-- for debugging Tomcat in Eclipse -->
1330 <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
1331 <env key="PATH" path="${tomcat.path}"/>
1332 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1333 <env key="CATALINA_HOME" value="${catalina.home}"/>
1334 <env key="CLASSPATH" path="${tomcat.classpath}"/>
1335 <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
1336 <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
1337 <env key="WNHOME" path="${wn.home}"/>
1338 <env key="FEDORA_HOME" path="${fedora.home}"/>
1339 </exec>
1340 <exec executable="${catalina.home}/bin/catalina.bat" os="${os.windows}" dir="${catalina.home}/bin" spawn="true">
1341 <arg value="jpda" />
1342 <arg value="start" />
1343 <env key="JPDA_ADDRESS" value="8000"/> <!-- for debugging Tomcat in Eclipse -->
1344 <env key="JPDA_TRANSPORT" value="dt_socket"/> <!-- for debugging Tomcat in Eclipse -->
1345 <env key="GSDLOS" value="windows"/>
1346 <env key="GSDL3HOME" value="${basedir}"/>
1347 <env key="Path" path="${tomcat.path}"/>
1348 <env key="PATH" path="${tomcat.path}"/>
1349 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1350 <env key="CATALINA_HOME" value="${catalina.home}"/>
1351 <env key="CLASSPATH" path="${tomcat.classpath}"/>
1352 <env key="FEDORA_HOME" path="${fedora.home}"/>
1353 </exec>
1354 <!-- wait for the server to startup in case other targets need it running -->
1355 <waitfor maxwait="5" maxwaitunit="second">
1356 <and>
1357 <socket server="${tomcat.server}" port="${tomcat.port}"/>
1358 <http url="http://${tomcat.server}:${tomcat.port}${app.path}/index.html"/>
1359 </and>
1360 </waitfor>
1361 </target>
1362
1363
1364 <!-- Another way: http://ptrthomas.wordpress.com/2006/03/25/how-to-start-and-stop-tomcat-from-ant/ -->
1365 <target name="start-tomcat" description="Startup only Tomcat" depends="init" if="tomcat.islocal">
1366 <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
1367 <property name="tomcat.path" refid="local.tomcat.path"/>
1368
1369 <if><bool>
1370 <isset property="fedora.maxpermsize"/></bool>
1371 <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx400M ${fedora.maxpermsize}"/>
1372 <else>
1373 <property name="catalina.opts" value="-Djava.util.prefs.syncInterval=2000000 -DGSDL3HOME=$GSDL3HOME -DGSDLOS=$GSDLOS -DPATH=$PATH -Xmx400M"/>
1374 </else>
1375 </if>
1376
1377 <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
1378 <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
1379
1380 <exec executable="${catalina.home}/bin/startup.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
1381 <!--<env key="GSDLOS" value="linux"/> do we need this?? -->
1382 <env key="GSDL3HOME" value="${basedir}"/>
1383 <env key="PATH" path="${tomcat.path}"/>
1384 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1385 <env key="CATALINA_HOME" value="${catalina.home}"/>
1386 <env key="CLASSPATH" path="${tomcat.classpath}"/>
1387 <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
1388 <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
1389 <env key="WNHOME" path="${wn.home}"/>
1390 <env key="FEDORA_HOME" path="${fedora.home}"/>
1391 </exec>
1392 <exec executable="${catalina.home}/bin/startup.bat" os="${os.windows}" dir="${catalina.home}/bin" spawn="true">
1393 <env key="GSDLOS" value="windows"/>
1394 <env key="GSDL3HOME" value="${basedir}"/>
1395 <env key="Path" path="${tomcat.path}"/>
1396 <env key="PATH" path="${tomcat.path}"/>
1397 <env key="CATALINA_OPTS" value="${catalina.opts}"/>
1398 <env key="CATALINA_HOME" value="${catalina.home}"/>
1399 <env key="CLASSPATH" path="${tomcat.classpath}"/>
1400 <env key="FEDORA_HOME" path="${fedora.home}"/>
1401 </exec>
1402 <!-- wait for the server to startup in case other targets need it running -->
1403 <waitfor maxwait="5" maxwaitunit="second">
1404 <and>
1405 <socket server="${tomcat.server}" port="${tomcat.port}"/>
1406 <http url="http://${tomcat.server}:${tomcat.port}${app.path}/index.html"/>
1407 </and>
1408 </waitfor>
1409 </target>
1410
1411 <!--ant task http: http://www.jajakarta.org/ant/ant-1.6.1/docs/ja/manual/api/org/apache/tools/ant/taskdefs/condition/Http.html-->
1412 <target name="reconfigure" description="Reconfigure the message router">
1413 <waitfor maxwait="5" maxwaitunit="second">
1414 <http url="http://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c"/>
1415 </waitfor>
1416 </target>
1417
1418 <!--Command-line args to Ant: http://www.jguru.com/faq/view.jsp?EID=471794-->
1419 <target name="reconfigure-collection" description="Reconfigure the collection">
1420 <waitfor maxwait="5" maxwaitunit="second">
1421 <http url="http://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}?a=s&amp;sa=c&amp;sc=${collection}"/>
1422 </waitfor>
1423 </target>
1424
1425 <!-- windows: do we want to launch a webrowser?? -->
1426 <!-- shouldn't this test whether anything is running first?
1427 It's safer to always attempt to stop tomcat: that way we won't be dependent on the right time
1428 to check whether the server is stopped or still running before attempting to start again.
1429 This target, which was recently called force-stop-tomcat for a while but is back to being
1430 called stop-tomcat, now hides the Java exception output that appears whenever tomcat is already
1431 stopped as happens when stop-tomcat is called consecutively. -->
1432 <target name="force-stop-tomcat" description="Shutdown only Tomcat" depends="init" if="tomcat.islocal">
1433 <exec executable="${catalina.home}/bin/shutdown.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
1434 <env key="FEDORA_HOME" path="${fedora.home}"/>
1435 <env key="CATALINA_HOME" value="${catalina.home}"/>
1436 <arg line=">/dev/null 2>&amp;1"/>
1437 </exec>
1438 <exec executable="${catalina.home}/bin/shutdown.bat" os="${os.windows}" dir="${catalina.home}/bin" spawn="false">
1439 <env key="FEDORA_HOME" path="${fedora.home}"/>
1440 <env key="CATALINA_HOME" value="${catalina.home}"/>
1441 <arg line=">nul 2>&amp;1"/>
1442 </exec>
1443 </target>
1444
1445 <!-- Can also try the "socket" condition in place of the "http" condition
1446 And also use a <waitfor> in place of <condition>, such as:
1447 <waitfor maxwait="5" maxwaitunit="second" timeoutproperty="tomcat.isstopped"><http url="..."/></waitfor>
1448 The http URL resolves to host:port/greenstone3
1449 Condition uses <http/> rather than <socket/> for testing, since if the server was stopped, the socket
1450 might still be in use for some moments. We test the URL with the http condition since it's likelier to
1451 fail sooner if the server has indeed been stopped. -->
1452 <target name="check-tomcat-running">
1453 <condition property="tomcat.isrunning">
1454 <!--<http url="http://${tomcat.server}:${tomcat.port}${app.path}"/>-->
1455 <http url="http://${tomcat.server}:${tomcat.port}"/>
1456 </condition>
1457 </target>
1458
1459 <!-- stop-tomcat checks if the tomcat server is already running. If it appears to be running
1460 (regardless of whether tomcat was just starting to shut down), this target calls force-stop-tomcat
1461 to issue the shutdown command to tomcat. Then it waits for at most 15 seconds for the server to
1462 actually stop by checking the socket at which tomcat listens every second, printing a warning
1463 at the end of the max wait time of 15 seconds if tomcat was still running. -->
1464 <target name="stop-tomcat" description="Shutdown only Tomcat if running" depends="check-tomcat-running" if="tomcat.isrunning">
1465 <antcall target="force-stop-tomcat"/>
1466
1467 <property name="wait.numchecks" value="15"/>
1468 <echo>Waiting for the server to shutdown... (${wait.numchecks} seconds max)</echo>
1469 <waitfor maxwait="${wait.numchecks}" maxwaitunit="second" checkevery="1" checkeveryunit="second" timeoutproperty="tomcat.timedout">
1470 <not><socket server="${tomcat.server}" port="${tomcat.port}"/></not>
1471 </waitfor>
1472
1473 <if>
1474 <bool>
1475 <isset property="${tomcat.timedout}"/>
1476 </bool>
1477 <property name="tomcat.isrunning" value="true"/>
1478 <echo>WARNING: Checked the socket ${wait.numchecks} times, but port ${tomcat.port} is still busy.</echo>
1479 <else>
1480 <echo>Tomcat is stopped.</echo>
1481 <property name="tomcat.isrunning" value="false"/>
1482 </else>
1483 </if>
1484 </target>
1485
1486 <target name="restart-tomcat" description="Shutdown and restart only Tomcat" depends="init,stop-tomcat,start-tomcat"/>
1487
1488 <target name="setup-catalina-ant-tasks">
1489 <!-- Configure the custom Ant tasks for the Tomcat Manager application -->
1490 <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"
1491 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1492 <taskdef name="list" classname="org.apache.catalina.ant.ListTask"
1493 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1494 <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"
1495 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1496 <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"
1497 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1498 <taskdef name="roles" classname="org.apache.catalina.ant.RolesTask"
1499 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1500 <taskdef name="start" classname="org.apache.catalina.ant.StartTask"
1501 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1502 <taskdef name="stop" classname="org.apache.catalina.ant.StopTask"
1503 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1504 <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"
1505 classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
1506 </target>
1507
1508 <!-- http://blog.andrewbeacock.com/2007/11/how-to-truncate-log-file-using-ubuntu.html
1509 Doing "cat </dev/null > packages/tomcat/logs/catalina.out" doesn't work as an ant target.
1510 It seems to have a problem with cat or </dev/null, with or without the < sign. -->
1511 <target name="reset-logs" description="Empties catalina.out, greenstone.log and contents of web/logs/tmp">
1512 <echo>Truncating catalina.out, greenstone.log and server.log, and emptying ${web.writablehome}/logs/tmp</echo>
1513 <exec executable="rm" os="${os.unix}" dir="${catalina.home}/logs" spawn="false">
1514 <arg value="-f"/>
1515 <arg value="catalina.out"/>
1516 </exec>
1517 <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
1518 <arg value="-f"/>
1519 <arg value="greenstone.log"/>
1520 </exec>
1521 <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
1522 <arg value="-f"/>
1523 <arg value="server.log"/>
1524 </exec>
1525
1526 <exec executable="touch" os="${os.unix}" dir="${catalina.home}/logs"
1527 spawn="false">
1528 <arg value="catalina.out"/>
1529 </exec>
1530 <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
1531 spawn="false">
1532 <arg value="greenstone.log"/>
1533 </exec>
1534 <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
1535 spawn="false">
1536 <arg value="server.log"/>
1537 </exec>
1538
1539 <exec executable="cmd" os="${os.windows}" dir="${catalina.home}/logs" spawn="false">
1540 <arg line="/c echo. > catalina.out"/>
1541 </exec>
1542 <exec executable="cmd" os="${os.windows}" dir="${web.writablehome}/logs" spawn="false">
1543 <arg line="/c echo. > greenstone.log"/>
1544 </exec>
1545 <exec executable="cmd" os="${os.windows}" dir="${web.writablehome}/logs" spawn="false">
1546 <arg line="/c echo. > server.log"/>
1547 </exec>
1548
1549 <if>
1550 <bool><available file="${web.writablehome}/logs/tmp" type="dir"/></bool>
1551 <delete>
1552 <fileset dir="${web.writablehome}/logs/tmp" includes="**/*"/>
1553 </delete>
1554 </if>
1555 </target>
1556
1557 <!-- ======================= ant Targets ============================ -->
1558 <target name="prepare-ant" depends="init">
1559 <if>
1560 <bool>
1561 <not><available file="${packages.home}/ant/.flagfile"/></not>
1562 </bool>
1563
1564 <get src="http://www.greenstone.org/gs3files/apache-ant-1.7.0-bin.zip"
1565 dest="${packages.home}/apache-ant-1.7.0-bin.zip"
1566 usetimestamp="true"/>
1567 <unzip src="${packages.home}/apache-ant-1.7.0-bin.zip"
1568 dest="${packages.home}"/>
1569 <move todir="${packages.home}/ant">
1570 <fileset dir="${packages.home}/apache-ant-1.7.0"/>
1571 </move>
1572 <echo file="${packages.home}/ant/.flagfile">
1573 the timestamp of this file is the time that ant was extracted from the zip files.
1574 it is used to figure out whether the files need to be refreshed or not in `ant prepare-ant`
1575 </echo>
1576
1577 <else>
1578 <echo>Ant has been prepared, will not prepare</echo>
1579 <echo>Delete ${packages.home}/ant/.flagfile to force refresh</echo>
1580 </else>
1581
1582 </if>
1583 </target>
1584
1585 <!-- ======================= Admin Targets ============================ -->
1586
1587 <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
1588 See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
1589 But you can do: echo mypassword | ant config-admin -->
1590 <target name="config-admin" description="Reset admin password">
1591 <input addproperty="admin.password" defaultvalue="admin" message="New admin password (3-8 characters):&gt;">
1592 <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
1593 </input>
1594 <!--<echo>PWD: ${admin.password}</echo>-->
1595 <antcall target="update-userdb">
1596 <param name="user.username" value="admin"/>
1597 <param name="user.password" value="${admin.password}"/>
1598 <param name="user.groups" value=""/>
1599 <param name="user.status" value=""/>
1600 <param name="user.comment" value="Password updated."/>
1601 <param name="user.email" value=""/>
1602 </antcall>
1603 </target>
1604
1605 <target name="config-user" description="Add or modify users" depends="get-user-data,update-userdb"/>
1606
1607 <target name="get-user-data" description="Get user details">
1608 <input addproperty="user.username" message="Username:&gt;"/>
1609 <input addproperty="user.password" defaultvalue="" message="Password (3-8 characters):&gt;">
1610 <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
1611 </input>
1612 <input addproperty="user.groups" defaultvalue="" message="Groups (comma-separated list):&gt;"/>
1613 <input addproperty="user.status" defaultvalue="true" message="Enabled (true/false):&gt;"/>
1614 <input addproperty="user.comment" defaultvalue="" message="Comment:&gt;"/>
1615 <input addproperty="user.email" defaultvalue="" message="Email:&gt;"/>
1616 </target>
1617
1618<!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
1619 See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
1620 But you can do: echo mypassword | ant config-admin -->
1621 <target name="update-userdb" description="Add or modify users" depends="check-tomcat-running">
1622
1623 <!-- stop tomcat if running, since derby db is embedded and only allows connections from one jvm instance at a time
1624 See http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html
1625 The ${tomcat.isrunning} property is set by the depends-target "check-tomcat-running" -->
1626 <if>
1627 <bool>
1628 <istrue value="${tomcat.isrunning}"/>
1629 </bool>
1630 <antcall target="stop-tomcat"/>
1631 </if>
1632
1633 <!--<echo>${admin.password}</echo>--> <!-- for testing -->
1634 <java classname="org.greenstone.gsdl3.util.ModifyUsersDB">
1635 <classpath refid="compile.classpath"/> <!--for ${web.lib}/gsdl3.jar and supporting files-->
1636 <arg file="${web.home}/sites/localsite/etc/usersDB"/>
1637 <arg value="${user.username}"/>
1638 <arg value="password=${user.password}"/>
1639 <arg value="groups=${user.groups}"/>
1640 <arg value="status=${user.status}"/>
1641 <arg value="comment=${user.comment}"/>
1642 <arg value="email=${user.email}"/>
1643 </java>
1644
1645 <!-- run tomcat again if it used to be running -->
1646 <if>
1647 <bool>
1648 <istrue value="${tomcat.isrunning}"/>
1649 </bool>
1650 <antcall target="start-tomcat"/>
1651 </if>
1652 </target>
1653
1654
1655 <!-- ======================= Axis Targets ============================ -->
1656
1657 <target name="prepare-axis" depends="init">
1658
1659 <if>
1660 <bool>
1661 <not><available file="${packages.home}/axis/.flagfile"/></not>
1662 </bool>
1663
1664 <get src="http://www.greenstone.org/gs3files/${axis.zip.version}"
1665 dest="${packages.home}/${axis.zip.version}"
1666 usetimestamp="true"/>
1667 <unzip src="${packages.home}/${axis.zip.version}"
1668 dest="${packages.home}"/>
1669 <move todir="${packages.home}/axis">
1670 <fileset dir="${packages.home}/${axis.dir.version}"/>
1671 </move>
1672 <!-- install axis into greenstone web app -->
1673 <copy todir="${web.lib}">
1674 <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/lib">
1675 <include name="*.jar"/>
1676 </fileset>
1677 </copy>
1678 <copy todir="${web.home}">
1679 <fileset dir="${packages.home}/axis/webapps/axis/">
1680 <include name="*.jsp"/>
1681 <include name="*.jws"/>
1682 </fileset>
1683 </copy>
1684 <copy tofile="${web.home}/axis.html" file="${packages.home}/axis/webapps/axis/index.html"/>
1685 <copy todir="${web.classes}">
1686 <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/classes">
1687 <include name="*.properties"/>
1688 </fileset>
1689 </copy>
1690 <echo file="${packages.home}/axis/.flagfile">
1691 the timestamp of this file is the time that axis was extracted from the zip files.
1692 it is used to figure out whether the files need to be refreshed or not in `ant prepare-axis`
1693 </echo>
1694
1695 <else>
1696 <echo>Axis has been prepared, will not prepare</echo>
1697 <echo>Delete ${packages.home}/axis/.flagfile to force refresh</echo>
1698 </else>
1699
1700 </if>
1701 </target>
1702
1703 <target name="soap-deploy-site" depends="init,get-sitename,get-siteuri,get-webservices,create-deployment-files,deploy-site"
1704 description="Deploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work."/>
1705
1706 <target name="deploy-site">
1707 <java classname="org.apache.axis.client.AdminClient">
1708 <classpath refid="compile.classpath"/>
1709 <arg value="-l"/>
1710 <arg value="http://${tomcat.server}:${tomcat.port}${app.path}/servlet/AxisServlet"/>
1711 <arg file="${basedir}/resources/soap/deploy.wsdd"/>
1712 </java>
1713 <delete file="${basedir}/resources/soap/deploy.wsdd"/> <!--clean up, no longer used-->
1714 </target>
1715
1716 <target name="soap-undeploy-site" depends="get-undeploy-service-name"
1717 description="Undeploy a SOAP web service for a local Greenstone site. Tomcat must be running for this to work.">
1718 <filter token="servicesname" value="${axis.undeploy.servicename}"/>
1719 <copy file="${basedir}/resources/soap/undeploy-site.wsdd.template"
1720 tofile="${basedir}/resources/soap/undeploy.wsdd"
1721 filtering="true"
1722 overwrite="true"/>
1723 <java classname="org.apache.axis.client.AdminClient">
1724 <classpath refid="compile.classpath"/>
1725 <arg value="-l"/>
1726 <arg value="http://${tomcat.server}:${tomcat.port}${app.path}/servlet/AxisServlet"/>
1727 <arg file="${basedir}/resources/soap/undeploy.wsdd"/>
1728 </java>
1729 <delete file="${basedir}/resources/soap/undeploy.wsdd"/> <!--clean up, no longer used-->
1730 </target>
1731
1732 <!-- this target used to deploy the default web service SOAPServer (base.webservice.name) on the localsite server
1733 with the default servicename of localsite-->
1734 <target name="deploy-localsite" depends="init"
1735 description="Deploy the SOAP server for localsite. Will start and stop Tomcat.">
1736 <antcall target="start-tomcat"/>
1737 <echo>Deploying ${base.webservice.name} web services for localsite under service name: localsite</echo>
1738 <antcall target="create-deployment-files">
1739 <param name="axis.sitename" value="localsite"/>
1740 <param name="axis.servicesname" value="${base.webservice.name}"/>
1741 <param name="axis.siteuri" value="localsite"/>
1742 </antcall>
1743 <antcall target="deploy-site">
1744 <param name="axis.sitename" value="localsite"/>
1745 <param name="axis.servicesname" value="${base.webservice.name}"/>
1746 <param name="axis.siteuri" value="localsite"/>
1747 </antcall>
1748 <echo>The Greenstone server has been started up. If you do not want it running, please type: ant stop.</echo>
1749 </target>
1750
1751 <target name="get-sitename" unless="axis.sitename">
1752 <input addproperty="axis.sitename" defaultvalue="localsite">What site do you want to deploy services for?
1753Press Enter for default:localsite</input>
1754 </target>
1755
1756 <target name="get-undeploy-service-name" unless="axis.undeploy.servicename">
1757 <input addproperty="axis.undeploy.servicename" defaultvalue="localsite">Please enter the full name of the service you wish to undeploy.
1758To find out which web services you've got deployed, point your browser to http://HOST:PORT/greenstone3/services
1759Or press Enter for undeploying the default:localsite /&gt;</input>
1760 <echo>Name of service to undeploy: ${axis.undeploy.servicename}</echo>
1761 </target>
1762
1763 <target name="get-webservices" unless="axis.servicesname">
1764 <input addproperty="axis.servicesname" defaultvalue="${base.webservice.name}">Which set of web services do you want to deploy?
1765Choose from: ${web.services.list}
1766Or press Enter for default:${base.webservice.name} /&gt;</input>
1767 <echo>${axis.servicesname}</echo>
1768 </target>
1769
1770 <target name="get-siteuri" depends="get-sitename,get-webservices" unless="axis.siteuri">
1771 <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>
1772 <echo>Site: ${axis.sitename}, services: ${axis.servicesname}, servicesname: ${axis.siteuri}</echo>
1773 </target>
1774
1775 <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">
1776 <condition property="soap.method" value="provider='java:MSG' style='message' use='literal'">
1777 <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
1778 </condition>
1779
1780 <!--everything else defaults to java:RPC at present-->
1781 <condition property="soap.method" value="provider='java:RPC'">
1782 <not>
1783 <equals arg1="${axis.servicesname}" arg2="${base.webservice.name}"/>
1784 </not>
1785 </condition>
1786 </target>
1787
1788 <target name="create-deployment-files" depends="set-soapmethod" if="axis.sitename">
1789 <filter token="sitename" value="${axis.sitename}"/>
1790 <filter token="siteuri" value="${axis.siteuri}"/>
1791 <filter token="servicesname" value="${axis.servicesname}"/>
1792 <filter token="soapmethod" value="${soap.method}"/>
1793 <copy file="${basedir}/resources/soap/site.wsdd.template"
1794 tofile="${basedir}/resources/soap/deploy.wsdd"
1795 filtering="true"
1796 overwrite="true"/>
1797 <!-- create the java files and compile them -->
1798 <copy file="${basedir}/resources/java/${axis.servicesname}.java.in"
1799 tofile="${src.gsdl3.home}/${axis.servicesname}${axis.sitename}.java"
1800 filtering="true"
1801 overwrite="true"/>
1802 <mkdir dir="${build.home}"/>
1803 <javac srcdir="${src.home}"
1804 destdir="${build.home}"
1805 debug="${compile.debug}"
1806 deprecation="${compile.deprecation}"
1807 optimize="${compile.optimize}">
1808 <classpath refid="compile.classpath"/>
1809 <include name="org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.java" />
1810 </javac>
1811 <mkdir dir="${web.classes}/org/greenstone/gsdl3"/>
1812 <copy file="${build.home}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
1813 tofile="${web.classes}/org/greenstone/gsdl3/${axis.servicesname}${axis.sitename}.class"
1814 overwrite="true" />
1815 </target>
1816
1817
1818 <!-- ====================== Core targets ============================== -->
1819 <!-- core targets refer to the core gsdl3 java src -->
1820
1821 <target name="prepare-core"/>
1822
1823 <target name="configure-core"/>
1824
1825 <target name="update-core" depends="init,svnupdate-core,clean-core,compile-core"
1826 description="Update only the Greenstone core" />
1827
1828 <target name="svnupdate-core" unless="nosvn.mode">
1829 <exec executable="svn">
1830 <arg value="update"/>
1831 <arg value="${basedir}"/>
1832 <arg value="-r"/><arg value="${branch.revision}"/>
1833 </exec>
1834 </target>
1835
1836 <target name="clean-core"
1837 description="Clean only the Greenstone core">
1838 <!-- should this delete the gsdl3.jar from web/WEB-INF?? -->
1839 <delete dir="${build.home}"/>
1840 </target>
1841
1842 <target name="compile-core" depends="init"
1843 description="Compile only the Greenstone core">
1844 <mkdir dir="${build.home}"/>
1845
1846 <if><bool><isset property="with.jni"/></bool>
1847 <javac srcdir="${src.home}"
1848 destdir="${build.home}"
1849 debug="${compile.debug}"
1850 deprecation="${compile.deprecation}"
1851 optimize="${compile.optimize}">
1852 <classpath>
1853 <path refid="compile.classpath"/>
1854 </classpath>
1855 </javac>
1856 <else>
1857 <property name="gsprefix" value=""/>
1858 <javac srcdir="${src.home}"
1859 destdir="${build.home}"
1860 debug="${compile.debug}"
1861 deprecation="${compile.deprecation}"
1862 optimize="${compile.optimize}">
1863 <classpath>
1864 <path refid="compile.classpath"/>
1865 </classpath>
1866 <exclude name="org/greenstone/gsdl3/service/GS2MGPPRetrieve.java"/>
1867 <exclude name="org/greenstone/gsdl3/service/GS2MGPPSearch.java"/>
1868 <exclude name="org/greenstone/gsdl3/service/GS2MGSearch.java"/>
1869 <exclude name="org/greenstone/gsdl3/service/GS2MGRetrieve.java"/>
1870 <exclude name="org/greenstone/gsdl3/service/GoogleNgramMGPPSearch.java"/>
1871 <exclude name="org/greenstone/gsdl3/service/PhindPhraseBrowse.java"/>
1872 <exclude name="org/greenstone/gsdl3/util/GDBMWrapper.java"/>
1873 </javac>
1874 </else>
1875 </if>
1876 <jar destfile="${build.home}/gsdl3.jar">
1877 <fileset dir="${build.home}">
1878 <include name="org/greenstone/gsdl3/**"/>
1879 <include name="org/flax/**"/>
1880 <exclude name="**/Test.class"/>
1881 </fileset>
1882 <manifest>
1883 <attribute name="Built-By" value="${user.name}" />
1884 </manifest>
1885 </jar>
1886 <copy file="${build.home}/gsdl3.jar" todir="${web.lib}"/>
1887
1888 <jar destfile="${build.home}/gutil.jar">
1889 <fileset dir="${build.home}">
1890 <include name="org/greenstone/util/**"/>
1891 </fileset>
1892 <manifest>
1893 <attribute name="Built-By" value="${user.name}" />
1894 </manifest>
1895 </jar>
1896 <copy file="${build.home}/gutil.jar" todir="${web.lib}"/>
1897
1898 <!-- copy the localsite server in case we need it -->
1899 <copy file="${build.home}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" tofile="${web.classes}/org/greenstone/gsdl3/${base.webservice.name}localsite.class" />
1900
1901 <!-- Greenstone Administrator Interface -->
1902 <jar destfile="${build.home}/GAI.jar">
1903 <fileset dir="${build.home}">
1904 <include name="org/greenstone/admin/**"/>
1905 </fileset>
1906 <manifest>
1907 <attribute name="Built-By" value="${user.name}" />
1908 </manifest>
1909 </jar>
1910 <copy file="${build.home}/GAI.jar" todir="${web.lib}"/>
1911 <copy file="${build.home}/GAI.jar" todir="${admin.dir}"/>
1912 <jar destfile="${build.home}/phind.jar">
1913 <fileset dir="${build.home}">
1914 <include name="org/greenstone/applet/phind/**"/>
1915 </fileset>
1916 <manifest>
1917 <attribute name="Built-By" value="${user.name}" />
1918 </manifest>
1919 </jar>
1920 <mkdir dir="${web.applet}"/>
1921 <copy file="${build.home}/phind.jar" todir="${web.applet}"/>
1922 <!-- phind also needs xercesImpl.jar and xml-apis.jar to be in web/applet -->
1923 <if>
1924 <bool><istrue value="${tomcat.islocal}"/></bool>
1925 <copy file="${web.lib}/xercesImpl.jar" todir="${web.applet}"/>
1926 <copy file="${web.lib}/xml-apis.jar" todir="${web.applet}"/>
1927 </if>
1928
1929
1930 <!-- skip anttasks for now
1931 <jar destfile="${build.home}/anttasks.jar">
1932 <fileset dir="${build.home}">
1933 <include name="org/greenstone/anttasks/**"/>
1934 </fileset>
1935 <manifest>
1936 <attribute name="Built-By" value="${user.name}" />
1937 </manifest>
1938 </jar>
1939 <copy file="${build.home}/anttasks.jar" todir="${basedir}/lib/java"/>-->
1940 <jar destfile="${build.home}/gsdl3test.jar">
1941 <fileset dir="${build.home}">
1942 <include name="org/greenstone/gsdl3/**/*Test.class"/>
1943 <include name="org/greenstone/testing/**"/>
1944 </fileset>
1945 <manifest>
1946 <attribute name="Built-By" value="${user.name}" />
1947 </manifest>
1948 </jar>
1949 <jar destfile="${build.home}/server.jar">
1950 <fileset dir="${build.home}">
1951 <include name="org/greenstone/server/**"/>
1952 <include name="org/greenstone/util/**"/>
1953 </fileset>
1954 <fileset file="${basedir}/resources/java/server.properties"/>
1955 <manifest>
1956 <attribute name="Built-By" value="${user.name}"/>
1957 </manifest>
1958 </jar>
1959 <copy file="${build.home}/server.jar" todir="${basedir}"/>
1960 </target>
1961
1962 <!-- === Eclipse targets == -->
1963 <target name="setup-for-eclipse">
1964
1965 <filter token="gsdlhome" value="${gs2build.home}"/>
1966 <filter token="gsdl3srchome" value="${basedir}"/>
1967 <filter token="gsdl3home" value="${basedir}/web"/>
1968
1969 <if>
1970 <bool><not><available file="${basedir}/TransformingLibrary.launch"/></not></bool>
1971 <copy file="${basedir}/TransformingLibrary.launch.in" tofile="${basedir}/TransformingLibrary.launch" filtering="true" overwrite="true"/>
1972 </if>
1973<!--
1974 <if>
1975 <bool><not><available file="${basedir}/LibraryCommandline.launch"/></not></bool>
1976 <copy file="${basedir}/LibraryCommandline.launch.in" tofile="${basedir}/LibraryCommandline.launch" filtering="true" overwrite="true"/>
1977 </if>
1978-->
1979 </target>
1980
1981 <!-- ================== Packages targets ================================ -->
1982 <!-- these targets refer to the greenstone source packages - these need
1983 updating less often, so are in separate targets to the core -->
1984 <target name="prepare-packages" depends="init"/>
1985
1986 <target name="update-packages" depends="init,svnupdate-packages,configure-packages,clean-packages,compile-packages"
1987 description="Update only the source packages"/>
1988
1989 <target name="svnupdate-packages" unless="nosvn.mode">
1990 <exec executable="svn">
1991 <arg value="update"/>
1992 <arg value="${src.packages.home}"/>
1993 <arg value="-r"/><arg value="${branch.revision}"/>
1994 </exec>
1995 </target>
1996
1997
1998 <target name="configure-packages" depends="init,configure-javagdbm"
1999 description="Configure only the packages."/>
2000
2001 <target name="configure-javagdbm" if="with.jni">
2002 <echo>
2003 Configuring JavaGDBM
2004 </echo>
2005
2006 <exec executable="${javagdbm.home}/configure" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
2007 <arg value="--prefix=${basedir}"/>
2008 <arg value="--libdir=${lib.jni}"/>
2009 <arg value="--with-gdbm=${gdbm.home}"/>
2010 <arg line="${cross.configure.args}"/>
2011 </exec>
2012 </target>
2013
2014 <target name="clean-packages" depends="init,clean-javagdbm" description="Clean only the packages"/>
2015
2016 <target name="clean-javagdbm" depends="init">
2017 <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
2018 <exec executable="make" os="${os.unix}"
2019 dir="${javagdbm.home}" failonerror="true">
2020 <arg value="clean"/>
2021 </exec>
2022 </if>
2023 </target>
2024
2025 <target name="distclean-packages" depends="init,distclean-javagdbm" description="Distclean only the packages"/>
2026
2027 <target name="distclean-javagdbm" depends="init">
2028 <if><bool><available file="${javagdbm.home}/Makefile"/></bool>
2029 <exec executable="make" os="${os.unix}"
2030 dir="${javagdbm.home}" failonerror="true">
2031 <arg value="distclean"/>
2032 </exec>
2033 </if>
2034 </target>
2035
2036 <target name="compile-packages" description="Compile only the source packages">
2037 <!-- javagdbm -->
2038 <antcall target="compile-javagdbm"/>
2039 <!-- Search4j -->
2040 <antcall target="compile-search4j"/>
2041 </target>
2042
2043 <target name="compile-javagdbm" description="Compile JavaGDBM" if="with.jni">
2044
2045 <!-- unix: -->
2046 <echo>compile javagdbm</echo>
2047 <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true"/>
2048 <exec executable="make" os="${os.unix}" dir="${javagdbm.home}" failonerror="true">
2049 <arg value="install"/>
2050 </exec>
2051
2052 <!-- windows: Calling without the "compile" argument first will run winMake.bat with
2053 "all" which will then perform both the compile AND link targets in jni/win32.mak
2054 (thereby also generating gdbmjava.dll). Then we run the same command with
2055 the "install" argument to copy the gdbmjava.dll into the correct location. -->
2056 <echo>Windows: compile javagdbm</echo>
2057 <exec executable="${javagdbm.home}/winMake.bat" os="${os.windows}" dir="${javagdbm.home}" failonerror="true">
2058 <env key="GSDL3SRCHOME" path="${basedir}"/>
2059 </exec>
2060 <exec executable="${javagdbm.home}/winMake.bat" os="${os.windows}" dir="${javagdbm.home}" failonerror="true">
2061 <env key="GSDL3SRCHOME" path="${basedir}"/>
2062 <arg value="install"/>
2063 </exec>
2064
2065 <!-- install the jar file -->
2066 <echo>Install the javagdbm jar file ${javagdbm.home}/javagdbm.jar ${lib.jni}</echo>
2067 <copy file="${javagdbm.home}/javagdbm.jar" todir="${lib.jni}"/>
2068 </target>
2069
2070 <target name="compile-search4j">
2071
2072 <!-- windows -->
2073 <if><bool><istrue value="${current.os.iswindows}"/></bool>
2074 <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
2075 <arg value="/f"/>
2076 <arg value="win32.mak"/>
2077 <arg value='BINDIR="${basedir}\bin"'/>
2078 </exec>
2079 <exec executable="nmake" dir="${src.packages.home}/search4j" failonerror="true">
2080 <arg value="/f"/>
2081 <arg value="win32.mak"/>
2082 <arg value="install"/>
2083 <arg value='BINDIR="${basedir}\bin"'/>
2084 </exec>
2085
2086 <!-- unix -->
2087 <else><if><bool><istrue value="${current.os.isunix}"/></bool>
2088 <exec executable="${src.packages.home}/search4j/configure" dir="${src.packages.home}/search4j" failonerror="true">
2089 <arg value="--bindir=${basedir}/bin"/>
2090 <arg value="${static.arg}"/>
2091 <arg line="${cross.configure.args}"/>
2092 </exec>
2093 <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true"/>
2094 <exec executable="make" dir="${src.packages.home}/search4j" failonerror="true">
2095 <arg value="install"/>
2096 </exec>
2097
2098 <!-- else warn -->
2099 <else>
2100 <fail>this target does not support the current os</fail>
2101
2102 </else></if></else></if>
2103
2104 </target>
2105
2106 <target name="install-auxiliary-jar-files" depends="init">
2107
2108 <if>
2109 <bool><available file="${mg.home}/mg.jar"/></bool>
2110 <copy file="${mg.home}/mg.jar" todir="${lib.jni}"/>
2111 </if>
2112
2113 <if>
2114 <bool><available file="${mgpp.home}/mgpp.jar"/></bool>
2115 <copy file="${mgpp.home}/mgpp.jar" todir="${lib.jni}"/>
2116 </if>
2117
2118 <copy file="${lucene.home}/LuceneWrapper3.jar" todir="${web.lib}"/>
2119 </target>
2120
2121 <target name="install-jni-files" depends="init" if="with.jni">
2122 <antcall target="install-jni-files-linux"/>
2123 <antcall target="install-jni-files-windows"/>
2124 <antcall target="install-jni-files-macos"/>
2125 </target>
2126
2127 <target name="install-jni-files-linux" depends="init" if="current.os.isunixnotmac">
2128
2129 <if>
2130
2131 <bool><equals arg1="${os.bin.dir}" arg2="windows"/></bool>
2132 <!-- cross compiling to windows -->
2133 <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
2134 <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
2135 <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
2136 <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
2137 <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
2138 <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
2139
2140 <else>
2141 <!-- otherwise do the usual Unix copies -->
2142 <copy file="${mg.home}/jni/libmgretrievejni.so" todir="${lib.jni}"/>
2143 <copy file="${mg.home}/jni/libmgsearchjni.so" todir="${lib.jni}"/>
2144 <copy file="${mg.home}/jni/libmgpassjni.so" todir="${lib.jni}"/>
2145 <copy file="${mgpp.home}/jni/libmgppretrievejni.so" todir="${lib.jni}"/>
2146 <copy file="${mgpp.home}/jni/libmgppsearchjni.so" todir="${lib.jni}"/>
2147 <copy file="${mgpp.home}/jni/libmgpppassjni.so" todir="${lib.jni}"/>
2148 </else>
2149 </if>
2150
2151
2152 </target>
2153 <target name="install-jni-files-windows" depends="init" if="current.os.iswindows">
2154 <copy file="${mg.home}/jni/mgretrievejni.dll" todir="${lib.jni}"/>
2155 <copy file="${mg.home}/jni/mgsearchjni.dll" todir="${lib.jni}"/>
2156 <copy file="${mg.home}/jni/mgpassjni.dll" todir="${lib.jni}"/>
2157 <copy file="${mgpp.home}/jni/mgppretrievejni.dll" todir="${lib.jni}"/>
2158 <copy file="${mgpp.home}/jni/mgppsearchjni.dll" todir="${lib.jni}"/>
2159 <copy file="${mgpp.home}/jni/mgpppassjni.dll" todir="${lib.jni}"/>
2160 </target>
2161 <target name="install-jni-files-macos" depends="init" if="current.os.ismac">
2162 <copy file="${mg.home}/jni/libmgretrievejni.jnilib" todir="${lib.jni}"/>
2163 <copy file="${mg.home}/jni/libmgsearchjni.jnilib" todir="${lib.jni}"/>
2164 <copy file="${mg.home}/jni/libmgpassjni.jnilib" todir="${lib.jni}"/>
2165 <copy file="${mgpp.home}/jni/libmgppretrievejni.jnilib" todir="${lib.jni}"/>
2166 <copy file="${mgpp.home}/jni/libmgppsearchjni.jnilib" todir="${lib.jni}"/>
2167 <copy file="${mgpp.home}/jni/libmgpppassjni.jnilib" todir="${lib.jni}"/>
2168 </target>
2169
2170 <!-- ========common-src targets =================================-->
2171 <!-- these are used to get common-src (for indexers, gdbm, sqlite etc) when
2172 collection building is not enabled -->
2173
2174 <target name="update-common-src" depends="init" if="collection.building.disabled">
2175 </target>
2176
2177 <target name="svnupdate-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
2178 <exec executable="svn">
2179 <arg value="update"/>
2180 <arg value="${common.src.home}"/>
2181 <arg value="-r"/><arg value="${branch.revision}"/>
2182 </exec>
2183 </target>
2184
2185 <target name="prepare-common-src" depends="init" if="collection.building.disabled" unless="common.src.present">
2186 <antcall target="checkout-common-src"/>
2187 <antcall target="unzip-windows-packages"/>
2188 </target>
2189
2190 <target name="checkout-common-src" depends="init" if="collection.building.disabled" unless="nosvn.mode">
2191 <echo>checking out common-src</echo>
2192 <exec executable="svn">
2193 <arg value="checkout"/>
2194 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src"/>
2195 <arg value="common-src"/>
2196 <arg value="-r"/><arg value="${branch.revision}"/>
2197 </exec>
2198 </target>
2199
2200 <target name="configure-common-src" depends="init">
2201<!--
2202 <echo>cross configure args: ${cross.configure.args}</echo>
2203-->
2204 <exec executable="${common.src.home}/configure" os="${os.unix}"
2205 dir="${common.src.home}" failonerror="true">
2206 <arg value="--prefix=${gs2build.home}"/> <!-- what value to use?? -->
2207 <arg value="--bindir=${gs2build.home}/bin/${os.bin.dir}"/> <!-- what value to use?? -->
2208 <arg line="${gs2.opt.args}"/>
2209 <arg line="${static.arg}"/>
2210 <arg line="${cross.configure.args}"/>
2211 <arg line="${allargs}"/>
2212 </exec>
2213 </target>
2214
2215 <target name="clean-common-src" depends="init">
2216 <!-- unix: -->
2217 <if><bool><available file="${common.src.home}/Makefile"/></bool>
2218 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2219 <arg value="clean"/>
2220 </exec>
2221 </if>
2222 <!-- windows: -->
2223 <exec executable="nmake" dir="${common.src.home}" os="${os.windows}" failonerror="true">
2224 <arg value="/f"/>
2225 <arg value="win32.mak"/>
2226 <arg value="clean"/>
2227 <arg value="GSDLHOME=${gs2build.home}"/>
2228 </exec>
2229 </target>
2230 <target name="distclean-common-src" depends="init">
2231 <!-- unix: -->
2232 <if><bool><available file="${common.src.home}/Makefile"/></bool>
2233 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2234 <arg value="distclean"/>
2235 </exec>
2236 </if>
2237 <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->
2238 <exec executable="nmake" dir="${common.src.home}" os="${os.windows}" failonerror="true">
2239 <arg value="/f"/>
2240 <arg value="win32.mak"/>
2241 <arg value="clean"/>
2242 <arg value="GSDLHOME=${gs2build.home}"/>
2243 </exec>
2244 </target>
2245 <target name="compile-common-src" depends="init">
2246 <!-- unix: -->
2247 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2248 <arg value="${gs2.compile.target}"/>
2249 </exec>
2250 <!-- windows: -->
2251 <exec executable="nmake" dir="${common.src.home}" os="${os.windows}" failonerror="true">
2252 <arg value="/f"/>
2253 <arg value="win32.mak"/>
2254 <arg value="GSDLHOME=${gs2build.home}"/>
2255 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
2256 <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
2257 <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
2258 <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
2259 <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
2260 </exec>
2261 </target>
2262
2263 <!-- ======= collection-building targets ===========================-->
2264
2265 <target name="update-collection-building" if="collection.building.enabled"
2266 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"
2267 description="Update (SVN update, configure, compile etc) only the collection building components"/>
2268
2269 <target name="svnupdate-collection-building" if="collection.building.enabled" depends="init,svnupdate-gs2build,svnupdate-cgi,svnupdate-gli" unless="nosvn.mode"
2270 description="SVN update the collection building components">
2271 </target>
2272
2273 <target name="prepare-collection-building" depends="init,prepare-gs2build,svnupdate-cgi,prepare-gli" if="collection.building.enabled">
2274 </target>
2275
2276 <target name="configure-collection-building" depends="init,configure-build-src" if="collection.building.enabled"
2277 description="Configure the collection building components">
2278 </target>
2279
2280 <target name="clean-collection-building" depends="init,clean-gli,clean-build-src"
2281 description="Clean only the collection building components"
2282 if="collection.building.enabled"/>
2283
2284 <target name="distclean-collection-building" depends="init,clean-build-src,distclean-build-src"
2285 description="Distclean only the collection building components"
2286 if="collection.building.enabled"/>
2287
2288 <target name="compile-collection-building" depends="init,compile-build-src,compile-gli" if="collection.building.enabled"
2289 description="Compile only the collection building components">
2290 <!-- make install for common-src -->
2291 <!-- unix: -->
2292 <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
2293 <arg value="${gs2.install.target}"/>
2294 </exec>
2295
2296 <!-- windows: -->
2297 <exec executable="nmake" dir="${common.src.home}" os="${os.windows}" failonerror="true">
2298 <arg value="/f"/>
2299 <arg value="win32.mak"/>
2300 <arg value="install"/>
2301 <arg value="GSDLHOME=${gs2build.home}"/>
2302 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
2303 <arg value="ENABLE_MG=${gs2.windows.enablemg}"/>
2304 <arg value="ENABLE_MGPP=${gs2.windows.enablemgpp}"/>
2305 <arg value="USE_GDBM=${gs2.windows.usegdbm}"/>
2306 <arg value="USE_SQLITE=${gs2.windows.usesqlite}"/>
2307 <!--
2308 <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
2309 <arg value="USE_SQLITE=0"/>--> <!-- why is this not on by default? -->
2310 </exec>
2311
2312 <!-- install gs2build indexers for windows -->
2313 <if>
2314 <bool><istrue value="${current.os.iswindows}"/></bool>
2315 <copy todir="${gs2build.home}/bin/windows">
2316 <fileset dir="${gs2build.home}/common-src/indexers/bin">
2317 <include name="*.*"/>
2318 </fileset>
2319 </copy>
2320 </if>
2321
2322 <!-- LuceneWrapper jar file not installed by default -->
2323 <mkdir dir="${gs2build.home}/bin/java"/>
2324 <copy file="${lucene.home}/LuceneWrapper3.jar" todir="${gs2build.home}/bin/java"/>
2325
2326 </target>
2327
2328 <!-- ============== gli targets ================================= -->
2329
2330 <!-- gliserver.pl, gsdlCGI.pm, metadata-server.pl and checksum.pl are updated alongside
2331 this in target svnupdate-collection-building -->
2332 <target name="svnupdate-gli" if="collection.building.enabled" depends="init" unless="nosvn.mode">
2333
2334 <exec executable="svn">
2335 <arg value="update"/>
2336 <arg value="${gli.home}"/>
2337 <arg value="-r"/><arg value="${branch.revision}"/>
2338 </exec>
2339
2340 </target>
2341
2342 <!-- gliserver.pl, gsdlCGI.pm, metadata-server.pl and checksum.pl are updated
2343 alongside this prepare-gli target in target prepare-collection-building -->
2344 <target name="prepare-gli" depends="init" if="collection.building.enabled" unless="gli.present">
2345 <!-- checkout -->
2346 <if><bool><and><not><istrue value="${nosvn.mode}"/></not><isset property="with.gli.and.gems"/></and></bool>
2347
2348 <exec executable="svn">
2349 <arg value="checkout"/>
2350 <arg value="${svn.root}/main/${branch.path}/gli"/>
2351 <arg value="-r"/><arg value="${branch.revision}"/>
2352 </exec>
2353
2354 </if>
2355 </target>
2356
2357 <!-- svn checkout gliserver.pl, gsdlCGI.pm for gli applet, as well as gsdlCGI.pm-dependent metadata-server.pl
2358 (checksum.pl is used by GS2 for depositdspace.dm and may eventually be used by GS3 too) -->
2359 <target name="svnupdate-cgi">
2360
2361 <exec executable="svn" dir="web/WEB-INF/cgi">
2362 <arg value="export"/>
2363 <arg value="-r"/><arg value="${branch.revision}"/>
2364 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/gliserver.pl"/>
2365 </exec>
2366 <exec executable="svn" dir="web/WEB-INF/cgi">
2367 <arg value="export"/>
2368 <arg value="-r"/><arg value="${branch.revision}"/>
2369 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/gsdlCGI.pm"/>
2370 </exec>
2371 <exec executable="svn" dir="web/WEB-INF/cgi">
2372 <arg value="export"/>
2373 <arg value="-r"/><arg value="${branch.revision}"/>
2374 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/metadata-server.pl"/>
2375 </exec>
2376 <exec executable="svn" dir="web/WEB-INF/cgi">
2377 <arg value="export"/>
2378 <arg value="-r"/><arg value="${branch.revision}"/>
2379 <arg value="${svn.root}/main/${branch.path}/greenstone2/common-src/cgi-bin/checksum.pl"/>
2380 </exec>
2381 </target>
2382
2383
2384 <target name="clean-gli" depends="init" if="collection.building.enabled">
2385 <!-- gli -->
2386 <property name="gli.home" value="${basedir}/gli"/>
2387 <!-- linux -->
2388 <exec executable="clean.sh" os="${os.unix}" dir="${gli.home}"
2389 resolveExecutable="true" failonerror="true"/>
2390 <!-- windows -->
2391 <exec executable="clean.bat" os="${os.windows}" dir="${gli.home}"
2392 resolveExecutable="true" failonerror="true"/>
2393 </target>
2394
2395 <target name="compile-gli" depends="init" if="collection.building.enabled">
2396 <if><bool><isset property="with.gli.and.gems"/></bool>
2397 <!-- gli -->
2398 <property name="gli.home" value="${basedir}/gli"/>
2399
2400 <!-- linux -->
2401 <exec executable="makegli.sh" os="${os.unix}" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
2402 <!--remote gli-->
2403 <exec executable="makejar.sh" os="${os.unix}" dir="${gli.home}"
2404 resolveExecutable="true" failonerror="true"/>
2405 <!-- windows -->
2406 <exec executable="makegli.bat" os="${os.windows}" dir="${gli.home}" resolveExecutable="true" failonerror="true"/>
2407 <!--remote gli-->
2408 <exec executable="makejar.bat" os="${os.windows}" dir="${gli.home}"
2409 resolveExecutable="true" failonerror="true"/>
2410 <copy file="${gli.home}/GLIServer.jar" todir="${gs2build.home}/bin/java" />
2411 </if>
2412 </target>
2413
2414 <target name="gli" description="Run the Greenstone Librarian Interface" depends="init" if="collection.building.enabled">
2415 <exec executable="${basedir}/gli/gli.sh" os="${os.linux},${os.solaris}" dir="${basedir}/gli" spawn="true">
2416 <env key="gsdl3path" path="${basedir}"/>
2417 <env key="gsdlpath" path="${gs2build.home}"/>
2418 </exec>
2419 <exec executable="${basedir}/gli/gli.sh" os="${os.mac}" dir="${basedir}/gli" spawn="true">
2420 <env key="gsdl3path" path="${basedir}"/>
2421 <env key="gsdlpath" path="${gs2build.home}"/>
2422 <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${gdbm.home}/lib"/>
2423 </exec>
2424 <exec executable="${basedir}/gli/gli.bat" os="${os.windows}" dir="${basedir}/gli" spawn="true">
2425 <env key="GSDL3PATH" path="${basedir}"/>
2426 <env key="GSDLPATH" path="${gs2build.home}"/>
2427 </exec>
2428 <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.
2429 </echo>
2430 </target>
2431
2432 <!-- ================ gs2build targets =========================== -->
2433
2434 <target name="svnupdate-gs2build" if="collection.building.enabled" depends="init" unless="nosvn.mode">
2435 <echo>svn updating gs2build</echo>
2436 <exec executable="svn">
2437 <arg value="update"/>
2438 <arg value="${gs2build.home}"/>
2439 <arg value="-r"/><arg value="${branch.revision}"/>
2440 </exec>
2441 </target>
2442
2443 <target name="prepare-gs2build" depends="init" if="collection.building.enabled" unless="gs2build.present">
2444 <antcall target="checkout-gs2build"/>
2445 <antcall target="prepare-imagemagick"/> <!-- has to be done before calling prepare-gnome-lib -->
2446 <antcall target="prepare-gnome-lib"/>
2447 <antcall target="unzip-windows-packages"/>
2448 <antcall target="checkout-winbin"/>
2449 <antcall target="get-windows-binaries"/>
2450 <antcall target="delete-winbin"/>
2451 </target>
2452
2453 <target name="checkout-gs2build" depends="init" if="collection.building.enabled" unless="nosvn.mode">
2454 <echo>checking out gs2build</echo>
2455 <exec executable="svn">
2456 <arg value="checkout"/>
2457 <arg value="${svn.root}/main/${branch.path}/gs2build"/>
2458 <arg value="-r"/><arg value="${branch.revision}"/>
2459 </exec>
2460 </target>
2461
2462
2463 <target name="prepare-imagemagick" depends="init" if="collection.building.enabled">
2464 <if>
2465 <bool>
2466 <istrue value="${checkout.imagemagick.ext}"/>
2467 </bool>
2468
2469 <antcall target="checkout-imagemagick"/>
2470 <antcall target="compile-imagemagick"/>
2471
2472 <else>
2473 <echo>**** Not preparing imagemagick:</echo>
2474 <echo>property checkout.imagemagick.ext in build.properties was not set or was set to false</echo>
2475 </else>
2476 </if>
2477 </target>
2478
2479 <target name="checkout-imagemagick" depends="init" if="collection.building.enabled" unless="nosvn.mode">
2480
2481 <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
2482 <condition property="imagemagick.src.present">
2483 <available file="${imagemagick.src.dir}" type="dir" />
2484 </condition>
2485
2486 <if>
2487 <bool>
2488 <not><istrue value="${imagemagick.src.present}"/></not>
2489 </bool>
2490
2491 <echo>checking out imagemagick source into the extension area</echo>
2492
2493 <exec executable="svn">
2494 <arg value="checkout"/>
2495 <arg value="${svn.root}/gs2-extensions/imagemagick/trunk/src"/>
2496 <arg value="${imagemagick.src.dir}"/>
2497 </exec>
2498
2499 <else>
2500 <echo>imagemagick source code already exists at ${imagemagick.src.dir}</echo>
2501 </else>
2502 </if>
2503 </target>
2504
2505 <!-- 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. -->
2506 <target name="compile-imagemagick" if="checkout.imagemagick.ext">
2507
2508 <property name="imagemagick.src.dir" value="${gs2build.home}/ext/imagemagick"/>
2509 <property name="imagemagick.compiled.dir" value="${gs2build.home}/ext/imagemagick/${os.bin.dir}"/>
2510
2511 <condition property="imagemagick.src.present">
2512 <available file="${imagemagick.src.dir}" type="dir" />
2513 </condition>
2514 <condition property="imagemagick.compiled.present">
2515 <available file="${imagemagick.compiled.dir}" type="dir"/>
2516 </condition>
2517 <!--<condition property="imagemagick.bin.present">
2518 <available file="${basedir}/wherever/the/imgmagick/binary/is/to/be/found" type="dir" />
2519 </condition>-->
2520
2521 <if>
2522 <bool>
2523 <and>
2524 <istrue value="${imagemagick.src.present}"/> <!-- imagemagick src code is present -->
2525 <not><istrue value="${imagemagick.compiled.present}"/></not> <!-- imagemagick src not compiled yet, so no imagemagick/os subfolder yet -->
2526 </and>
2527 </bool>
2528 <!-- then compile it. Only necessary for mac/linux, since windows has a stable working binary of imagemagick -->
2529 <exec executable="/bin/bash" dir="${imagemagick.src.dir}" failonerror="true">
2530 <arg value="CASCADE-MAKE.sh"/>
2531 </exec>
2532 </if>
2533 </target>
2534
2535
2536 <!-- Compile up gnome-lib src folder if: checkout.gnomelib.ext is turned on, and if not using the binary
2537 version (gnome-lib-minimal), and if the gnome-lib src folder is not already compiled up. -->
2538 <target name="compile-gnome-lib" if="checkout.gnomelib.ext">
2539
2540 <!-- http://stackoverflow.com/questions/3290307/sourcing-a-shell-profile-in-an-ant-build-file
2541 TODO: CASCADE-MAKE already sources devel.bash, but we still want to source it more globally,
2542 so that the rest of the GS3 compilation process also has access to those env variables -->
2543
2544 <property name="gnome.lib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
2545 <property name="gnome.lib.compiled.dir" value="${basedir}/gs2build/ext/gnome-lib/${os.bin.dir}"/>
2546
2547 <condition property="gnome.src.lib.present">
2548 <available file="${gnome.lib.src.dir}" type="dir" />
2549 </condition>
2550 <condition property="gnome.compiled.lib.present">
2551 <available file="${gnome.lib.compiled.dir}" type="dir"/>
2552 </condition>
2553 <condition property="gnome.lib.min.present">
2554 <available file="${basedir}/gs2build/ext/gnome-lib-minimal" type="dir" />
2555 </condition>
2556
2557 <if>
2558 <bool>
2559 <and>
2560 <!-- <istrue value="${checkout.gnomelib.ext}"/> make sure user wants gnome-lib -->
2561 <not><isset property="${gnome.lib.min.present}"/></not> <!-- no gnome-lib-minimal binary present -->
2562 <istrue value="${gnome.src.lib.present}"/> <!-- gnome-lib folder for compilation is present-->
2563 <not><istrue value="${gnome.compiled.lib.present}"/></not> <!-- gnome-lib not yet compiled, so no gnome-lib/os subfolder yet -->
2564 </and>
2565 </bool>
2566
2567 <!-- then compile it. Only necessary for mac/linux, since windows doesn't need gnome lib -->
2568 <exec executable="/bin/bash" dir="${gnome.lib.src.dir}" failonerror="true">
2569 <arg value="CASCADE-MAKE.sh"/>
2570 </exec>
2571 </if>
2572 </target>
2573
2574
2575 <target name="prepare-gnome-lib" depends="init" if="collection.building.enabled" unless="gnome-lib.present">
2576 <if>
2577 <bool>
2578 <istrue value="${checkout.gnomelib.ext}"/>
2579 </bool>
2580
2581 <antcall target="checkout-gnome-lib"/>
2582 <antcall target="compile-gnome-lib"/>
2583
2584 <else>
2585 <echo>**** Not preparing gnome-lib:</echo>
2586 <echo>property checkout.gnomelib.ext in build.properties was not set or was set to false</echo>
2587 </else>
2588 </if>
2589 </target>
2590
2591
2592 <target name="checkout-gnome-lib" depends="init" if="collection.building.enabled" unless="nosvn.mode">
2593
2594 <property name="gnomelib.src.dir" value="${basedir}/gs2build/ext/gnome-lib"/>
2595 <condition property="gnome.src.present">
2596 <available file="${gnomelib.src.dir}" type="dir" />
2597 </condition>
2598
2599 <if>
2600 <bool>
2601 <not><istrue value="${gnome.src.present}"/></not>
2602 </bool>
2603
2604 <echo>checking out gnome-lib extension</echo>
2605 <exec executable="svn">
2606 <arg value="checkout"/>
2607 <arg value="${svn.root}/gs2-extensions/gnome-lib/trunk/src"/>
2608 <arg value="${gs2build.home}/ext/gnome-lib"/>
2609 </exec>
2610
2611 <else>
2612 <echo>gnomelib source code already exists at ${gnomelib.src.dir}</echo>
2613 </else>
2614 </if>
2615
2616 </target>
2617
2618 <target name="checkout-winbin" depends="init" if="current.os.iswindows"
2619 unless="nosvn.mode">
2620
2621 <exec executable="svn">
2622 <arg value="checkout"/>
2623 <arg value="${svn.root}/main/${branch.path}/binaries/windows"/>
2624 <arg value="-r"/><arg value="${branch.revision}"/>
2625 <arg value="winbin"/>
2626 </exec>
2627
2628 </target>
2629
2630 <target name="update-winbin" depends="init" if="current.os.iswindows" unless="nosvn.mode">
2631 <exec executable="svn">
2632 <arg value="update"/>
2633 <arg value="winbin"/>
2634 <arg value="-r"/><arg value="${branch.revision}"/>
2635 </exec>
2636
2637 </target>
2638
2639 <target name="get-windows-binaries" depends="init" if="collection.building.enabled.windows">
2640 <move todir="${gs2build.home}/bin/windows" failonerror="false">
2641 <fileset dir="${basedir}/winbin/bin"/>
2642 </move>
2643 </target>
2644
2645 <target name="delete-winbin" depends="init" if="collection.building.enabled.windows">
2646 <delete dir="${basedir}/winbin"/>
2647 </target>
2648
2649 <target name="unzip-windows-packages" depends="init" if="current.os.iswindows">
2650 <unzip src="${common.src.home}/packages/windows/crypt/crypt.zip"
2651 dest="${common.src.home}/packages/windows/crypt"/>
2652 <untar compression="gzip"
2653 src="${common.src.home}/packages/sqlite/${sqlite.targz.version}"
2654 dest="${common.src.home}/packages/sqlite"/>
2655 <unzip src="${common.src.home}/indexers/packages/windows/iconv/iconv.zip"
2656 dest="${common.src.home}/indexers/packages/windows/iconv"/>
2657 </target>
2658
2659 <target name="gs2build-edit-setup-bat" if="collection.building.enabled.windows">
2660 <!-- we want a windows path in the setup.bat file -->
2661 <pathconvert targetos="windows" property="gs2build.home.windows">
2662 <path path="${gs2build.home}"/>
2663 </pathconvert>
2664 <move file="${gs2build.home}/setup.bat" tofile="${gs2build.home}/setup-tmp.bat">
2665 <filterset>
2666 <filter token="gsdlhome" value="${gs2build.home.windows}"/>
2667 </filterset>
2668 </move>
2669 <move file="${gs2build.home}/setup-tmp.bat" tofile="${gs2build.home}/setup.bat" />
2670 </target>
2671
2672
2673 <target name="clean-build-src" depends="init" if="collection.building.enabled">
2674 <!-- unix: -->
2675 <if><bool><available file="${build.src.home}/Makefile"/></bool>
2676 <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
2677 <arg value="clean"/>
2678 </exec>
2679 </if>
2680 <!-- windows: -->
2681 <exec executable="nmake" dir="${build.src.home}" os="${os.windows}" failonerror="true">
2682 <arg value="/f"/>
2683 <arg value="win32.mak"/>
2684 <arg value="clean"/>
2685 <arg value="GSDLHOME=${gs2build.home}"/>
2686 </exec>
2687 </target>
2688
2689
2690 <target name="distclean-build-src" depends="init,clean-build-src" if="collection.building.enabled">
2691 <!-- unix: -->
2692 <if><bool><available file="${build.src.home}/Makefile"/></bool>
2693 <exec executable="make" os="${os.unix}" dir="${build.src.home}" failonerror="true">
2694 <arg value="distclean"/>
2695 </exec>
2696 </if>
2697 <!-- windows: distclean = clean + remove configure products (remove makefiles). But on Windows there is no removing makefiles, so we just call clean -->
2698 <exec executable="nmake" dir="${build.src.home}" os="${os.windows}" failonerror="true">
2699 <arg value="/f"/>
2700 <arg value="win32.mak"/>
2701 <arg value="clean"/>
2702 <arg value="GSDLHOME=${gs2build.home}"/>
2703 </exec>
2704 </target>
2705
2706 <target name="configure-build-src" depends="init" if="collection.building.enabled"
2707 description="Configure the build-src component">
2708 <exec executable="${build.src.home}/configure" os="${os.unix}"
2709 dir="${build.src.home}" failonerror="true">
2710 <arg value="--prefix=${gs2build.home}"/>
2711 <arg line="${gs2.opt.args} ${static.arg} ${cross.configure.args} ${allargs}"/>
2712 </exec>
2713 </target>
2714
2715 <!-- common-src is done separately and needs to be compiled first -->
2716 <target name="compile-build-src" depends="init" if="collection.building.enabled">
2717
2718 <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
2719 <arg line="${ldlpath.arg}"/>
2720 </exec>
2721
2722 <exec executable="make" dir="${build.src.home}" os="${os.unix}" failonerror="true">
2723 <arg value="install"/>
2724 </exec>
2725
2726 <!-- run the setup script -->
2727 <!-- <exec executable="${compile.windows.c++.setup}" os="${os.windows}" failonerror="true"/>-->
2728 <!--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-->
2729 <exec executable="nmake" dir="${build.src.home}" os="${os.windows}" failonerror="true">
2730 <arg value="/f"/>
2731 <arg value="win32.mak"/>
2732 <arg value="GSDLHOME=${gs2build.home}"/>
2733 </exec>
2734 <exec executable="nmake" dir="${build.src.home}" os="${os.windows}" failonerror="true">
2735 <arg value="/f"/>
2736 <arg value="win32.mak"/>
2737 <arg value="install"/>
2738 <arg value="GSDLHOME=${gs2build.home}"/>
2739 </exec>
2740 </target>
2741
2742
2743 <!-- ======================== TESTING Targets ========================= -->
2744
2745 <target name="test" description="Run the (incomplete) JUnit test suite "
2746 depends="init">
2747 <mkdir dir="${basedir}/test"/>
2748 <junit printsummary="withOutAndErr"
2749 errorproperty="test.failed"
2750 failureproperty="test.failed"
2751 fork="${junit.fork}">
2752 <formatter type="plain"/>
2753 <classpath>
2754 <pathelement location="${build.home}/gsdl3test.jar"/>
2755 <path refid="compile.classpath"/>
2756 </classpath>
2757 <test name="${testcase}" if="testcase"/>
2758 <batchtest todir="${basedir}/test" unless="testcase">
2759 <fileset dir="${build.home}" includes="**/*Test.class" />
2760 </batchtest>
2761 </junit>
2762 <echo>
2763 *********************************************
2764 Test output can be found in directory 'test'
2765 *********************************************
2766 </echo>
2767 </target>
2768
2769 <!-- ======================== FLAX Targets ========================= -->
2770 <target name="prepare-flax" description="check out flax source code from another repository" if="install.flax">
2771 <echo>checking out flax ...</echo>
2772 <mkdir dir="${basedir}/src/java/org/flax"/>
2773 <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/flax"/>
2774 <mkdir dir="${basedir}/src/java/org/greenstone/gsdl3/action/flax"/>
2775 <mkdir dir="${web.home}/WEB-INF/classes/flax"/>
2776 <mkdir dir="${web.home}/interfaces/flax"/>
2777 <mkdir dir="${web.home}/sites/flax"/>
2778 <mkdir dir="${basedir}/flax-resources"/>
2779 <mkdir dir="${basedir}/flax-lib"/>
2780 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/flax"/>
2781 <arg value="src/java/org/flax"/></exec>
2782 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/flax"/>
2783 <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
2784 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/src/java/org/greenstone/gsdl3/action/flax"/>
2785 <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
2786 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/WEB-INF/classes/flax"/>
2787 <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
2788 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/interfaces/flax"/>
2789 <arg value="${web.home}/interfaces/flax"/></exec>
2790 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/web/sites/flax"/>
2791 <arg value="${web.home}/sites/flax"/></exec>
2792 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/flax-resources"/>
2793 <arg value="flax-resources"/></exec>
2794 <exec executable="svn"><arg value="checkout"/><arg value="${flax.checkout.path}/lib"/>
2795 <arg value="flax-lib"/></exec>
2796 <antcall target="flax-copy-del-files" />
2797 </target>
2798
2799 <target name="flax-copy-del-files" description="copy some flax files into the appropriate greenstone3 directories and delete some unwanted greenstone stuff">
2800 <copy file="${web.home}/WEB-INF/classes/flax/web.xml" todir="${web.home}/WEB-INF" overwrite="true" />
2801 <copy todir="${web.home}/WEB-INF/lib">
2802 <fileset dir="${basedir}/flax-lib">
2803 <include name="*.jar"/>
2804 </fileset>
2805 </copy>
2806 <!--<delete dir="${web.home}/sites/gateway"/>
2807 <delete dir="${web.home}/sites/localsite"/>-->
2808 </target>
2809
2810 <target name="update-flax" description="update flax from repository">
2811 <echo>updating flax ...</echo>
2812 <exec executable="svn"><arg value="update"/>
2813 <arg value="src/java/org/flax"/></exec>
2814 <exec executable="svn"><arg value="update"/>
2815 <arg value="src/java/org/greenstone/gsdl3/action/flax"/></exec>
2816 <exec executable="svn"><arg value="update"/>
2817 <arg value="src/java/org/greenstone/gsdl3/flax"/></exec>
2818 <exec executable="svn"><arg value="update"/>
2819 <arg value="${web.home}/WEB-INF/classes/flax"/></exec>
2820 <exec executable="svn"><arg value="update"/>
2821 <arg value="${web.home}/interfaces/flax"/></exec>
2822 <exec executable="svn"><arg value="update"/>
2823 <arg value="${web.home}/web/sites/flax"/></exec>
2824 <exec executable="svn"><arg value="update"/>
2825 <arg value="flax-resources"/></exec>
2826 <exec executable="svn"><arg value="update"/>
2827 <arg value="flax-lib"/></exec>
2828 <antcall target="compile-core" />
2829 </target>
2830
2831 <!-- ========================End of FLAX Targets ========================= -->
2832
2833 <target name="compile-javadocs">
2834 <javadoc packagenames="org.greenstone.*"
2835 sourcepath="src/java"
2836 defaultexcludes="yes"
2837 destdir="docs/javadoc"
2838 author="true"
2839 version="true"
2840 use="true"
2841 windowtitle="Greenstone3 API">
2842 <doctitle><![CDATA[<h1>Greenstone3 API</h1>]]></doctitle>
2843 </javadoc>
2844 </target>
2845
2846<!-- ========== Some distribution targets ======================== -->
2847 <target name="remove-source">
2848 <if><bool><isset property="with.gli.and.gems"/></bool>
2849 <delete includeEmptyDirs="true">
2850 <fileset dir="." defaultexcludes="false">
2851 <patternset refid="greenstone3.source.component"/>
2852 </fileset>
2853 </delete>
2854
2855 <else>
2856 <delete includeEmptyDirs="true">
2857 <fileset dir="." defaultexcludes="false">
2858 <patternset refid="greenstone3.source.no.gli.component"/>
2859 </fileset>
2860 </delete>
2861 </else>
2862 </if>
2863 </target>
2864
2865 <target name="dist-tidy"
2866 description="'tidies-up' a greenstone3 installation for distribution.">
2867
2868 <!-- delete unneeded things -->
2869 <delete dir="${packages.home}/axis"/>
2870 <delete><fileset dir="${packages.home}" includes="*.zip"/></delete>
2871 <delete file="README-SVN.txt"/>
2872 <delete file="build.properties.in"/>
2873
2874 <!-- delete source files -->
2875 <antcall target="remove-source"/>
2876
2877 <!-- create empty directories -->
2878 <mkdir dir="${web.writablehome}/applet"/>
2879 <mkdir dir="${web.writablehome}/logs"/>
2880 <mkdir dir="${web.writablehome}/logs/tmp"/>
2881
2882 <!-- os specific tidy-ups -->
2883 <!-- linux, mac -->
2884 <if><bool><istrue value="${current.os.isunix}"/></bool>
2885 <delete><fileset dir="." includes="*.bat"/></delete>
2886 <if><bool><isset property="with.gli.and.gems"/></bool>
2887 <delete><fileset dir="gli" includes="*.bat"/></delete>
2888 </if>
2889 <delete><fileset dir="gs2build" includes="*.bat"/></delete>
2890 <delete><fileset dir="bin/script" includes="*.bat"/></delete>
2891 <delete file="${basedir}/gs2build/win32cfg.h"/>
2892 <delete file="${basedir}/gs2build/win32.mak"/>
2893 <delete dir="${basedir}/winutil"/>
2894 <delete failonerror="false"><fileset dir="${lib.jni}" includes="*.dll"/></delete>
2895
2896 <!-- windows -->
2897 <else><if><bool><istrue value="${current.os.iswindows}"/></bool>
2898 <delete><fileset dir="." includes="*.sh,*.bash,*.csh"/></delete>
2899 <if><bool><isset property="with.gli.and.gems"/></bool>
2900 <delete><fileset dir="gli" includes="*.sh,*.bash,*.csh"/></delete>
2901 </if>
2902 <delete><fileset dir="gs2build" includes="*.sh,*.bash,*.csh"/></delete>
2903 <delete><fileset dir="bin/script" includes="*.sh,*.bash,*.csh"/></delete>
2904 </if></else></if>
2905
2906 </target>
2907
2908 <!-- fix up executable permissions for binary release -->
2909 <target name="fix-execute-permissions">
2910 <echo>Setting binaries to executable</echo>
2911 <chmod perm="775">
2912 <fileset dir="."><patternset refid="greenstone3.executables"/></fileset>
2913 </chmod>
2914 </target>
2915
2916 <!-- fix up executable permissions for source code release -->
2917 <target name="fix-execute-permissions-source">
2918 <chmod perm="775">
2919 <fileset dir="."><patternset refid="greenstone3.source.executables"/></fileset>
2920 </chmod>
2921 </target>
2922
2923 <!-- for macs, set up the .app shortcuts to gsi, gli, client-gli and gems -->
2924 <target name="gen-mac-shortcuts">
2925 <if><bool><istrue value="${current.os.ismac}"/></bool>
2926 <filter token="gsdl3srchome" value="${basedir}"/>
2927 <copy file="${basedir}/gs3-server.app/Contents/document.wflow.in" tofile="${basedir}/gs3-server.app/Contents/document.wflow" filtering="true" overwrite="true"/>
2928 <copy file="${basedir}/gli.app/Contents/document.wflow.in" tofile="${basedir}/gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
2929 <copy file="${basedir}/client-gli.app/Contents/document.wflow.in" tofile="${basedir}/client-gli.app/Contents/document.wflow" filtering="true" overwrite="true"/>
2930 <copy file="${basedir}/gems.app/Contents/document.wflow.in" tofile="${basedir}/gems.app/Contents/document.wflow" filtering="true" overwrite="true"/>
2931 </if>
2932 </target>
2933
2934 <!-- ============= tweaks for making compilation static ========== -->
2935 <target name="tweak-makefiles" depends="init" if="compile.static">
2936 <antcall target="rtftohtml-add-static" />
2937 </target>
2938
2939 <target name="rtftohtml-add-static" depends="init" if="collection.building.enabled">
2940 <rsr file="${gs2build.home}/build-src/packages/rtftohtml/rtftohtml_src/Makefile" pattern="-o rtftohtml(.{2})EXEEXT(.{1})" replacement="-o rtftohtml$1EXEEXT$2 -static" />
2941 </target>
2942
2943 <target name="run-collection-tests">
2944 <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
2945 <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>
2946 </if>
2947 <for param="testjar">
2948 <path>
2949 <fileset dir="${basedir}" includes="web/sites/*/collect/*/tests/tests.jar"/>
2950 </path>
2951 <sequential>
2952 <echo>Testing @{testjar}</echo>
2953 <java classname="org.junit.runner.JUnitCore" fork="true">
2954 <arg value="gstests.TestClass"/>
2955 <jvmarg value="-DSERVERURL=http://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet} "/>
2956 <classpath>
2957 <fileset dir="${basedir}/ext/testing/lib/java">
2958 <include name="*.jar"/>
2959 </fileset>
2960 <files includes="@{testjar}"/>
2961 </classpath>
2962 </java>
2963 </sequential>
2964 </for>
2965 </target>
2966
2967 <target name="build-collection-tests">
2968 <if><bool><not><available file="${basedir}/ext/testing" type="dir"/></not></bool>
2969 <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>
2970 </if>
2971 <for param="compiledir">
2972 <path>
2973 <dirset dir="${basedir}" includes="web/sites/*/collect/*/tests/src"/>
2974 </path>
2975 <sequential>
2976 <echo>Compiling @{compiledir}</echo>
2977 <if><bool><not><available file="@{compiledir}/../build" type="dir"/></not></bool>
2978 <mkdir dir="@{compiledir}/../build"/>
2979 </if>
2980 <javac
2981 srcdir="@{compiledir}"
2982 destdir="@{compiledir}/../build"
2983 debug="${compile.debug}"
2984 deprecation="${compile.deprecation}"
2985 optimize="${compile.optimize}">
2986 <classpath>
2987 <fileset dir="${basedir}/ext/testing/lib/java">
2988 <include name="*.jar"/>
2989 </fileset>
2990 </classpath>
2991 <include name="gstests/*.java"/>
2992 </javac>
2993 <jar destfile="@{compiledir}/../tests.jar">
2994 <fileset dir="@{compiledir}/../build">
2995 <include name="gstests/**"/>
2996 </fileset>
2997 <manifest>
2998 <attribute name="Built-By" value="${user.name}" />
2999 </manifest>
3000 </jar>
3001 </sequential>
3002 </for>
3003 </target>
3004</project>
Note: See TracBrowser for help on using the repository browser.