debuggers.hg

view tools/control/build-web.xml @ 623:e5cb8bd7ebfe

bitkeeper revision 1.325 (3f0d278fx62UemAA1unbHTgIGvOJ4Q)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/users/rac61/xeno.bk
into labyrinth.cl.cam.ac.uk:/auto/groups/xeno/users/sos22/xeno.bk
author sos22@labyrinth.cl.cam.ac.uk
date Thu Jul 10 08:45:03 2003 +0000 (2003-07-10)
parents bd90bd0c8b23
children 73fab8c399fd
line source
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.
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:
10 docs Static documentation files to be copied to
11 the "docs" subdirectory of your distribution.
13 src Java source code (and associated resource files)
14 to be compiled to the "WEB-INF/classes"
15 subdirectory of your web applicaiton.
17 web Static HTML, JSP, and other content (such as
18 image files), including the WEB-INF subdirectory
19 and its configuration file contents.
21 $Id: build.xml.txt,v 1.7 2002/12/28 09:08:58 jfclere Exp $
22 -->
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 -->
33 <project name="xenctl web interface" default="compile" basedir=".">
37 <!-- ===================== Property Definitions =========================== -->
40 <!--
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:
46 * Definitions on the "ant" command line (ant -Dfoo=bar compile).
48 * Definitions from a "build.properties" file in the top level
49 source directory of this application.
51 * Definitions from a "build.properties" file in the developer's
52 home directory.
54 * Default definitions in this build.xml file.
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.
62 -->
64 <property file="build.properties"/>
65 <property file="${user.home}/build.properties"/>
68 <!-- ==================== File and Directory Names ======================== -->
71 <!--
73 These properties generally define file and directory names (or paths) that
74 affect where the build process stores its outputs.
76 app.name Base name of this application, used to
77 construct filenames and directories.
78 Defaults to "myapp".
80 app.path Context path to which this application should be
81 deployed (defaults to "/" plus the value of the
82 "app.name" property).
84 app.version Version number of this iteration of the application.
86 build.home The directory into which the "prepare" and
87 "compile" targets will generate their output.
88 Defaults to "build".
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.
94 dist.home The name of the base directory in which
95 distribution files are created.
96 Defaults to "dist".
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)
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.
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)
110 -->
112 <property name="app.name" value="myapp"/>
113 <property name="app.path" value="/${app.name}"/>
114 <property name="app.version" value="0.1-dev"/>
115 <property name="build.home" value="${basedir}/build-web"/>
116 <property name="catalina.home" value="../../../.."/> <!-- UPDATE THIS! -->
117 <property name="dist.home" value="${basedir}/dist-web"/>
118 <property name="docs.home" value="${basedir}/docs"/>
119 <!-- <property name="manager.url" value="http://localhost:8080/manager"/> -->
120 <property name="src.home" value="${basedir}/src"/>
121 <property name="web.home" value="${basedir}/web"/>
124 <!-- ================== Custom Ant Task Definitions ======================= -->
127 <!--
129 These properties define custom tasks for the Ant build tool that interact
130 with the "/manager" web application installed with Tomcat 4. Before they
131 can be successfully utilized, you must perform the following steps:
133 - Copy the file "server/lib/catalina-ant.jar" from your Tomcat 4
134 installation into the "lib" directory of your Ant installation.
136 - Create a "build.properties" file in your application's top-level
137 source directory (or your user login home directory) that defines
138 appropriate values for the "manager.password", "manager.url", and
139 "manager.username" properties described above.
141 For more information about the Manager web application, and the functionality
142 of these tasks, see <http://localhost:8080/tomcat-docs/manager-howto.html>.
144 -->
146 <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"/>
147 <taskdef name="list" classname="org.apache.catalina.ant.ListTask"/>
148 <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"/>
149 <taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask"/>
152 <!-- ==================== Compilation Control Options ==================== -->
154 <!--
156 These properties control option settings on the Javac compiler when it
157 is invoked using the <javac> task.
159 compile.debug Should compilation include the debug option?
161 compile.deprecation Should compilation include the deprecation option?
163 compile.optimize Should compilation include the optimize option?
165 -->
167 <property name="compile.debug" value="true"/>
168 <property name="compile.deprecation" value="false"/>
169 <property name="compile.optimize" value="true"/>
173 <!-- ==================== External Dependencies =========================== -->
176 <!--
178 Use property values to define the locations of external JAR files on which
179 your application will depend. In general, these values will be used for
180 two purposes:
181 * Inclusion on the classpath that is passed to the Javac compiler
182 * Being copied into the "/WEB-INF/lib" directory during execution
183 of the "deploy" target.
185 Because we will automatically include all of the Java classes that Tomcat 4
186 exposes to web applications, we will not need to explicitly list any of those
187 dependencies. You only need to worry about external dependencies for JAR
188 files that you are going to include inside your "/WEB-INF/lib" directory.
190 -->
192 <!-- Dummy external dependency -->
193 <!--
194 <property name="foo.jar"
195 value="/path/to/foo.jar"/>
196 -->
199 <!-- ==================== Compilation Classpath =========================== -->
201 <!--
203 Rather than relying on the CLASSPATH environment variable, Ant includes
204 features that makes it easy to dynamically construct the classpath you
205 need for each compilation. The example below constructs the compile
206 classpath to include the servlet.jar file, as well as the other components
207 that Tomcat makes available to web applications automatically, plus anything
208 that you explicitly added.
210 -->
212 <path id="compile.classpath">
214 <!-- Include all JAR files that will be included in /WEB-INF/lib -->
215 <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
216 <!--
217 <pathelement location="${foo.jar}"/>
218 -->
220 <!-- Include all elements that Tomcat exposes to applications -->
221 <pathelement location="${catalina.home}/common/classes"/>
222 <fileset dir="${catalina.home}/common/endorsed">
223 <include name="*.jar"/>
224 </fileset>
225 <fileset dir="${catalina.home}/common/lib">
226 <include name="*.jar"/>
227 </fileset>
228 <pathelement location="${catalina.home}/shared/classes"/>
229 <fileset dir="${catalina.home}/shared/lib">
230 <include name="*.jar"/>
231 </fileset>
233 </path>
237 <!-- ==================== All Target ====================================== -->
239 <!--
241 The "all" target is a shortcut for running the "clean" target followed
242 by the "compile" target, to force a complete recompile.
244 -->
246 <target name="all" depends="clean,compile"
247 description="Clean build and dist directories, then compile"/>
251 <!-- ==================== Clean Target ==================================== -->
253 <!--
255 The "clean" target deletes any previous "build" and "dist" directory,
256 so that you can be ensured the application can be built from scratch.
258 -->
260 <target name="clean"
261 description="Delete old build and dist directories">
262 <delete dir="${build.home}"/>
263 <delete dir="${dist.home}"/>
264 <exec executable="make" dir="${web.home}/tmpl"><arg value="clean"/></exec>
265 </target>
269 <!-- ==================== Compile Target ================================== -->
271 <!--
273 The "compile" target transforms source files (from your "src" directory)
274 into object files in the appropriate location in the build directory.
275 This example assumes that you will be including your classes in an
276 unpacked directory hierarchy under "/WEB-INF/classes".
278 -->
280 <target name="compile" depends="prepare"
281 description="Compile Java sources">
283 <!-- Compile Java classes as necessary -->
284 <mkdir dir="${build.home}/WEB-INF/classes"/>
285 <javac srcdir="${src.home}"
286 destdir="${build.home}/WEB-INF/classes"
287 debug="${compile.debug}"
288 deprecation="${compile.deprecation}"
289 optimize="${compile.optimize}">
290 <classpath refid="compile.classpath"/>
291 <include name="org/xenoserver/control/**"/>
292 <include name="org/xenoserver/web/**"/>
293 </javac>
295 <!-- Copy application resources -->
296 <copy todir="${build.home}/WEB-INF/classes">
297 <fileset dir="${src.home}" excludes="**/*.java"/>
298 </copy>
300 </target>
304 <!-- ==================== Dist Target ===================================== -->
307 <!--
309 The "dist" target creates a binary distribution of your application
310 in a directory structure ready to be archived in a tar.gz or zip file.
311 Note that this target depends on two others:
313 * "compile" so that the entire web application (including external
314 dependencies) will have been assembled
316 * "javadoc" so that the application Javadocs will have been created
318 -->
320 <target name="dist" depends="compile"
321 description="Create binary distribution">
323 <!-- Copy documentation subdirectories -->
324 <mkdir dir="${dist.home}/docs"/>
325 <copy todir="${dist.home}/docs">
326 <fileset dir="${docs.home}"/>
327 </copy>
329 <!-- Create application JAR file -->
330 <jar jarfile="${dist.home}/${app.name}-${app.version}.war"
331 basedir="${build.home}"/>
333 <!-- Copy additional files to ${dist.home} as necessary -->
335 </target>
339 <!-- ==================== Install Target ================================== -->
341 <!--
343 The "install" target tells the specified Tomcat 4 installation to dynamically
344 install this web application and make it available for execution. It does
345 *not* cause the existence of this web application to be remembered across
346 Tomcat restarts; if you restart the server, you will need to re-install all
347 this web application.
349 If you have already installed this application, and simply want Tomcat to
350 recognize that you have updated Java classes (or the web.xml file), use the
351 "reload" target instead.
353 NOTE: This target will only succeed if it is run from the same server that
354 Tomcat is running on.
356 NOTE: This is the logical opposite of the "remove" target.
358 -->
360 <target name="install" depends="compile"
361 description="Install application to servlet container">
363 <install url="${manager.url}"
364 username="${manager.username}"
365 password="${manager.password}"
366 path="${app.path}"
367 war="file://${build.home}"/>
369 </target>
372 <!-- ==================== Javadoc Target ================================== -->
374 <!--
376 The "javadoc" target creates Javadoc API documentation for the Java
377 classes included in your application. Normally, this is only required
378 when preparing a distribution release, but is available as a separate
379 target in case the developer wants to create Javadocs independently.
381 -->
383 <target name="javadoc" depends="compile"
384 description="Create Javadoc API documentation">
386 <mkdir dir="${dist.home}/docs/api"/>
387 <javadoc sourcepath="${src.home}"
388 destdir="${dist.home}/docs/api"
389 packagenames="*">
390 <classpath refid="compile.classpath"/>
391 </javadoc>
393 </target>
397 <!-- ====================== List Target =================================== -->
399 <!--
401 The "list" target asks the specified Tomcat 4 installation to list the
402 currently running web applications, either loaded at startup time or
403 installed dynamically. It is useful to determine whether or not the
404 application you are currently developing has been installed.
406 -->
408 <target name="list"
409 description="List installed applications on servlet container">
411 <list url="${manager.url}"
412 username="${manager.username}"
413 password="${manager.password}"/>
415 </target>
418 <!-- ==================== Prepare Target ================================== -->
420 <!--
422 The "prepare" target is used to create the "build" destination directory,
423 and copy the static contents of your web application to it. If you need
424 to copy static files from external dependencies, you can customize the
425 contents of this task.
427 Normally, this task is executed indirectly when needed.
429 -->
431 <target name="prepare">
433 <!-- Create build directories as needed -->
434 <mkdir dir="${build.home}"/>
435 <mkdir dir="${build.home}/WEB-INF"/>
436 <mkdir dir="${build.home}/WEB-INF/classes"/>
438 <!-- create templates -->
439 <exec executable="make" dir="${web.home}/tmpl"/>
441 <!-- Copy static content of this web application -->
442 <copy todir="${build.home}">
443 <fileset dir="${web.home}"/>
444 </copy>
446 <!-- Copy external dependencies as required -->
447 <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
448 <mkdir dir="${build.home}/WEB-INF/lib"/>
449 <!--
450 <copy todir="${build.home}/WEB-INF/lib" file="${foo.jar}"/>
451 -->
453 <!-- Copy static files from external dependencies as needed -->
454 <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
456 </target>
459 <!-- ==================== Reload Target =================================== -->
461 <!--
463 The "reload" target tells the specified Tomcat 4 installation to dynamically
464 reload this web application, to reflect changes in the underlying classes or
465 the "web.xml" deployment descriptor.
467 -->
469 <target name="reload" depends="compile"
470 description="Reload application on servlet container">
472 <reload url="${manager.url}"
473 username="${manager.username}"
474 password="${manager.password}"
475 path="${app.path}"/>
477 </target>
480 <!-- ==================== Remove Target =================================== -->
482 <!--
484 The "remove" target tells the specified Tomcat 4 installation to dynamically
485 remove this web application from service.
487 NOTE: This is the logical opposite of the "install" target.
489 -->
491 <target name="remove"
492 description="Remove application on servlet container">
494 <remove url="${manager.url}"
495 username="${manager.username}"
496 password="${manager.password}"
497 path="${app.path}"/>
499 </target>
502 <target name="help">
503 <echo>all clean, them compile</echo>
504 <echo>dist create war file</echo>
505 <echo>install install application in servlet container</echo>
506 <echo>list list applications installed in servelet container</echo>
507 <echo>reload reload application in servlet container</echo>
508 <echo>remove dynamically remove web application</echo>
509 </target>
511 </project>