Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

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