1 | <!--
|
---|
2 | General purpose build script for web applications and web services,
|
---|
3 | including enhanced support for deploying directly to a Tomcat 4
|
---|
4 | based server.
|
---|
5 |
|
---|
6 | This build script assumes that the source code of your web application
|
---|
7 | is organized into the following subdirectories underneath the source
|
---|
8 | code directory from which you execute the build script:
|
---|
9 |
|
---|
10 | docs Static documentation files to be copied to
|
---|
11 | the "docs" subdirectory of your distribution.
|
---|
12 |
|
---|
13 | src Java source code (and associated resource files)
|
---|
14 | to be compiled to the "WEB-INF/classes"
|
---|
15 | subdirectory of your web applicaiton.
|
---|
16 |
|
---|
17 | web Static HTML, JSP, and other content (such as
|
---|
18 | image files), including the WEB-INF subdirectory
|
---|
19 | and its configuration file contents.
|
---|
20 |
|
---|
21 | $Id: build.xml 10077 2005-06-13 03:48:12Z kjdon $
|
---|
22 | -->
|
---|
23 |
|
---|
24 |
|
---|
25 | <!-- A "project" describes a set of targets that may be requested
|
---|
26 | when Ant is executed. The "default" attribute defines the
|
---|
27 | target which is executed if no specific target is requested,
|
---|
28 | and the "basedir" attribute defines the current working directory
|
---|
29 | from which Ant executes the requested task. This is normally
|
---|
30 | set to the current working directory.
|
---|
31 | -->
|
---|
32 |
|
---|
33 | <project name="GSDL Alerting Service" default="compile" basedir=".">
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 | <!-- ===================== Property Definitions =========================== -->
|
---|
38 |
|
---|
39 |
|
---|
40 | <!--
|
---|
41 |
|
---|
42 | Each of the following properties are used in the build script.
|
---|
43 | Values for these properties are set by the first place they are
|
---|
44 | defined, from the following list:
|
---|
45 |
|
---|
46 | * Definitions on the "ant" command line (ant -Dfoo=bar compile).
|
---|
47 |
|
---|
48 | * Definitions from a "build.properties" file in the top level
|
---|
49 | source directory of this application.
|
---|
50 |
|
---|
51 | * Definitions from a "build.properties" file in the developer's
|
---|
52 | home directory.
|
---|
53 |
|
---|
54 | * Default definitions in this build.xml file.
|
---|
55 |
|
---|
56 | You will note below that property values can be composed based on the
|
---|
57 | contents of previously defined properties. This is a powerful technique
|
---|
58 | that helps you minimize the number of changes required when your development
|
---|
59 | environment is modified. Note that property composition is allowed within
|
---|
60 | "build.properties" files as well as in the "build.xml" script.
|
---|
61 |
|
---|
62 | -->
|
---|
63 |
|
---|
64 | <property file="build.properties"/>
|
---|
65 | <property file="${user.home}/build.properties"/>
|
---|
66 |
|
---|
67 |
|
---|
68 | <!-- ==================== File and Directory Names ======================== -->
|
---|
69 |
|
---|
70 |
|
---|
71 | <!--
|
---|
72 |
|
---|
73 | These properties generally define file and directory names (or paths) that
|
---|
74 | affect where the build process stores its outputs.
|
---|
75 |
|
---|
76 | app.name Base name of this application, used to
|
---|
77 | construct filenames and directories.
|
---|
78 | Defaults to "myapp".
|
---|
79 |
|
---|
80 | app.path Context path to which this application should be
|
---|
81 | deployed (defaults to "/" plus the value of the
|
---|
82 | "app.name" property).
|
---|
83 |
|
---|
84 | app.version Version number of this iteration of the application.
|
---|
85 |
|
---|
86 | build.home The directory into which the "prepare" and
|
---|
87 | "compile" targets will generate their output.
|
---|
88 | Defaults to "build".
|
---|
89 |
|
---|
90 | catalina.home The directory in which you have installed
|
---|
91 | a binary distribution of Tomcat 4. This will
|
---|
92 | be used by the "deploy" target.
|
---|
93 |
|
---|
94 | dist.home The name of the base directory in which
|
---|
95 | distribution files are created.
|
---|
96 | Defaults to "dist".
|
---|
97 |
|
---|
98 | manager.password The login password of a user that is assigned the
|
---|
99 | "manager" role (so that he or she can execute
|
---|
100 | commands via the "/manager" web application)
|
---|
101 |
|
---|
102 | manager.url The URL of the "/manager" web application on the
|
---|
103 | Tomcat installation to which we will deploy web
|
---|
104 | applications and web services.
|
---|
105 |
|
---|
106 | manager.username The login username of a user that is assigned the
|
---|
107 | "manager" role (so that he or she can execute
|
---|
108 | commands via the "/manager" web application)
|
---|
109 |
|
---|
110 | -->
|
---|
111 |
|
---|
112 | <property name="app.name" value="gsdl-as"/>
|
---|
113 | <property name="app.path" value="/alerting"/>
|
---|
114 | <property name="app.version" value="0.1-dev"/>
|
---|
115 | <property name="build.home" value="${basedir}/build"/>
|
---|
116 | <property name="catalina.home" value="../../comms/jakarta/tomcat/"/>
|
---|
117 | <property name="dist.home" value="${basedir}/dist"/>
|
---|
118 | <property name="docs.home" value="${basedir}/docs"/>
|
---|
119 | <property name="docs.link" value="http://java.sun.com/j2se/1.4.2/docs/api/"/>
|
---|
120 | <property name="manager.url" value="http://localhost:8080/manager"/>
|
---|
121 | <property name="manager.username" value="admin"/>
|
---|
122 | <property name="manager.password" value="admin"/>
|
---|
123 | <property name="src.home" value="${basedir}/src"/>
|
---|
124 | <property name="web.home" value="${basedir}/web"/>
|
---|
125 |
|
---|
126 |
|
---|
127 | <!-- ================== Custom Ant Task Definitions ======================= -->
|
---|
128 |
|
---|
129 |
|
---|
130 | <!--
|
---|
131 |
|
---|
132 | These properties define custom tasks for the Ant build tool that interact
|
---|
133 | with the "/manager" web application installed with Tomcat 4. Before they
|
---|
134 | can be successfully utilized, you must perform the following steps:
|
---|
135 |
|
---|
136 | - Copy the file "server/lib/catalina-ant.jar" from your Tomcat 4
|
---|
137 | installation into the "lib" directory of your Ant installation.
|
---|
138 |
|
---|
139 | - Create a "build.properties" file in your application's top-level
|
---|
140 | source directory (or your user login home directory) that defines
|
---|
141 | appropriate values for the "manager.password", "manager.url", and
|
---|
142 | "manager.username" properties described above.
|
---|
143 |
|
---|
144 | For more information about the Manager web application, and the functionality
|
---|
145 | of these tasks, see <http://localhost:8080/tomcat-docs/manager-howto.html>.
|
---|
146 |
|
---|
147 | -->
|
---|
148 |
|
---|
149 | <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"
|
---|
150 | classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
|
---|
151 | <taskdef name="list" classname="org.apache.catalina.ant.ListTask"
|
---|
152 | classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
|
---|
153 | <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"
|
---|
154 | classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
|
---|
155 | <taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask"
|
---|
156 | classpath="${catalina.home}/server/lib/catalina-ant.jar"/>
|
---|
157 |
|
---|
158 |
|
---|
159 | <!-- ==================== Compilation Control Options ==================== -->
|
---|
160 |
|
---|
161 | <!--
|
---|
162 |
|
---|
163 | These properties control option settings on the Javac compiler when it
|
---|
164 | is invoked using the <javac> task.
|
---|
165 |
|
---|
166 | compile.debug Should compilation include the debug option?
|
---|
167 |
|
---|
168 | compile.deprecation Should compilation include the deprecation option?
|
---|
169 |
|
---|
170 | compile.optimize Should compilation include the optimize option?
|
---|
171 |
|
---|
172 | -->
|
---|
173 |
|
---|
174 | <property name="compile.debug" value="true"/>
|
---|
175 | <property name="compile.deprecation" value="false"/>
|
---|
176 | <property name="compile.optimize" value="true"/>
|
---|
177 |
|
---|
178 |
|
---|
179 |
|
---|
180 | <!-- ==================== External Dependencies =========================== -->
|
---|
181 |
|
---|
182 |
|
---|
183 | <!--
|
---|
184 |
|
---|
185 | Use property values to define the locations of external JAR files on which
|
---|
186 | your application will depend. In general, these values will be used for
|
---|
187 | two purposes:
|
---|
188 | * Inclusion on the classpath that is passed to the Javac compiler
|
---|
189 | * Being copied into the "/WEB-INF/lib" directory during execution
|
---|
190 | of the "deploy" target.
|
---|
191 |
|
---|
192 | Because we will automatically include all of the Java classes that Tomcat 4
|
---|
193 | exposes to web applications, we will not need to explicitly list any of those
|
---|
194 | dependencies. You only need to worry about external dependencies for JAR
|
---|
195 | files that you are going to include inside your "/WEB-INF/lib" directory.
|
---|
196 |
|
---|
197 | -->
|
---|
198 |
|
---|
199 | <!-- Dummy external dependency -->
|
---|
200 | <!--
|
---|
201 | <property name="foo.jar"
|
---|
202 | value="/path/to/foo.jar"/>
|
---|
203 | -->
|
---|
204 |
|
---|
205 |
|
---|
206 | <!-- ==================== Compilation Classpath =========================== -->
|
---|
207 |
|
---|
208 | <!--
|
---|
209 |
|
---|
210 | Rather than relying on the CLASSPATH environment variable, Ant includes
|
---|
211 | features that makes it easy to dynamically construct the classpath you
|
---|
212 | need for each compilation. The example below constructs the compile
|
---|
213 | classpath to include the servlet.jar file, as well as the other components
|
---|
214 | that Tomcat makes available to web applications automatically, plus anything
|
---|
215 | that you explicitly added.
|
---|
216 |
|
---|
217 | -->
|
---|
218 |
|
---|
219 | <path id="compile.classpath">
|
---|
220 |
|
---|
221 | <!-- Include all JAR files that will be included in /WEB-INF/lib -->
|
---|
222 | <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
|
---|
223 | <fileset dir="lib">
|
---|
224 | <include name="*.jar"/>
|
---|
225 | </fileset>
|
---|
226 | <!-- include greenstone files -->
|
---|
227 | <fileset dir="../../web/WEB-INF/lib/">
|
---|
228 | <include name="*.jar"/>
|
---|
229 | </fileset>
|
---|
230 | <!-- Include all elements that Tomcat exposes to applications -->
|
---|
231 | <pathelement location="${catalina.home}/common/classes"/>
|
---|
232 | <fileset dir="${catalina.home}/common/endorsed">
|
---|
233 | <include name="*.jar"/>
|
---|
234 | </fileset>
|
---|
235 | <fileset dir="${catalina.home}/common/lib">
|
---|
236 | <include name="*.jar"/>
|
---|
237 | </fileset>
|
---|
238 | <pathelement location="${catalina.home}/shared/classes"/>
|
---|
239 | <fileset dir="${catalina.home}/shared/lib">
|
---|
240 | <include name="*.jar"/>
|
---|
241 | </fileset>
|
---|
242 |
|
---|
243 | </path>
|
---|
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 4 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 | <install url="${manager.url}"
|
---|
371 | username="${manager.username}"
|
---|
372 | password="${manager.password}"
|
---|
373 | path="${app.path}"
|
---|
374 | war="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 | link="${docs.link}"
|
---|
397 | private="true"
|
---|
398 | packagenames="*">
|
---|
399 | <classpath refid="compile.classpath"/>
|
---|
400 | </javadoc>
|
---|
401 |
|
---|
402 | </target>
|
---|
403 |
|
---|
404 |
|
---|
405 |
|
---|
406 | <!-- ====================== List Target =================================== -->
|
---|
407 |
|
---|
408 | <!--
|
---|
409 |
|
---|
410 | The "list" target asks the specified Tomcat 4 installation to list the
|
---|
411 | currently running web applications, either loaded at startup time or
|
---|
412 | installed dynamically. It is useful to determine whether or not the
|
---|
413 | application you are currently developing has been installed.
|
---|
414 |
|
---|
415 | -->
|
---|
416 |
|
---|
417 | <target name="list"
|
---|
418 | description="List installed applications on servlet container">
|
---|
419 |
|
---|
420 | <list url="${manager.url}"
|
---|
421 | username="${manager.username}"
|
---|
422 | password="${manager.password}"/>
|
---|
423 |
|
---|
424 | </target>
|
---|
425 |
|
---|
426 |
|
---|
427 | <!-- ==================== Prepare Target ================================== -->
|
---|
428 |
|
---|
429 | <!--
|
---|
430 |
|
---|
431 | The "prepare" target is used to create the "build" destination directory,
|
---|
432 | and copy the static contents of your web application to it. If you need
|
---|
433 | to copy static files from external dependencies, you can customize the
|
---|
434 | contents of this task.
|
---|
435 |
|
---|
436 | Normally, this task is executed indirectly when needed.
|
---|
437 |
|
---|
438 | -->
|
---|
439 |
|
---|
440 | <target name="prepare">
|
---|
441 |
|
---|
442 | <!-- Create build directories as needed -->
|
---|
443 | <mkdir dir="${build.home}"/>
|
---|
444 | <mkdir dir="${build.home}/WEB-INF"/>
|
---|
445 | <mkdir dir="${build.home}/WEB-INF/classes"/>
|
---|
446 |
|
---|
447 |
|
---|
448 | <!-- Copy static content of this web application -->
|
---|
449 | <copy todir="${build.home}">
|
---|
450 | <fileset dir="${web.home}"/>
|
---|
451 | </copy>
|
---|
452 |
|
---|
453 | <jar destfile="lib/templates.jar" basedir="lib/templates" includes="*.vm"/>
|
---|
454 |
|
---|
455 | <!-- Copy external dependencies as required -->
|
---|
456 | <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
|
---|
457 | <mkdir dir="${build.home}/WEB-INF/lib"/>
|
---|
458 | <copy todir="${build.home}/WEB-INF/lib">
|
---|
459 | <fileset dir="lib" includes="*.jar"/>
|
---|
460 | </copy>
|
---|
461 |
|
---|
462 | <!-- Copy static files from external dependencies as needed -->
|
---|
463 | <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
|
---|
464 |
|
---|
465 | </target>
|
---|
466 |
|
---|
467 |
|
---|
468 | <!-- ==================== Reload Target =================================== -->
|
---|
469 |
|
---|
470 | <!--
|
---|
471 |
|
---|
472 | The "reload" signals the specified application Tomcat 4 to shut itself down
|
---|
473 | and reload. This can be useful when the web application context is not
|
---|
474 | reloadable and you have updated classes or property files in the
|
---|
475 | /WEB-INF/classes directory or when you have added or updated jar files in the
|
---|
476 | /WEB-INF/lib directory.
|
---|
477 |
|
---|
478 | NOTE: The /WEB-INF/web.xml web application configuration file is not reread
|
---|
479 | on a reload. If you have made changes to your web.xml file you must stop
|
---|
480 | then start the web application.
|
---|
481 |
|
---|
482 | -->
|
---|
483 |
|
---|
484 | <target name="reload" depends="compile"
|
---|
485 | description="Reload application on servlet container">
|
---|
486 |
|
---|
487 | <reload url="${manager.url}"
|
---|
488 | username="${manager.username}"
|
---|
489 | password="${manager.password}"
|
---|
490 | path="${app.path}"/>
|
---|
491 |
|
---|
492 | </target>
|
---|
493 |
|
---|
494 |
|
---|
495 | <!-- ==================== Remove Target =================================== -->
|
---|
496 |
|
---|
497 | <!--
|
---|
498 |
|
---|
499 | The "remove" target tells the specified Tomcat 4 installation to dynamically
|
---|
500 | remove this web application from service.
|
---|
501 |
|
---|
502 | NOTE: This is the logical opposite of the "install" target.
|
---|
503 |
|
---|
504 | -->
|
---|
505 |
|
---|
506 | <target name="remove"
|
---|
507 | description="Remove application on servlet container">
|
---|
508 |
|
---|
509 | <remove url="${manager.url}"
|
---|
510 | username="${manager.username}"
|
---|
511 | password="${manager.password}"
|
---|
512 | path="${app.path}"/>
|
---|
513 |
|
---|
514 | </target>
|
---|
515 |
|
---|
516 |
|
---|
517 | </project>
|
---|