File: build.xml

package info (click to toggle)
cocoon2 20010420-1
  • links: PTS
  • area: contrib
  • in suites: woody
  • size: 15,864 kB
  • ctags: 3,013
  • sloc: java: 18,267; xml: 7,879; sh: 86; makefile: 64; sql: 16; python: 16
file content (699 lines) | stat: -rw-r--r-- 32,223 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
<!-- ===========================================================================


                       * =========================== *
                       |  Apache Cocoon Build System |
                       * =========================== *

                                     by

                     Stefano Mazzocchi <stefano@apache.org>


Installing the build tools
==========================

The Cocoon build system is based on Apache Ant, which is a Java building tool
originally developed for the Tomcat project but now used in many other
Apache projects and extended by many developers.

Ant is a little but very handy tool that uses a build file written in XML
(this file) as building instructions. For more information refer to
"http://jakarta.apache.org/ant/".

To make things easier for you, the Cocoon distribution contains a precompiled
version of Ant and the build scripts take care of running it.

The only thing that you have to make sure, is the "JAVA_HOME" environment
property should be set to match the JVM you want to use. 

That's all you have to do to be ready to go.


Building instructions
=====================

Ok, let's build the baby. First, make sure your current working directory is
where this very file is located. Then type

  ./build.sh (unix)
  .\build.bat (win32)

if everything is right and all the required packages are visible, this action
will generate a file called "cocoon.jar" in the "./build/cocoon" directory.
Note, that if you do further development, compilation time is reduced since
Ant is able of detecting which files have changed and to recompile them at need.

Also, you'll note that reusing a single JVM instance for each task, increases
tremendously the performance of the whole build system, compared to other
tools (i.e. make or shell scripts) where a new JVM is started for each task.


Building on another directory
=============================

Sometimes you might want to build on an external directory to keep the 
distribution clean: no worries, this is just an environment property away.
Suppose you want to use the "../build" directory instead, you simply tipe

 [unix]  ./build.sh  -Dbuild.root=../build
 [win32] .\build.bat -Dbuild.root=..\build

By using the -Dxxx=yyy argument, you are setting environments in the JVM: Ant
is designed to give higher priority to system environments to allow you to
modify _any_ <property> that you can find in the building instructions below,
so it's just a matter of understanding what property you want to change
and you don't have to touch this file (which you shouldn't need to do).


Build targets
=============

The build system is not only responsible of compiling Cocoon into a jar file,
but is also responsible for creating the HTML documentation, javadocs,
distributions and web site. In fact, the file you have here is _exactly_ what
is used by cocoon maintainers to take care of everything in the Cocoon
project, no less and no more.

To know more about the available targets take a look at this file, which is
pretty self-explanatory or type

 [unix]  ./build.sh  -projecthelp
 [win32] .\build.bat -projecthelp

and concentrate on the target descriptions that start with a star '*': these
are the one you should call, the others are internal targets that are called
by the main ones.

                              Happy hacking from the Apache Cocoon Dev Team :)

============================================================================ -->

<project default="package" basedir=".">

  <!--
    Give user a chance to override without editing this file
    (and without typing -D each time he compiles it)
  -->
  <property file=".ant.properties"/>
  <property file="${user.home}/.ant.properties"/>

  <!--
    these are here only for those who use jikes compiler. For other
    developers this part makes no difference.
  -->
  <property name="build.compiler.emacs" value="on"/>
  <property name="build.compiler.warnings" value="true"/>
  <property name="build.compiler.pedantic" value="false"/>
  <property name="build.compiler.depend" value="true"/>
  <property name="build.compiler.fulldepend" value="true"/>

  <!-- =================================================================== -->
  <!-- Indentify Classpath                                                 -->
  <!-- =================================================================== -->
  <path id="classpath">
    <fileset dir="./lib">
      <include name="*.jar"/>
    </fileset>
  </path>

  <!-- =================================================================== -->
  <!-- Initialization target                                               -->
  <!-- =================================================================== -->
  <target name="init">
    <tstamp/>
    <property name="fullname" value="Apache Cocoon"/>
    <property name="Name"     value="Cocoon"/>
    <property name="name"     value="cocoon"/>
    <property name="version"  value="2.0a5"/>
    <property name="year"     value="1999-2001"/>

    <echo message="------------------- ${fullname} ${version} [${year}] ----------------"/>

    <property name="debug"          value="on"/>
    <property name="optimize"       value="off"/>
    <property name="deprecation"    value="off"/>
    <property name="build.compiler" value="classic"/>
    <property name="target.vm"      value="1.2"/>

    <property name="src.dir"      value="./src"/>
    <property name="lib.dir"      value="./lib"/>
    <property name="docs.dir"     value="./xdocs"/>
    <property name="dtd.dir"      value="./xdocs/dtd"/>
    <property name="skins.dir"    value="./skins"/>
    <property name="images.dir"   value="./xdocs/images"/>
    <property name="webapp.dir"   value="./webapp"/>
    <property name="resource.dir" value="./resources"/>
    <property name="packages"     value="org.apache.*"/>

    <property name="browser.skin" value="${skins.dir}/xml.apache.org/"/>
    <property name="printer.skin" value="${skins.dir}/printer/"/>
    <property name="browser.projfile" value="docs-book.xml"/>
    <property name="site.projfile" value="site-book.xml"/>
    <property name="doc.generator" value="org.apache.stylebook.StyleBook"/>

    <property name="build.root"     value="./build"/>
    <property name="build.dir"      value="${build.root}/${name}"/>
    <property name="build.src"      value="${build.dir}/src"/>
    <property name="build.dest"     value="${build.dir}/classes"/>
    <property name="build.docs"     value="${build.dir}/docs"/>
    <property name="build.xdocs"    value="${build.dir}/xdocs"/>
    <property name="build.docs.printer" value="${build.dir}/printer-docs"/>
    <property name="build.war"      value="${build.dir}/webapp"/>
    <property name="build.javadocs" value="${build.dir}/javadocs"/>

    <property name="dist.root"   value="./dist"/>
    <property name="dist.dir"    value="${dist.root}/${name}-${version}"/>
    <property name="dist.target" value="${dist.root}"/>

    <property name="site" value="../xml-site/targets/${name}"/>

    <filter token="name"    value="${fullname}"/>
    <filter token="year"    value="${year}"/>
    <filter token="version" value="${version}"/>
    <filter token="date"    value="${TODAY}"/>
    <filter token="log"     value="true"/>
    <filter token="verbose" value="true"/>

    <!-- Add filters for loading database information from database.properties file -->
    <property file="database.properties"/>
    <filter token="database-driver" value="${database-driver}"/>
    <filter token="database-url" value="${database-url}"/>
    <filter token="database-user" value="${database-user}"/>
    <filter token="database-password" value="${database-password}"/>

    <available property="servlet.present" classname="javax.servlet.http.HttpServlet">
      <classpath refid="classpath"/>
    </available>
    <available property="php.present" classname="net.php.servlet">
      <classpath refid="classpath"/>
    </available>
    <available property="xt.present" classname="com.jclark.xsl.sax.XMLProcessorImpl">
      <classpath refid="classpath"/>
    </available>
    <available property="svg.present" classname="org.apache.batik.transcoder.Transcoder">
      <classpath refid="classpath"/>
    </available>
    <available property="rhino.present" classname="org.mozilla.javascript.tools.jsc.Main">
      <classpath refid="classpath"/>
    </available>
    <available property="jstyle.present" classname="jstyle.JSFormatter">
      <classpath refid="classpath"/>
    </available>
    <available property="fop.present" classname="org.apache.fop.apps.Driver">
      <classpath refid="classpath"/>
    </available>
    <available property="tidy.present" classname="org.w3c.tidy.Tidy">
      <classpath refid="classpath"/>
    </available>
    <available property="servlet23.present"
        classname="javax.servlet.http.HttpServletRequestWrapper">
      <classpath refid="classpath"/>
    </available>
    <available property="xpath.present" classname="org.apache.xpath.XPathAPI">
      <classpath refid="classpath"/>
    </available>
    <available property="ora.driver.present" classname="oracle.sql.BLOB">
      <classpath refid="classpath"/>
    </available>
    <available property="mail.present" classname="javax.mail.Session">
      <classpath refid="classpath"/>
    </available>
  </target>

  <!-- =================================================================== -->
  <!-- Prepares the build directory                                        -->
  <!-- =================================================================== -->
  <target name="prepare" depends="init">
    <mkdir dir="${build.dir}"/>
  </target>

  <!-- =================================================================== -->
  <!-- Prepares the source code                                            -->
  <!-- =================================================================== -->
  <target name="prepare-src-main" depends="prepare,generate-java-code">
    <mkdir dir="${build.src}"/>
    <mkdir dir="${build.dest}"/>
    <copy todir="${build.src}" filtering="on">
      <fileset dir="${src.dir}">
        <exclude name="**/http/RequestWrapper2*.java"/>
        <exclude name="**/Ora*.java" unless="ora.driver.present"/>
        <exclude name="**/Sendmail*.java" unless="mail.present"/>
        <exclude name="**/browser/*.x*"/>
      </fileset>
    </copy>
  </target>

  <!-- =================================================================== -->
  <!-- Prepares the servlet 2.3 source code                                -->
  <!-- =================================================================== -->
  <target name="prepare-src-23" depends="prepare-src-main" if="servlet23.present">
    <copy file="${src.dir}/org/apache/cocoon/environment/http/RequestWrapper23.java"
        tofile="${build.src}/org/apache/cocoon/environment/http/RequestWrapper.java"
        filtering="on"/>
  </target>

  <!-- =================================================================== -->
  <!-- Prepares the servlet 2.2 source code                                -->
  <!-- =================================================================== -->
  <target name="prepare-src-22" depends="prepare-src-23" unless="servlet23.present">
    <copy file="${src.dir}/org/apache/cocoon/environment/http/RequestWrapper22.java"
        tofile="${build.src}/org/apache/cocoon/environment/http/RequestWrapper.java"
        filtering="on"/>
  </target>

  <!-- =================================================================== -->
  <!-- Prepares the source code                                            -->
  <!-- =================================================================== -->
  <target name="prepare-src" depends="prepare-src-22"/>

  <!-- =================================================================== -->
  <!-- Set a variable if the generated java code is already up-to-date.    -->
  <!-- =================================================================== -->
  <target name="generate-java-code-check" depends="init">
    <uptodate property="generate-java-code.notrequired"
        targetfile="${build.src}/org/apache/cocoon/components/browser/BrowserImpl.java" >
      <srcfiles dir="${src.dir}/org/apache/cocoon/components/browser"
          includes="BrowserImpl.xml,BrowserImpl.xsl"/>
    </uptodate>
  </target>

  <!-- =================================================================== -->
  <!-- Generate the Java code from XML using XSLT                          -->
  <!-- =================================================================== -->
  <target name="generate-java-code" depends="generate-java-code-check"
          unless="generate-java-code.notrequired">
    <style basedir="${src.dir}/org/apache/cocoon/components/browser"
           destdir="${build.src}/org/apache/cocoon/components/browser"
           includes="BrowserImpl.xml"
           extension=".java"
           style="BrowserImpl.xsl"/>
  </target>


  <!-- =================================================================== -->
  <!-- Compiles the source directory                                       -->
  <!-- =================================================================== -->
  <target name="compile" depends="prepare-src"
          description="Compiles the source code">
    <copy todir="${build.dest}">
      <fileset dir="${build.src}">
        <include name="**/Manifest.mf"/>
        <include name="**/*.xsl"/>
	<include name="**/*.roles"/>
      </fileset>
    </copy>

    <javac srcdir="${build.src}"
           destdir="${build.dest}"
           debug="${debug}"
           optimize="${optimize}"
           deprecation="${deprecation}"
           target="${target.vm}">
      <classpath refid="classpath"/>
      <exclude name="**/*.html"/>
      <exclude name="**/CocoonServlet*.java" unless="servlet.present"/>
      <exclude name="**/XT*.java"            unless="xt.present"/>
      <exclude name="**/SVG*.java"           unless="svg.present"/>
      <exclude name="**/Javascript*"         unless="rhino.present"/>
      <exclude name="**/Jstyle*"             unless="jstyle.present"/>
      <exclude name="**/FOP*"                unless="fop.present"/>
      <exclude name="**/Php*"                unless="php.present"/>
      <exclude name="**/HTMLGenerator.java"  unless="tidy.present"/>
      <exclude name="**/J2eeDataSource.java" unless="j2ee.present"/>
      <exclude name="**/XIncludeTransformer.java" unless="xpath.present"/>
      <exclude name="**/Ora*"                unless="ora.driver.present"/>
    </javac>
  </target>

  <!-- =================================================================== -->
  <!-- Creates the jar file                                                -->
  <!-- =================================================================== -->
  <target name="package" depends="compile" description="Generates the jar package">
    <jar jarfile="${build.dir}/${name}.jar" manifest="${build.src}/Manifest.mf">
      <fileset dir="${build.dest}" includes="org/**"/>
    </jar>
  </target>

  <!-- =================================================================== -->
  <!-- Prapares the webapp directories                                     -->
  <!-- =================================================================== -->
  <target name="prepare-webapp" depends="prepare">
    <mkdir dir="${build.war}"/>

    <copy todir="${build.war}" filtering="on">
      <fileset dir="${webapp.dir}">
        <exclude name="**/*.gif"/>
        <exclude name="**/*.jpg"/>
        <exclude name="**/*.png"/>
      </fileset>
    </copy>

    <copy todir="${build.war}" filtering="off">
      <fileset dir="${webapp.dir}">
        <include name="**/*.gif"/>
        <include name="**/*.jpg"/>
        <include name="**/*.png"/>
      </fileset>
    </copy>
  </target>

  <!-- =================================================================== -->
  <!-- Prepares the libraries for the war package                          -->
  <!-- =================================================================== -->
  <target name="prepare-xsp" depends="package" if="compile.xsp">
    <java classname="org.apache.cocoon.Main" fork="yes">
      <arg line="-x -w ${build.war}/WEB-INF/classes -c webapp" />
      <classpath>
        <fileset dir="lib">
          <include name="**/*.jar"/>
        </fileset>
        <pathelement location="${build.dir}/${name}.jar"/>
        <pathelement location="${java.home}/../lib/tools.jar"/>
      </classpath>
    </java>  
  </target>

  <!-- =================================================================== -->
  <!-- Prepares the libraries for the war package                          -->
  <!-- =================================================================== -->
  <target name="prepare-webapp-libs" depends="package" if="include.webapp.libs">
    <copy todir="${build.war}/WEB-INF/lib">
      <fileset dir="${lib.dir}">
        <include name="*.jar"/>
        <exclude name="ant*.jar"/>
        <exclude name="stylebook*.jar"/>
        <exclude name="servlet*.jar"/>
      </fileset>
    </copy>

    <!-- NOTE: java.home is normally set by the JVM to the /jre directory -->
    <copy file="${java.home}/../lib/tools.jar" tofile="${build.war}/WEB-INF/lib/javac.jar"/>
    <copy file="${build.dir}/${name}.jar" tofile="${build.war}/WEB-INF/lib/${name}-${version}.jar"/>
  </target>

  <!-- =================================================================== -->
  <!-- Creates the war file                                                -->
  <!-- =================================================================== -->
  <target name="webapp" depends="prepare-webapp, prepare-webapp-libs, prepare-xsp" description="Generates the war package">
    <jar jarfile="${build.dir}/${name}.war" basedir="${build.war}" includes="**"/>
  </target>

  <!-- =================================================================== -->
  <!-- Creates a local webapp directly useable as a servlet context        -->
  <!-- =================================================================== -->
  <target name="webapp-local" depends="prepare-webapp, prepare-webapp-libs"
      description="Generates a local webapp directory usable as servlet context for quicker turn around">
    <!-- delete file="${build.war}/WEB-INF/lib/${name}-${version}.jar"/ -->
    <copy todir="${build.war}/WEB-INF/classes">
      <fileset dir="${build.dest}"/>
    </copy>
  </target>

  <!-- =================================================================== -->
  <!-- Removes existing uncompressed webapp                                -->
  <!-- =================================================================== -->
  <target name="remove-webapp" if="remove.webapp" description="Removes existing uncompressed webapp" depends="init">
    <delete dir="${install.war}/${name}"/>
  </target>
  
  <!-- =================================================================== -->
  <!-- Installs Cocoon file                                                -->
  <!-- =================================================================== -->
  <target name="install" depends="package, webapp, remove-webapp" if="install.war" description="Installs the war package">
    <copy file="${build.dir}/${name}.war" tofile="${install.war}/${name}.war"/>
  </target>

  <!-- =================================================================== -->
  <!-- Prepares the docs                                                   -->
  <!-- =================================================================== -->
  <target name="prepare-docs" depends="init">
    <mkdir dir="${build.xdocs}"/>

    <!-- make filtered copy of XML docs -->
    <copy todir="${build.xdocs}" filtering="on">
      <fileset dir="${docs.dir}">
        <exclude name="**/*.gif"/>
        <exclude name="**/*.png"/>
        <exclude name="**/*.jpg"/>
      </fileset>
    </copy>

    <copy todir="${build.xdocs}" filtering="off">
      <fileset dir="${docs.dir}">
        <include name="**/*.gif"/>
        <include name="**/*.png"/>
        <include name="**/*.jpg"/>
      </fileset>
    </copy>

    <copy file="changes.xml" tofile="${build.xdocs}/changes.xml" filtering="on"/>
    <copy file="todo.xml"    tofile="${build.xdocs}/todo.xml"/>

    <replace file="${build.xdocs}/changes.xml" token="./xdocs/dtd/" value="dtd/"/>
    <replace file="${build.xdocs}/todo.xml"    token="./xdocs/dtd/" value="dtd/"/>
  </target>


  <!-- =================================================================== -->
  <!-- Set a variable if the generated docs are already up-to-date.        -->
  <!-- =================================================================== -->
  <target name="docs_check" depends="init">
    <uptodate property="docs.notrequired" targetfile="${build.docs}/index.html" >
      <srcfiles dir="." includes="changes.xml,todo.xml"/>
      <srcfiles dir="${docs.dir}" includes="*.xml" excludes="${site.projfile}"/>
    </uptodate>
  </target>
 
  <!-- =================================================================== -->
  <!-- If generated  docs is already up-to-date, print a message saying so. -->
  <!-- =================================================================== -->
  <target name="docs_done" if="docs.notrequired">
    <echo message="-------------------------------------------------------------"/>
    <echo message="Not rebuilding docs, as they are up-to-date:"/>
    <echo message="  ${build.docs}/index.html is more recent than"/>
    <echo message="  todo.xml, changes.xml, ${docs.dir}/*.xml"/>
    <echo message="-------------------------------------------------------------"/>
  </target>

  <!-- =================================================================== -->
  <!-- Generate HTML docs                                                  -->
  <!-- =================================================================== -->
  <target name="docs" depends="prepare-docs, docs_check, docs_done"
      unless="docs.notrequired"
      description="Generates the documentation">
    <mkdir dir="${build.docs}"/>
    <copy file="${build.xdocs}/docs-book.xml" tofile="${build.xdocs}/book.xml"/>
    <java classname="${doc.generator}" fork="yes">
      <classpath refid="classpath"/>
      <arg line="targetDirectory=${build.docs} ${build.xdocs}/book.xml ${browser.skin}"/>
    </java>
  </target>

  <!-- =================================================================== -->
  <!-- Set a variable if the generated printer docs are already up-to-date. -->
  <!-- =================================================================== -->
  <target name="printer-docs_check" depends="init">
    <uptodate property="printer-docs.notrequired" targetfile="${build.docs.printer}/index.html" >
      <srcfiles dir="." includes="changes.xml,todo.xml"/>
      <srcfiles dir="${docs.dir}" includes="*.xml" excludes="${site.projfile}"/>
    </uptodate>
  </target>
 
  <!-- =================================================================== -->
  <!-- If generated printer docs is already up-to-date, print a message saying so. -->
  <!-- =================================================================== -->
  <target name="printer-docs_done" if="printer-docs.notrequired">
    <echo message="-------------------------------------------------------------"/>
    <echo message="Not rebuilding printer docs, as they are up-to-date:"/>
    <echo message="  ${build.docs.printer}/index.html is more recent than"/>
    <echo message="  todo.xml, changes.xml, ${docs.dir}/*.xml"/>
    <echo message="-------------------------------------------------------------"/>
  </target>

  <!-- =================================================================== -->
  <!-- Generate printer-friendly HTML docs                                 -->
  <!-- =================================================================== -->
  <target name="printer-docs" depends="prepare-docs, printer-docs_check, printer-docs_done"
      unless="printer-docs.notrequired"
      description="Generates printer-friendly documentation">
    <mkdir dir="${build.docs.printer}"/>
    <copy file="${build.xdocs}/${browser.projfile}" tofile="${build.xdocs}/book.xml"/>
    <java classname="${doc.generator}" fork="yes">
      <classpath refid="classpath"/>
      <arg line="targetDirectory=${build.docs.printer} ${build.xdocs}/book.xml ${printer.skin}"/>
    </java>
  </target>

  <!-- =================================================================== -->
  <!-- Set a variable if the generated site is already up-to-date.         -->
  <!-- =================================================================== -->
  <target name="site_check" depends="init">
    <uptodate property="site.notrequired" targetfile="${site}/index.html" >
      <srcfiles dir="." includes="changes.xml,todo.xml"/>
      <srcfiles dir="${docs.dir}" includes="*.xml" excludes="${browser.projfile}"/>
    </uptodate>
  </target>

  <!-- =================================================================== -->
  <!-- If generated site is already up-to-date, print a message saying so. -->
  <!-- =================================================================== -->
  <target name="site_done" if="site.notrequired">
    <echo message="-------------------------------------------------------------"/>
    <echo message="Not rebuilding site, as it is up-to-date:"/>
    <echo message="  ${site}/index.html is more recent than"/>
    <echo message="  todo.xml, changes.xml, ${docs.dir}/*.xml"/>
    <echo message="-------------------------------------------------------------"/>
  </target>

  <!-- =================================================================== -->
  <!-- Creates the web site                                                -->
  <!-- =================================================================== -->
  <target name="site" depends="prepare-docs, site_check, site_done"
      unless="site.notrequired"
      description="Generates the web site (for site maintainers only)">
    <mkdir dir="${site}"/>
    <copy file="${build.xdocs}/${site.projfile}" tofile="${build.xdocs}/book.xml"/>
    <java classname="${doc.generator}" fork="yes">
      <classpath refid="classpath"/>
      <arg line="targetDirectory=${site} ${build.xdocs}/book.xml ${browser.skin}"/>
    </java>
  </target>

  <!-- =================================================================== -->
  <!-- Set a variable if javadoc is already up-to-date.                    -->
  <!-- =================================================================== -->
  <target name="javadocs_check">
    <uptodate property="javadocs.notrequired" targetfile="${build.javadocs}/packages.html" >
      <srcfiles dir= "${build.src}" includes="**/*.java"/>
    </uptodate>
  </target>
  
  <!-- =================================================================== -->
  <!-- If javadoc is already up-to-date, print a message saying so.        -->
  <!-- =================================================================== -->
  <target name="javadocs_done" if="javadocs.notrequired">
    <echo message="-------------------------------------------------------------"/>
    <echo message="Not rebuilding Javadocs, as they are up-to-date:"/>
    <echo message="  ${build.javadocs}/packages.html is more recent than"/>
    <echo message="  ${build.src}/**/*.java"/>
    <echo message="-------------------------------------------------------------"/>
  </target>

  <!-- =================================================================== -->
  <!-- Creates the API documentation                                       -->
  <!-- =================================================================== -->
  <target name="javadocs" depends="prepare-src, javadocs_check, javadocs_done"
      unless="javadocs.notrequired"
      description="Generates the API documentation">
    <mkdir dir="${build.javadocs}"/>
    <javadoc packagenames="${packages}"
             sourcepath="${build.src}"
             destdir="${build.javadocs}"
             author="true"
             version="true"
             use="false"
             noindex="true"
             windowtitle="${Name} API"
             doctitle="${Name}"
             bottom="Copyright &#169; ${year} Apache Software Foundation. All Rights Reserved."
             stylesheetfile="${resource.dir}/javadoc.css">
      <classpath refid="classpath"/>
    </javadoc>
  </target>

  <!-- =================================================================== -->
  <!-- Creates the distribution                                            -->
  <!-- =================================================================== -->
  <target name="dist" depends="package, webapp, docs, javadocs" description="Prepares the distribution">
    <mkdir dir="${dist.dir}"/>
    <mkdir dir="${dist.dir}/lib"/>
    <mkdir dir="${dist.dir}/src"/>
    <mkdir dir="${dist.dir}/docs"/>
    <mkdir dir="${dist.dir}/docs/api"/>
    <mkdir dir="${dist.dir}/webapp"/>

    <copy file="${build.dir}/${name}.jar" tofile="${dist.dir}/lib/${name}.jar"/>

    <copy todir="${dist.dir}/src">
      <fileset dir="${build.src}"/>
    </copy>
    <copy todir="${dist.dir}/webapp">
      <fileset dir="${build.war}"/>
    </copy>
    <copy todir="${dist.dir}/lib">
      <fileset dir="${lib.dir}"/>
    </copy>

    <copy todir="${dist.dir}/docs">
      <fileset dir="${build.docs}"/>
    </copy>
    <copy todir="${dist.dir}/docs/api">
      <fileset dir="${build.javadocs}"/>
    </copy>
    <copy todir="${dist.dir}/xdocs">
      <fileset dir="${docs.dir}">
        <exclude name="book.xml, changes.xml, todo.xml"/>
      </fileset>
    </copy>
    <copy todir="${dist.dir}">
      <fileset dir="${docs.dir}">
        <include name="changes.xml, todo.xml"/>
      </fileset>
    </copy>
    <copy todir="${dist.dir}/skins">
      <fileset dir="${skins.dir}"/>
    </copy>

    <copy todir="${dist.dir}" filtering="on">
     <fileset dir=".">
      <include name="README"/>
      <include name="LICENSE"/>
      <include name="INSTALL"/>
      <include name="WARNING"/>
      <include name="*.bat"/>
      <include name="*.sh"/>
     </fileset>
    </copy>

    <chmod perm="+x" file="${dist.dir}/run.sh"/>
    <chmod perm="+x" file="${dist.dir}/build.sh"/>
    <fixcrlf srcdir="${dist.dir}" includes="run.sh"       cr="remove"/>
    <fixcrlf srcdir="${dist.dir}" includes="run.bat"      cr="add"/>
    <fixcrlf srcdir="${dist.dir}" includes="build.sh"     cr="remove"/>
    <fixcrlf srcdir="${dist.dir}" includes="build.bat"    cr="add"/>
  </target>

  <!-- =================================================================== -->
  <!-- Packages the distribution as .zip                                   -->
  <!-- =================================================================== -->
  <target name="dist-zip" depends="dist" description="* Generates the distribution as a .zip file">
    <zip zipfile="${dist.target}/${Name}-${version}.zip" basedir="${dist.dir}" includes="**"/>
  </target>

  <!-- =================================================================== -->
  <!-- Packages the distribution with .tar.gzip                            -->
  <!-- =================================================================== -->
  <target name="dist-tgz" depends="dist" description="* Generates the distribution as a .tar.gz file">
    <tar tarfile="${dist.target}/${Name}-${version}.tar" basedir="${dist.root}" includes="**"/>
    <gzip zipfile="${dist.target}/${Name}-${version}.tar.gz" src="${dist.target}/${Name}-${version}.tar"/>
  </target>

  <!-- =================================================================== -->
  <!-- Clean targets                                                       -->
  <!-- =================================================================== -->
  <target name="clean" depends="init" description="* Cleans the build directories">
    <delete dir="${build.dir}"/>
  </target>

  <target name="distclean" depends="clean" description="* Cleans everything to the original state">
    <delete dir="${build.root}"/>
    <delete file="${dist.target}/${Name}-${version}.tar.gz"/>
    <delete file="${dist.target}/${Name}-${version}.tar"/>
    <delete file="${dist.target}/${Name}-${version}.zip"/>
    <delete dir="${dist.root}"/>
  </target>

</project>

<!-- End of file -->