0c2841e8d8acbe2e31f3bd03aa19648f9af0886d
[cacert-birdshack.git] / Business Logic / trunk / build.xml
1 <!--
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 -->
17
18 <!--
19 General purpose build script for web applications and web services,
20 including enhanced support for deploying directly to a Tomcat 6
21 based server.
22
23 This build script assumes that the source code of your web application
24 is organized into the following subdirectories underneath the source
25 code directory from which you execute the build script:
26
27 docs Static documentation files to be copied to
28 the "docs" subdirectory of your distribution.
29
30 src Java source code (and associated resource files)
31 to be compiled to the "WEB-INF/classes"
32 subdirectory of your web applicaiton.
33
34 web Static HTML, JSP, and other content (such as
35 image files), including the WEB-INF subdirectory
36 and its configuration file contents.
37
38 $Id: build.xml.txt 562814 2007-08-05 03:52:04Z markt $
39 -->
40
41
42 <!-- A "project" describes a set of targets that may be requested
43 when Ant is executed. The "default" attribute defines the
44 target which is executed if no specific target is requested,
45 and the "basedir" attribute defines the current working directory
46 from which Ant executes the requested task. This is normally
47 set to the current working directory.
48 -->
49
50 <project name="BirdShack Business Logic" default="compile" basedir=".">
51
52
53
54 <!-- ===================== Property Definitions =========================== -->
55
56
57 <!--
58
59 Each of the following properties are used in the build script.
60 Values for these properties are set by the first place they are
61 defined, from the following list:
62
63 * Definitions on the "ant" command line (ant -Dfoo=bar compile).
64
65 * Definitions from a "build.properties" file in the top level
66 source directory of this application.
67
68 * Definitions from a "build.properties" file in the developer's
69 home directory.
70
71 * Default definitions in this build.xml file.
72
73 You will note below that property values can be composed based on the
74 contents of previously defined properties. This is a powerful technique
75 that helps you minimize the number of changes required when your development
76 environment is modified. Note that property composition is allowed within
77 "build.properties" files as well as in the "build.xml" script.
78
79 -->
80
81 <property file="build.properties"/>
82 <!-- <property file="${user.home}/build.properties"/> -->
83
84
85 <!-- ==================== File and Directory Names ======================== -->
86
87
88 <!--
89 These properties generally define file and directory names (or paths) that
90 affect where the build process stores its outputs.
91
92 app.name Base name of this application, used to
93 construct filenames and directories.
94 Defaults to "myapp".
95
96 app.path Context path to which this application should be
97 deployed (defaults to "/" plus the value of the
98 "app.name" property).
99
100 app.version Version number of this iteration of the application.
101
102 build.home The directory into which the "prepare" and
103 "compile" targets will generate their output.
104 Defaults to "build".
105
106 catalina.home The directory in which you have installed
107 a binary distribution of Tomcat 6. This will
108 be used by the "deploy" target.
109
110 dist.home The name of the base directory in which
111 distribution files are created.
112 Defaults to "dist".
113
114 manager.password The login password of a user that is assigned the
115 "manager" role (so that he or she can execute
116 commands via the "/manager" web application)
117
118 manager.url The URL of the "/manager" web application on the
119 Tomcat installation to which we will deploy web
120 applications and web services.
121
122 manager.username The login username of a user that is assigned the
123 "manager" role (so that he or she can execute
124 commands via the "/manager" web application)
125
126 -->
127
128 <property name="app.name" value="bl"/>
129 <property name="app.path" value="/"/>
130 <property name="app.version" value="0.1-dev"/>
131 <property name="build.home" value="${basedir}/build"/>
132 <property name="catalina.home" value="/Users/law/Downloads/apache-tomcat-6.0.18"/> <!-- UPDATE THIS! -->
133 <property name="dist.home" value="${basedir}/dist"/>
134 <property name="docs.home" value="${basedir}/docs"/>
135 <property name="manager.url" value="http://localhost:8080/manager"/>
136 <property name="src.home" value="${basedir}/src"/>
137 <property name="web.home" value="${basedir}/webapps"/>
138
139
140 <!-- ==================== External Dependencies =========================== -->
141
142
143 <!--
144
145 Use property values to define the locations of external JAR files on which
146 your application will depend. In general, these values will be used for
147 two purposes:
148 * Inclusion on the classpath that is passed to the Javac compiler
149 * Being copied into the "/WEB-INF/lib" directory during execution
150 of the "deploy" target.
151
152 Because we will automatically include all of the Java classes that Tomcat 6
153 exposes to web applications, we will not need to explicitly list any of those
154 dependencies. You only need to worry about external dependencies for JAR
155 files that you are going to include inside your "/WEB-INF/lib" directory.
156
157 -->
158
159 <!-- Dummy external dependency -->
160 <!--
161 <property name="foo.jar"
162 value="/path/to/foo.jar"/>
163 -->
164
165
166 <!-- ==================== Compilation Classpath =========================== -->
167
168 <!--
169
170 Rather than relying on the CLASSPATH environment variable, Ant includes
171 features that makes it easy to dynamically construct the classpath you
172 need for each compilation. The example below constructs the compile
173 classpath to include the servlet.jar file, as well as the other components
174 that Tomcat makes available to web applications automatically, plus anything
175 that you explicitly added.
176
177 -->
178
179 <path id="compile.classpath">
180
181 <!-- Include all JAR files that will be included in /WEB-INF/lib -->
182 <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
183 <!--
184 <pathelement location="${foo.jar}"/>
185 -->
186
187 <!-- Include all elements that Tomcat exposes to applications -->
188 <fileset dir="${catalina.home}/bin">
189 <include name="*.jar"/>
190 </fileset>
191 <pathelement location="${catalina.home}/lib"/>
192 <fileset dir="${catalina.home}/lib">
193 <include name="*.jar"/>
194 </fileset>
195
196 </path>
197
198
199
200 <!-- ================== Custom Ant Task Definitions ======================= -->
201
202
203 <!--
204
205 These properties define custom tasks for the Ant build tool that interact
206 with the "/manager" web application installed with Tomcat 6. Before they
207 can be successfully utilized, you must perform the following steps:
208
209 - Copy the file "lib/catalina-ant.jar" from your Tomcat 6
210 installation into the "lib" directory of your Ant installation.
211
212 - Create a "build.properties" file in your application's top-level
213 source directory (or your user login home directory) that defines
214 appropriate values for the "manager.password", "manager.url", and
215 "manager.username" properties described above.
216
217 For more information about the Manager web application, and the functionality
218 of these tasks, see <http://localhost:8080/tomcat-docs/manager-howto.html>.
219
220 -->
221
222 <taskdef resource="org/apache/catalina/ant/catalina.tasks"
223 classpathref="compile.classpath"/>
224
225
226 <!-- ==================== Compilation Control Options ==================== -->
227
228 <!--
229
230 These properties control option settings on the Javac compiler when it
231 is invoked using the <javac> task.
232
233 compile.debug Should compilation include the debug option?
234
235 compile.deprecation Should compilation include the deprecation option?
236
237 compile.optimize Should compilation include the optimize option?
238
239 -->
240
241 <property name="compile.debug" value="true"/>
242 <property name="compile.deprecation" value="false"/>
243 <property name="compile.optimize" value="true"/>
244
245
246
247 <!-- ==================== All Target ====================================== -->
248
249 <!--
250
251 The "all" target is a shortcut for running the "clean" target followed
252 by the "compile" target, to force a complete recompile.
253
254 -->
255
256 <target name="all" depends="clean,compile"
257 description="Clean build and dist directories, then compile"/>
258
259
260
261 <!-- ==================== Clean Target ==================================== -->
262
263 <!--
264
265 The "clean" target deletes any previous "build" and "dist" directory,
266 so that you can be ensured the application can be built from scratch.
267
268 -->
269
270 <target name="clean"
271 description="Delete old build and dist directories">
272 <delete dir="${build.home}"/>
273 <delete dir="${dist.home}"/>
274 </target>
275
276
277
278 <!-- ==================== Compile Target ================================== -->
279
280 <!--
281
282 The "compile" target transforms source files (from your "src" directory)
283 into object files in the appropriate location in the build directory.
284 This example assumes that you will be including your classes in an
285 unpacked directory hierarchy under "/WEB-INF/classes".
286
287 -->
288
289 <target name="compile" depends="prepare"
290 description="Compile Java sources">
291
292 <!-- Compile Java classes as necessary -->
293 <mkdir dir="${build.home}/WEB-INF/classes"/>
294 <javac srcdir="${src.home}"
295 destdir="${build.home}/WEB-INF/classes"
296 debug="${compile.debug}"
297 deprecation="${compile.deprecation}"
298 optimize="${compile.optimize}">
299 <classpath refid="compile.classpath"/>
300 </javac>
301
302 <!-- Copy application resources -->
303 <copy todir="${build.home}/WEB-INF/classes">
304 <fileset dir="${src.home}" excludes="**/*.java"/>
305 </copy>
306
307 </target>
308
309
310
311 <!-- ==================== Dist Target ===================================== -->
312
313
314 <!--
315
316 The "dist" target creates a binary distribution of your application
317 in a directory structure ready to be archived in a tar.gz or zip file.
318 Note that this target depends on two others:
319
320 * "compile" so that the entire web application (including external
321 dependencies) will have been assembled
322
323 * "javadoc" so that the application Javadocs will have been created
324
325 -->
326
327 <target name="dist" depends="compile,javadoc"
328 description="Create binary distribution">
329
330 <!-- Copy documentation subdirectories -->
331 <mkdir dir="${dist.home}/docs"/>
332 <copy todir="${dist.home}/docs">
333 <fileset dir="${docs.home}"/>
334 </copy>
335
336 <!-- Create application JAR file -->
337 <jar jarfile="${dist.home}/${app.name}-${app.version}.war"
338 basedir="${build.home}"/>
339
340 <!-- Copy additional files to ${dist.home} as necessary -->
341
342 </target>
343
344
345
346 <!-- ==================== Install Target ================================== -->
347
348 <!--
349
350 The "install" target tells the specified Tomcat 6 installation to dynamically
351 install this web application and make it available for execution. It does
352 *not* cause the existence of this web application to be remembered across
353 Tomcat restarts; if you restart the server, you will need to re-install all
354 this web application.
355
356 If you have already installed this application, and simply want Tomcat to
357 recognize that you have updated Java classes (or the web.xml file), use the
358 "reload" target instead.
359
360 NOTE: This target will only succeed if it is run from the same server that
361 Tomcat is running on.
362
363 NOTE: This is the logical opposite of the "remove" target.
364
365 -->
366
367 <target name="install" depends="compile"
368 description="Install application to servlet container">
369
370 <deploy url="${manager.url}"
371 username="${manager.username}"
372 password="${manager.password}"
373 path="${app.path}"
374 localWar="file://${build.home}"/>
375
376 </target>
377
378
379 <!-- ==================== Javadoc Target ================================== -->
380
381 <!--
382
383 The "javadoc" target creates Javadoc API documentation for the Java
384 classes included in your application. Normally, this is only required
385 when preparing a distribution release, but is available as a separate
386 target in case the developer wants to create Javadocs independently.
387
388 -->
389
390 <target name="javadoc" depends="compile"
391 description="Create Javadoc API documentation">
392
393 <mkdir dir="${dist.home}/docs/api"/>
394 <javadoc sourcepath="${src.home}"
395 destdir="${dist.home}/docs/api"
396 packagenames="*">
397 <classpath refid="compile.classpath"/>
398 </javadoc>
399
400 </target>
401
402
403
404 <!-- ====================== List Target =================================== -->
405
406 <!--
407
408 The "list" target asks the specified Tomcat 6 installation to list the
409 currently running web applications, either loaded at startup time or
410 installed dynamically. It is useful to determine whether or not the
411 application you are currently developing has been installed.
412
413 -->
414
415 <target name="list"
416 description="List installed applications on servlet container">
417
418 <list url="${manager.url}"
419 username="${manager.username}"
420 password="${manager.password}"/>
421
422 </target>
423
424
425 <!-- ==================== Prepare Target ================================== -->
426
427 <!--
428
429 The "prepare" target is used to create the "build" destination directory,
430 and copy the static contents of your web application to it. If you need
431 to copy static files from external dependencies, you can customize the
432 contents of this task.
433
434 Normally, this task is executed indirectly when needed.
435
436 -->
437
438 <target name="prepare">
439
440 <!-- Create build directories as needed -->
441 <mkdir dir="${build.home}"/>
442 <mkdir dir="${build.home}/WEB-INF"/>
443 <mkdir dir="${build.home}/WEB-INF/classes"/>
444
445
446 <!-- Copy static content of this web application -->
447 <copy todir="${build.home}">
448 <fileset dir="${web.home}"/>
449 </copy>
450
451 <!-- Copy external dependencies as required -->
452 <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
453 <mkdir dir="${build.home}/WEB-INF/lib"/>
454 <!--
455 <copy todir="${build.home}/WEB-INF/lib" file="${foo.jar}"/>
456 -->
457
458 <!-- Copy static files from external dependencies as needed -->
459 <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
460
461 </target>
462
463
464 <!-- ==================== Reload Target =================================== -->
465
466 <!--
467
468 The "reload" signals the specified application Tomcat 6 to shut itself down
469 and reload. This can be useful when the web application context is not
470 reloadable and you have updated classes or property files in the
471 /WEB-INF/classes directory or when you have added or updated jar files in the
472 /WEB-INF/lib directory.
473
474 NOTE: The /WEB-INF/web.xml web application configuration file is not reread
475 on a reload. If you have made changes to your web.xml file you must stop
476 then start the web application.
477
478 -->
479
480 <target name="reload" depends="compile"
481 description="Reload application on servlet container">
482
483 <reload url="${manager.url}"
484 username="${manager.username}"
485 password="${manager.password}"
486 path="${app.path}"/>
487
488 </target>
489
490
491 <!-- ==================== Remove Target =================================== -->
492
493 <!--
494
495 The "remove" target tells the specified Tomcat 6 installation to dynamically
496 remove this web application from service.
497
498 NOTE: This is the logical opposite of the "install" target.
499
500 -->
501
502 <target name="remove"
503 description="Remove application on servlet container">
504
505 <undeploy url="${manager.url}"
506 username="${manager.username}"
507 password="${manager.password}"
508 path="${app.path}"/>
509
510 </target>
511
512
513 </project>