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

Last change on this file since 27829 was 27829, checked in by davidb, 11 years ago

Additional work to help support Greenstone running off a read-only medium, such as a DVD

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