1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
<!--*************************************************************************
|
3
|
Filename : build.xml
|
4
|
Project : mapbuilder
|
5
|
Document Type : XML
|
6
|
Purpose : build file for ant tool
|
7
|
|
8
|
Author Date Description
|
9
|
M.Adair 17-Dec-2001 initial version copied from quicklook
|
10
|
|
11
|
$Id$
|
12
|
***************************************************************************--><!--
|
13
|
General purpose build script for web applications and web services,
|
14
|
including enhanced support for deploying directly to a Tomcat 5
|
15
|
based server.
|
16
|
|
17
|
This build script assumes that the source code of your web application
|
18
|
is organized into the following subdirectories underneath the source
|
19
|
code directory from which you execute the build script:
|
20
|
|
21
|
docs Static documentation files to be copied to
|
22
|
the "docs" subdirectory of your distribution.
|
23
|
|
24
|
src Java source code (and associated resource files)
|
25
|
to be compiled to the "WEB-INF/classes"
|
26
|
subdirectory of your web applicaiton.
|
27
|
|
28
|
web Static HTML, JSP, and other content (such as
|
29
|
image files), including the WEB-INF subdirectory
|
30
|
and its configuration file contents.
|
31
|
|
32
|
-->
|
33
|
<!-- A "project" describes a set of targets that may be requested
|
34
|
when Ant is executed. The "default" attribute defines the
|
35
|
target which is executed if no specific target is requested,
|
36
|
and the "basedir" attribute defines the current working directory
|
37
|
from which Ant executes the requested task. This is normally
|
38
|
set to the current working directory.
|
39
|
-->
|
40
|
<project basedir=".." default="deploy-tomcat" name="mapbuilder">
|
41
|
|
42
|
<!-- ===================== Property Definitions =========================== -->
|
43
|
<!--
|
44
|
Each of the following properties are used in the build script.
|
45
|
Values for these properties are set by the first place they are
|
46
|
defined, from the following list:
|
47
|
|
48
|
* Definitions on the "ant" command line (ant -Dfoo=bar compile).
|
49
|
|
50
|
* Definitions from a "build.properties" file in the top level
|
51
|
source directory of this application.
|
52
|
|
53
|
* Definitions from a "build.properties" file in the developer's
|
54
|
home directory.
|
55
|
|
56
|
* Default definitions in this build.xml file.
|
57
|
|
58
|
You will note below that property values can be composed based on the
|
59
|
contents of previously defined properties. This is a powerful technique
|
60
|
that helps you minimize the number of changes required when your development
|
61
|
environment is modified. Note that property composition is allowed within
|
62
|
"build.properties" files as well as in the "build.xml" script.
|
63
|
-->
|
64
|
<property file="build.properties"/>
|
65
|
<property file="${user.home}/build.properties"/>
|
66
|
|
67
|
<!-- ==================== File and Directory Names ======================== -->
|
68
|
<!--
|
69
|
|
70
|
These properties generally define file and directory names (or paths) that
|
71
|
affect where the build process stores its outputs.
|
72
|
|
73
|
app.name Base name of this application, used to
|
74
|
construct filenames and directories.
|
75
|
Defaults to "myapp".
|
76
|
|
77
|
app.path Context path to which this application should be
|
78
|
deployed (defaults to "/" plus the value of the
|
79
|
"app.name" property).
|
80
|
|
81
|
app.version Version number of this iteration of the application.
|
82
|
|
83
|
build.home The directory into which the "prepare" and
|
84
|
"compile" targets will generate their output.
|
85
|
Defaults to "build".
|
86
|
|
87
|
catalina.home The directory in which you have installed
|
88
|
a binary distribution of Tomcat 5. This will
|
89
|
be used by the "deploy" target.
|
90
|
|
91
|
dist.home The name of the base directory in which
|
92
|
distribution files are created.
|
93
|
Defaults to "dist".
|
94
|
|
95
|
manager.password The login password of a user that is assigned the
|
96
|
"manager" role (so that he or she can execute
|
97
|
commands via the "/manager" web application)
|
98
|
|
99
|
manager.url The URL of the "/manager" web application on the
|
100
|
Tomcat installation to which we will deploy web
|
101
|
applications and web services.
|
102
|
|
103
|
manager.username The login username of a user that is assigned the
|
104
|
"manager" role (so that he or she can execute
|
105
|
commands via the "/manager" web application)
|
106
|
|
107
|
-->
|
108
|
|
109
|
<property environment="env"/>
|
110
|
<property name="app.name" value="mapbuilder"/>
|
111
|
<property name="pack.name" value="mapbuilder-lib"/>
|
112
|
<property name="app.path" value="/${app.name}"/>
|
113
|
<property name="app.version" value="0.4-alpha"/>
|
114
|
<property name="catalina.home" value="${env.CATALINA_HOME}"/> <!-- ensure you have this environment var set -->
|
115
|
<property name="build.home" value="${basedir}/build"/>
|
116
|
<property name="compress.home" value="${basedir}/compressBuild"/>
|
117
|
<property name="deploy.home" value="${catalina.home}/webapps/${app.name}"/>
|
118
|
<property name="dist.home" value="${basedir}/dist"/>
|
119
|
<property name="docs.home" value="${build.home}/docs"/>
|
120
|
<property name="dev.home" value="${basedir}/."/>
|
121
|
<property name="context.home" value="${dev.home}/server/java"/>
|
122
|
<property name="src.home" value="${context.home}/src"/>
|
123
|
|
124
|
|
125
|
<!-- ==================== External Dependencies =========================== -->
|
126
|
|
127
|
<!--
|
128
|
Use property values to define the locations of external JAR files on which
|
129
|
your application will depend. In general, these values will be used for
|
130
|
two purposes:
|
131
|
* Inclusion on the classpath that is passed to the Javac compiler
|
132
|
* Being copied into the "/WEB-INF/lib" directory during execution
|
133
|
of the "deploy" target.
|
134
|
|
135
|
Because we will automatically include all of the Java classes that Tomcat 5
|
136
|
exposes to web applications, we will not need to explicitly list any of those
|
137
|
dependencies. You only need to worry about external dependencies for JAR
|
138
|
files that you are going to include inside your "/WEB-INF/lib" directory.
|
139
|
-->
|
140
|
|
141
|
<!--
|
142
|
<property name="foo.jar" value="$/lib/foo.jar"/>
|
143
|
-->
|
144
|
<property name="httpClient.jar" value="${context.home}/lib/commons-httpclient-2.0.1.jar"/>
|
145
|
<property name="logging.jar" value="${context.home}/lib/commons-logging.jar"/>
|
146
|
<property name="log4j.jar" value="${context.home}/lib/log4j-1.2.8.jar"/>
|
147
|
<property name="jstl.jar" value="${context.home}/lib/jstl.jar"/>
|
148
|
<property name="standard.jar" value="${context.home}/lib/standard.jar"/>
|
149
|
|
150
|
|
151
|
<!-- ==================== Prepare Target ================================== -->
|
152
|
|
153
|
<!--
|
154
|
|
155
|
The "prepare" target is used to create the "build" destination directory,
|
156
|
and copy the static contents of your web application to it. If you need
|
157
|
to copy static files from external dependencies, you can customize the
|
158
|
contents of this task.
|
159
|
|
160
|
Normally, this task is executed indirectly when needed.
|
161
|
|
162
|
-->
|
163
|
|
164
|
<target name="prepare">
|
165
|
|
166
|
<!-- Create build directories as needed -->
|
167
|
<mkdir dir="${build.home}"/>
|
168
|
|
169
|
<!-- Copy static content of the mapbuilder project -->
|
170
|
<copy todir="${build.home}">
|
171
|
<fileset dir="${basedir}"
|
172
|
includes="demo/** lib/** docs/** server/php/** CHANGES LICENSE LGPL README index.html"/>
|
173
|
</copy>
|
174
|
<copy file="${basedir}/server/php/mapbuilderConfig.xml" todir="${build.home}/lib" overwrite="true"/>
|
175
|
|
176
|
</target>
|
177
|
|
178
|
<target name="prepare-tomcat" depends="prepare">
|
179
|
|
180
|
<!-- Create build directories as needed -->
|
181
|
<mkdir dir="${build.home}"/>
|
182
|
<mkdir dir="${build.home}/WEB-INF"/>
|
183
|
<mkdir dir="${build.home}/WEB-INF/classes"/>
|
184
|
|
185
|
<!-- Copy static content of this web application -->
|
186
|
<copy todir="${build.home}">
|
187
|
<fileset dir="${context.home}/web"/>
|
188
|
</copy>
|
189
|
<copy file="${context.home}/web/lib/mapbuilderConfig.xml" todir="${build.home}/lib" overwrite="true"/>
|
190
|
|
191
|
<!-- set the global server config file to the JSP version -->
|
192
|
<echo message="setting mbServerConfig URL to JSP version"/>
|
193
|
<delete file="${build.home}/lib/Mapbuilder.js.temp" quiet="true"/>
|
194
|
<copy file="${basedir}/lib/Mapbuilder.js" todir="${build.home}/lib" overwrite="true"/>
|
195
|
<replace file="${build.home}/lib/Mapbuilder.js" token="mapbuilderConfig.xml" value="mapbuilderConfig.jsp"/>
|
196
|
|
197
|
<!-- copy all files from etc to WEB-INF; includes tld files and scaf tokens-->
|
198
|
<copy todir="${build.home}/WEB-INF">
|
199
|
<fileset dir="${context.home}/etc">
|
200
|
</fileset>
|
201
|
</copy>
|
202
|
|
203
|
<!-- Copy external dependencies as required -->
|
204
|
<!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
|
205
|
<mkdir dir="${build.home}/WEB-INF/lib"/>
|
206
|
<!--
|
207
|
<copy todir="${build.home}/WEB-INF/lib" file="${foo.jar}"/>
|
208
|
-->
|
209
|
<copy todir="${build.home}/WEB-INF/lib" file="${httpClient.jar}"/>
|
210
|
<copy todir="${build.home}/WEB-INF/lib" file="${logging.jar}"/>
|
211
|
<copy todir="${build.home}/WEB-INF/lib" file="${log4j.jar}"/>
|
212
|
<copy todir="${build.home}/WEB-INF/lib" file="${jstl.jar}"/>
|
213
|
<copy todir="${build.home}/WEB-INF/lib" file="${standard.jar}"/>
|
214
|
|
215
|
</target>
|
216
|
|
217
|
|
218
|
<!-- ==================== All Target ====================================== -->
|
219
|
|
220
|
<!--
|
221
|
|
222
|
The "all" target is a shortcut for running the "clean" target followed
|
223
|
by the "compile" target, to force a complete recompile.
|
224
|
|
225
|
-->
|
226
|
|
227
|
<target depends="clean,compile" description="Clean build and dist directories, then compile" name="all"/>
|
228
|
|
229
|
|
230
|
|
231
|
<!-- ==================== Clean Target ==================================== -->
|
232
|
|
233
|
<!--
|
234
|
|
235
|
The "clean" target deletes any previous "build" and "dist" directory,
|
236
|
so that you can be ensured the application can be built from scratch.
|
237
|
|
238
|
-->
|
239
|
|
240
|
<target description="Delete old build and dist directories" name="clean">
|
241
|
<delete dir="${build.home}"/>
|
242
|
<delete dir="${dist.home}"/>
|
243
|
<delete dir="${compress.home}"/>
|
244
|
</target>
|
245
|
|
246
|
|
247
|
|
248
|
<!-- ==================== Clean Tomcat ==================================== -->
|
249
|
|
250
|
<target description="Delete old build and dist directories" name="clean-tomcat">
|
251
|
<delete dir="${deploy.home}"/>
|
252
|
</target>
|
253
|
|
254
|
|
255
|
|
256
|
<!-- ==================== Documentation =================================== -->
|
257
|
|
258
|
<target description="Create documentation" name="docs">
|
259
|
|
260
|
<mkdir dir="${build.home}/docs"/>
|
261
|
|
262
|
<!-- style the design docs from the XBook document -->
|
263
|
<!--style in="${basedir}/design/mapbuilder-lib.xml" style="/usr/share/sgml/docbook/xsl-stylesheets/html/docbook.xsl" out="${build.home}/docs/design/index.html"/-->
|
264
|
|
265
|
<echo message="os name=${os.name}"/>
|
266
|
<exec executable="${basedir}/bin/publish.sh" os="linux">
|
267
|
</exec>
|
268
|
</target>
|
269
|
|
270
|
<!-- ==================== Compilation Control Options ==================== -->
|
271
|
|
272
|
<!--
|
273
|
These properties control option settings on the Javac compiler when it
|
274
|
is invoked using the <javac> task.
|
275
|
|
276
|
compile.debug Should compilation include the debug option?
|
277
|
compile.deprecation Should compilation include the deprecation option?
|
278
|
compile.optimize Should compilation include the optimize option?
|
279
|
-->
|
280
|
<property name="compile.debug" value="false"/>
|
281
|
<property name="compile.deprecation" value="false"/>
|
282
|
<property name="compile.optimize" value="true"/>
|
283
|
|
284
|
|
285
|
<!-- ==================== External Dependencies =========================== -->
|
286
|
<!--
|
287
|
Use property values to define the locations of external JAR files on which
|
288
|
your application will depend. In general, these values will be used for
|
289
|
two purposes:
|
290
|
* Inclusion on the classpath that is passed to the Javac compiler
|
291
|
* Being copied into the "/WEB-INF/lib" directory during execution
|
292
|
of the "deploy" target.
|
293
|
|
294
|
Because we will automatically include all of the Java classes that Tomcat 5
|
295
|
exposes to web applications, we will not need to explicitly list any of those
|
296
|
dependencies. You only need to worry about external dependencies for JAR
|
297
|
files that you are going to include inside your "/WEB-INF/lib" directory.
|
298
|
-->
|
299
|
|
300
|
<!--
|
301
|
<property name="foo.jar" value="${context.home}/lib/foo.jar"/>
|
302
|
-->
|
303
|
|
304
|
<!-- ==================== Compilation Classpath =========================== -->
|
305
|
<!--
|
306
|
Rather than relying on the CLASSPATH environment variable, Ant includes
|
307
|
features that makes it easy to dynamically construct the classpath you
|
308
|
need for each compilation. The example below constructs the compile
|
309
|
classpath to include the servlet.jar file, as well as the other components
|
310
|
that Tomcat makes available to web applications automatically, plus anything
|
311
|
that you explicitly added.
|
312
|
-->
|
313
|
|
314
|
<path id="compile.classpath">
|
315
|
|
316
|
<!-- Include all JAR files that will be included in /WEB-INF/lib -->
|
317
|
<!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
|
318
|
<!--
|
319
|
<pathelement location="${foo.jar}"/>
|
320
|
-->
|
321
|
<pathelement location="${httpClient.jar}"/>
|
322
|
<pathelement location="${logging.jar}"/>
|
323
|
<pathelement location="${log4j.jar}"/>
|
324
|
|
325
|
<!-- Include all elements that Tomcat exposes to applications -->
|
326
|
<pathelement location="${catalina.home}/common/classes"/>
|
327
|
<fileset dir="${catalina.home}/common/endorsed">
|
328
|
<include name="*.jar"/>
|
329
|
</fileset>
|
330
|
<fileset dir="${catalina.home}/common/lib">
|
331
|
<include name="*.jar"/>
|
332
|
</fileset>
|
333
|
<pathelement location="${catalina.home}/shared/classes"/>
|
334
|
<fileset dir="${catalina.home}/shared/lib">
|
335
|
<include name="*.jar"/>
|
336
|
</fileset>
|
337
|
|
338
|
</path>
|
339
|
|
340
|
<!-- ==================== Compile Target ================================== -->
|
341
|
<!--
|
342
|
The "compile" target transforms source files (from your "src" directory)
|
343
|
into object files in the appropriate location in the build directory.
|
344
|
This example assumes that you will be including your classes in an
|
345
|
unpacked directory hierarchy under "/WEB-INF/classes".
|
346
|
-->
|
347
|
|
348
|
<target name="compile" depends="prepare-tomcat" description="Compile Java sources">
|
349
|
|
350
|
<!-- Compile Java classes as necessary -->
|
351
|
<mkdir dir="${build.home}/WEB-INF/classes"/>
|
352
|
<javac srcdir="${src.home}"
|
353
|
destdir="${build.home}/WEB-INF/classes"
|
354
|
debug="${compile.debug}"
|
355
|
deprecation="${compile.deprecation}"
|
356
|
optimize="${compile.optimize}">
|
357
|
<classpath refid="compile.classpath"/>
|
358
|
</javac>
|
359
|
|
360
|
<!-- Copy application resources -->
|
361
|
<copy todir="${build.home}/WEB-INF/classes">
|
362
|
<fileset dir="${src.home}" excludes="**/*.java"/>
|
363
|
</copy>
|
364
|
|
365
|
</target>
|
366
|
|
367
|
|
368
|
<!-- =================== Compress Target ================================== -->
|
369
|
|
370
|
<target description="Compress JS and XSL files" name="compress" depends="prepare">
|
371
|
<copy todir="${compress.home}">
|
372
|
<fileset dir="${build.home}"/>
|
373
|
</copy>
|
374
|
|
375
|
<exec executable="${basedir}/bin/compress.sh" os="linux"/>
|
376
|
</target>
|
377
|
|
378
|
|
379
|
<!-- ==================== Deploy ========================================== -->
|
380
|
<!--
|
381
|
The "deploy" target synchronizes the build directory with the Java Servlet
|
382
|
container directory. This could also be done by copying in the war file.
|
383
|
-->
|
384
|
<target name="deploy-tomcat"
|
385
|
description="Copy build directory to $CATALINA_HOME"
|
386
|
depends="compile">
|
387
|
<mkdir dir="${deploy.home}"/>
|
388
|
<copy todir="${deploy.home}">
|
389
|
<fileset dir="${build.home}">
|
390
|
</fileset>
|
391
|
</copy>
|
392
|
</target>
|
393
|
|
394
|
|
395
|
|
396
|
<!-- ==================== Dist Target ===================================== -->
|
397
|
<!--
|
398
|
|
399
|
The "dist" target creates a binary distribution of your application
|
400
|
in a directory structure ready to be archived in a tar.gz or zip file.
|
401
|
Note that this target depends on two others:
|
402
|
|
403
|
* "compile" so that the entire web application (including external
|
404
|
dependencies) will have been assembled
|
405
|
-->
|
406
|
|
407
|
<target
|
408
|
name="dist"
|
409
|
description="Create binary distribution"
|
410
|
depends="clean,docs">
|
411
|
|
412
|
<!-- first do the apache distribution -->
|
413
|
<antcall target="dist-apache"/>
|
414
|
|
415
|
<!-- remove the compress directory, recreated in tomcat distribution -->
|
416
|
<delete dir="${compress.home}"/>
|
417
|
|
418
|
<!-- do the tomcat distribution -->
|
419
|
<antcall target="dist-tomcat"/>
|
420
|
|
421
|
</target>
|
422
|
|
423
|
<!--
|
424
|
The "dist-tomcat" target creates the war file distribution of your application
|
425
|
only without creating all docs, zips, etc. This is to be used for deploying
|
426
|
your application to a produciton server.
|
427
|
-->
|
428
|
<target
|
429
|
name="dist-tomcat"
|
430
|
description="Create binary distribution"
|
431
|
depends="compile,compress"
|
432
|
>
|
433
|
|
434
|
<mkdir dir="${dist.home}"/>
|
435
|
|
436
|
<!-- Create source WAR file -->
|
437
|
<jar jarfile="${dist.home}/${app.name}.war" basedir="${compress.home}"/>
|
438
|
|
439
|
<!-- zip up the application WAR file -->
|
440
|
<zip destfile="${dist.home}/${pack.name}-${app.version}-war.zip" update="true">
|
441
|
<zipfileset file="${dist.home}/${app.name}.war"/>
|
442
|
</zip>
|
443
|
</target>
|
444
|
|
445
|
<!--
|
446
|
The "dist-apache" target creates the zip file distribution for the Apache/PHP
|
447
|
environment.
|
448
|
-->
|
449
|
<target
|
450
|
name="dist-apache"
|
451
|
description="Create binary distribution"
|
452
|
depends="prepare,compress"
|
453
|
>
|
454
|
|
455
|
<mkdir dir="${dist.home}"/>
|
456
|
|
457
|
<!-- Create source zip file -->
|
458
|
<zip destfile="${dist.home}/${pack.name}-src-${app.version}.zip" update="true">
|
459
|
<zipfileset dir="${basedir}" excludes="build/** dist/** compressBuild/** client/** design/**" prefix="mapbuilder"/>
|
460
|
</zip>
|
461
|
|
462
|
<!-- Create application zip file -->
|
463
|
<zip destfile="${dist.home}/${pack.name}-${app.version}.zip" update="true">
|
464
|
<zipfileset dir="${compress.home}" prefix="mapbuilder"/>
|
465
|
</zip>
|
466
|
|
467
|
</target>
|
468
|
|
469
|
</project>
|