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

Last change on this file since 27834 was 27834, checked in by davidb, 8 years ago

Test for windows relied on a property that had not been set yet (for read-only test). Rearranged to operate correctly

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