File: build.xml

package info (click to toggle)
libfreemarker-java 2.3.13%2Bdebian1-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 4,296 kB
  • ctags: 5,458
  • sloc: java: 42,735; xml: 1,352; jsp: 28; makefile: 14; sh: 10; python: 10
file content (824 lines) | stat: -rw-r--r-- 35,704 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
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
<?xml version="1.0" encoding="UTF-8"?>
<!--

Ant buildfile for 'FreeMarker' application. Compatible with Ant version 1.3.

Authors:  Alex Petrushko <alpet@ocf.berkeley.edu>
          Nicholas Cull <run2000@users.sourceforge.net>
      Jonathan Revusky <jon@revusky.com>
      Attila Szegedi <szegedia@users.sourceforge.net>

Version: $Id: build.xml,v 1.138.2.4 2006/12/27 16:11:23 szegedia Exp $

-->

<project basedir="." default="jar" name="freemarker">

    <property name="libs.location" value="http://freemarker.sourceforge.net/jarsforbuild"/>
    <property name="repositoryRootDir" value="../../../"/>

    <property file="src/freemarker/version.properties" />
    <property name="src.dir" value="src"/>
    <property name="lib.dir" value="lib"/>
    <property name="examples.dir" value="examples"/>
    <property name="build.dir" value="build"/>
    <property name="build.examples.dir" value="build/examples"/>
    <property name="build.jython-webapp.dir" value="${build.examples.dir}/jython-webapp"/>
    <property name="build.classes.dir" value="build/classes"/>
    <property name="build.javacc.dir" value="build/javacc"/>
    <property name="build.javadoc.dir" value="build/api" />
    <property name="testcase.dir" value="build/testcase"/>
    <property name="dist.dir" value="build/dist"/>
    <property name="dist.dir.versioned" value="${dist.dir}/freemarker-${version}"/>
    <property name="docgen.dir" value="../docgen" />
    <property name="javadoc.use" value="yes" /> <!-- when tar dir deepth limit is a problem, set to "no" -->

    <property name="freemarker.tar" value="build/freemarker-${version}.tar" />
    <property name="freemarker.gzip" value="${freemarker.tar}.gz" />

    <property name="lib.jdom" location="lib/jdom.jar"/>
    <property name="lib.jaxen" location="lib/jaxen.jar"/>
    <property name="lib.xalan" location="lib/xalan.jar"/>
    <property name="lib.saxpath" location="lib/saxpath.jar"/>
    <property name="lib.log4j" location="lib/log4j.jar"/>
    <property name="lib.logkit" location="lib/logkit.jar"/>
    <property name="lib.xerces" location="lib/xerces.jar"/>
    <property name="lib.junit" location="lib/junit.jar"/>
    <property name="lib.dom4j" location="lib/dom4j.jar"/>
    <property name="lib.struts" location="lib/struts.jar"/>
    <property name="lib.rhino" location="lib/js.jar"/>
    <property name="lib.servlet" location="lib/servlet.jar"/>
    <property name="lib.jsp12" location="lib/jsp-api-1.2.jar"/>
    <property name="lib.jsp20" location="lib/jsp-api-2.0.jar"/>
    <property name="lib.jsp21" location="lib/jsp-api-2.1.jar"/>
	
    <property name="lib.jython" location="lib/jython.jar"/>
    <!-- If not overridden, use default -->
    <property name="boot.class.path" value="${sun.boot.class.path}"/>
    <!-- Path elements to dependencies -->

    <path id="compile.nojsp.classpath">
        <pathelement path="${lib.servlet}"/>
        <pathelement path="${lib.jdom}"/>
        <pathelement path="${lib.jaxen}"/>
        <pathelement path="${lib.dom4j}"/>
        <pathelement path="${lib.saxpath}"/>
        <pathelement path="${lib.xalan}"/> <!-- Xalan is not included with Sun JRE 1.5! -->
        <pathelement path="${lib.jython}"/>
        <pathelement path="${lib.logkit}"/>
        <pathelement path="${lib.log4j}"/>
        <pathelement path="${lib.rhino}"/>
        <pathelement path="${java.class.path}"/>
    </path>
    
    <path id="compile.classpath">
        <path refid="compile.nojsp.classpath"/>
        <pathelement path="${lib.jsp21}"/>
    </path>

    <path id="compile.jsp1.classpath">
        <path refid="compile.nojsp.classpath"/>
        <pathelement path="${lib.jsp12}"/>
    </path>

    <path id="compile.jsp2.classpath">
	<path refid="compile.nojsp.classpath"/>
	<pathelement path="${lib.jsp20}"/>
    </path>
    
    <path id="compile.classpath.testcases">
        <pathelement path="${lib.junit}"/>
        <pathelement path="${lib.jython}"/>
        <pathelement path="${lib.jdom}"/>
        <pathelement path="${lib.servlet}"/>
        <pathelement path="${lib.jsp20}"/>
    </path>

    <path id="compile.classpath.javadoc">
        <pathelement path="${lib.xerces}"/>
        <pathelement path="${lib.jdom}"/>
        <pathelement path="${lib.dom4j}"/>
        <pathelement path="${lib.rhino}"/>
        <pathelement path="${lib.jaxen}"/>
        <pathelement path="${lib.jython}"/>
        <pathelement path="${lib.saxpath}"/>
        <pathelement path="${lib.xalan}"/> <!-- Xalan is not included with Sun JRE 1.5 with the old classname! -->
        <pathelement path="${lib.servlet}"/>
        <pathelement path="${lib.jsp21}"/>
        <pathelement path="${lib.logkit}"/>
        <pathelement path="${lib.log4j}"/>
        <pathelement path="${src.dir}"/>
        <pathelement path="${build.javacc.dir}"/>
        <pathelement path="${java.class.path}"/>
    </path>

    <path id="compile.classpath.examples">
        <pathelement path="${lib.servlet}"/>
        <pathelement path="${lib.dir}/freemarker.jar"/>
        <pathelement path="${lib.struts}"/>
    </path>
    
    <path id="full.classpath">
        <pathelement path="${src.dir}"/>
        <pathelement path="${build.classes.dir}" />
        <pathelement path="${lib.servlet}"/>
        <pathelement path="${lib.jdom}"/>
        <pathelement path="${lib.jaxen}"/>
        <pathelement path="${lib.dom4j}"/>
        <pathelement path="${lib.saxpath}"/>
        <pathelement path="${lib.xalan}"/> <!-- Xalan is not included with Sun JRE 1.5! -->
        <pathelement path="${lib.jython}"/>
        <pathelement path="${lib.logkit}"/>
        <pathelement path="${lib.log4j}"/>
        <pathelement path="${java.class.path}"/>
    </path>
    
    
    <!-- Pattern set for FreeMarker compilation -->
    <patternset id="freemarker.compile">
        <include name="freemarker/cache/**"/>
        <include name="freemarker/debug/**"/>
        <include name="freemarker/ext/**"/>
        <include name="freemarker/log/**"/>
        <include name="freemarker/core/**" />
        <include name="freemarker/template/**"/>
        <exclude name="freemarker/core/RegexBuiltins.java"/>
        <exclude name="freemarker/ext/ant/**"/>
        <exclude name="freemarker/ext/beans/EnumModels.java"/>
        <exclude name="freemarker/ext/dom/XalanXPathSupport.java"/>
        <exclude name="freemarker/ext/dom/SunInternalXalanXPathSupport.java"/>
        <exclude name="freemarker/ext/dom/JaxenXPathSupport.java"/>
        <exclude name="freemarker/ext/jdom/NodeListModel.java"/>
        <exclude name="freemarker/ext/jython/**"/>
        <exclude name="freemarker/ext/jsp/TaglibFactory.java"/>
        <exclude name="freemarker/ext/jsp/TaglibFactory.java"/>
        <exclude name="freemarker/ext/jsp/FreeMarkerPageContext1.java"/>
        <exclude name="freemarker/ext/jsp/FreeMarkerPageContext2.java"/>
        <exclude name="freemarker/ext/jsp/FreeMarkerJspFactory2.java"/>
        <exclude name="freemarker/ext/rhino/**"/>
        <exclude name="freemarker/ext/xml/Dom4jNavigator.java"/>
        <exclude name="freemarker/ext/xml/JdomNavigator.java"/>
        <exclude name="freemarker/log/AvalonLoggerFactory.java"/>
        <exclude name="freemarker/log/JDK14LoggerFactory.java"/>
        <exclude name="freemarker/log/Log4JLoggerFactory.java"/>
        <exclude name="freemarker/template/utility/JythonRuntime.java"/>
    </patternset>

    <!-- Pattern set for FreeMarker jar -->
    <patternset id="freemarker.jar">
        <include name="freemarker/**"/>
    </patternset>

    <patternset id="freemarker.compile.logkit">
        <include name="freemarker/log/AvalonLoggerFactory.java"/>
    </patternset>

    <patternset id="freemarker.compile.jdk14">
        <include name="freemarker/log/JDK14LoggerFactory.java"/>
        <include name="freemarker/core/RegexBuiltins.java"/>
    </patternset>

    <patternset id="freemarker.compile.jdk15">
        <include name="freemarker/ext/beans/EnumModels.java"/>
        <include name="freemarker/ext/dom/SunInternalXalanXPathSupport.java"/>
    </patternset>

    <patternset id="freemarker.compile.xalan">
        <include name="freemarker/ext/dom/XalanXPathSupport.java"/>
    </patternset>

    <patternset id="freemarker.compile.log4j">
        <include name="freemarker/log/Log4JLoggerFactory.java"/>
    </patternset>

    <patternset id="freemarker.compile.dom4j">
        <include name="freemarker/ext/xml/Dom4jNavigator.java"/>
    </patternset>

    <patternset id="freemarker.compile.jaxen">
        <include name="freemarker/ext/dom/JaxenXPathSupport.java"/>
    </patternset>

    <patternset id="freemarker.compile.jdom">
        <include name="freemarker/ext/jdom/NodeListModel.java"/>
        <include name="freemarker/ext/xml/JdomNavigator.java"/>
    </patternset>

    <patternset id="freemarker.compile.jython">
        <include name="freemarker/ext/ant/**"/>
        <include name="freemarker/template/utility/JythonRuntime.java"/>
        <include name="freemarker/ext/jython/**"/>
    </patternset>

    <patternset id="freemarker.compile.rhino">
        <include name="freemarker/ext/rhino/**"/>
    </patternset>

    <patternset id="freemarker.compile.jsp1">
        <include name="freemarker/ext/jsp/FreeMarkerPageContext1.java"/>
    </patternset>

    <patternset id="freemarker.compile.jsp2">
        <include name="freemarker/ext/jsp/FreeMarkerPageContext2.java"/>
        <include name="freemarker/ext/jsp/FreeMarkerJspFactory2.java"/>
    </patternset>

    <!-- Pattern set for FreeMarker test case compilation -->
    <patternset id="freemarker.compile.testcases">
        <include name="freemarker/testcase/**"/>
    </patternset>

    <!-- Pattern set for FreeMarker test case test files -->
    <patternset id="freemarker.testcases">
        <include name="freemarker/testcase/reference/**"/>
        <include name="freemarker/testcase/template/**"/>
        <include name="freemarker/testcase/servlets/reference/**"/>
        <include name="freemarker/testcase/servlets/template/**"/>
        <include name="freemarker/testcase/servlets/WEB-INF/**"/>
        <include name="freemarker/testcase/*.properties"/>
        <include name="freemarker/testcase/*.xml"/>
        <include name="freemarker/testcase/models/*.properties"/>
    </patternset>

    <!-- Pattern set for FreeMarker JavaDoc -->
    <patternset id="freemarker.javadoc.files">
        <exclude name="manual/**"/>
    </patternset>

    <!-- Pattern set for FreeMarker distribution -->
    <patternset id="freemarker.distribution.src">
        <include name="build.xml"/>
        <include name="examples/**"/>
        <include name="LICENSE.txt"/>
        <include name="README.txt"/>
        <include name="src/**"/>
        <include name="examples/**"/>
        <exclude name="**/CVS/**"/>
        <exclude name="**/*.bak"/>
        <exclude name="**/src/**/*.class" />
        <exclude name="**/.nbattrs" />
    </patternset>

    <target name="fetchlibs" unless="all.libs.present" description="fetch build dependencies and put them in lib directory">
	<mkdir dir="lib"/>
	<echo>Fetching libraries from server.</echo>
	<get src="${libs.location}/README.txt" dest="lib/README.txt" usetimestamp="true"/>
	<get src="${libs.location}/ant.jar" dest="lib/ant.jar" usetimestamp="true"/>
	<get src="${libs.location}/dom4j.jar" dest="lib/dom4j.jar" usetimestamp="true"/>
	<get src="${libs.location}/emma.jar" dest="lib/emma.jar" usetimestamp="true"/>
	<get src="${libs.location}/emma_ant.jar" dest="lib/emma_ant.jar" usetimestamp="true"/>
	<get src="${libs.location}/2.3/javacc.jar" dest="lib/javacc.jar" usetimestamp="true"/>
	<get src="${libs.location}/jaxen.jar" dest="lib/jaxen.jar" usetimestamp="true"/>
	<get src="${libs.location}/2.3/jdom.jar" dest="lib/jdom.jar" usetimestamp="true"/>
	<get src="${libs.location}/js.jar" dest="lib/js.jar" usetimestamp="true"/>
	<get src="${libs.location}/junit.jar" dest="lib/junit.jar" usetimestamp="true"/>
	<get src="${libs.location}/jython.jar" dest="lib/jython.jar" usetimestamp="true"/>
	<get src="${libs.location}/log4j.jar" dest="lib/log4j.jar" usetimestamp="true"/>
	<get src="${libs.location}/2.3/logkit.jar" dest="lib/logkit.jar" usetimestamp="true"/>
	<get src="${libs.location}/2.3/rt122.jar" dest="lib/rt122.jar" usetimestamp="true"/>
	<get src="${libs.location}/saxpath.jar" dest="lib/saxpath.jar" usetimestamp="true"/>
	<get src="${libs.location}/servlet.jar" dest="lib/servlet.jar" usetimestamp="true"/>
	<get src="${libs.location}/struts.jar" dest="lib/struts.jar" usetimestamp="true"/>
	<get src="${libs.location}/jsp-api-1.2.jar" dest="lib/jsp-api-1.2.jar" usetimestamp="true"/>
	<get src="${libs.location}/jsp-api-2.0.jar" dest="lib/jsp-api-2.0.jar" usetimestamp="true"/>
	<get src="${libs.location}/jsp-api-2.1.jar" dest="lib/jsp-api-2.1.jar" usetimestamp="true"/>
	<get src="${libs.location}/xalan.jar" dest="lib/xalan.jar" usetimestamp="true"/>
    </target>

    <target name="init">
        <condition property="all.libs.present">
            <and>
                <available file="lib/README.txt"/>
                <available file="lib/ant.jar"/>
                <available file="lib/dom4j.jar"/>
                <available file="lib/emma.jar"/>
                <available file="lib/emma_ant.jar"/>
                <available file="lib/javacc.jar"/>
                <available file="lib/jaxen.jar"/>
                <available file="lib/jdom.jar"/>
                <available file="lib/js.jar"/>
                <available file="lib/junit.jar"/>
                <available file="lib/jython.jar"/>
                <available file="lib/log4j.jar"/>
                <available file="lib/logkit.jar"/>
                <available file="lib/rt122.jar"/>
                <available file="lib/saxpath.jar"/>
                <available file="lib/servlet.jar"/>
                <available file="lib/struts.jar"/>
                <available file="lib/jsp-api-1.2.jar"/>
                <available file="lib/jsp-api-2.0.jar"/>
                <available file="lib/jsp-api-2.1.jar"/>
                <available file="lib/xalan.jar"/>
            </and>
        </condition>
        <antcall target="fetchlibs"/>
        <available
            property="log4j.available"
            classname="org.apache.log4j.Logger"
            classpathref="compile.classpath"/>
        <available
            property="logkit.available"
            classname="org.apache.log.Logger"
            classpathref="compile.classpath"/>
        <available
            property="jdk14.available"
            classname="java.util.logging.Logger"
            classpathref="compile.classpath"/>
        <available
            property="jdk15.available"
            classname="java.lang.Enum"
            classpathref="compile.classpath"/>
        <available
            property="jython.available"
            classname="org.python.core.PyObject"
            classpathref="compile.classpath"/>
        <available
            property="jsp21.available"
            classname="javax.el.ELResolver"
            classpathref="compile.classpath"/>
        <available
            property="dom4j.available"
            classname="org.dom4j.Node"
            classpathref="compile.classpath"/>
        <available
            property="jaxen.available"
            classname="org.jaxen.XPath"
            classpathref="compile.classpath"/>
        <available
            property="jdom.available"
            classname="org.jdom.Element"
            classpathref="compile.classpath"/>
        <available
            property="rhino.available"
            classname="org.mozilla.javascript.Scriptable"
            classpathref="compile.classpath"/>
        <available
            property="xalan.available"
            classname="org.apache.xpath.XPathAPI"
            classpathref="compile.classpath" />
    </target>
    
    <!-- The build targets begin here -->
    <target depends="" name="clean" description="Erase the deployment tree">
        <delete dir="${build.dir}"/>
        <delete dir="${lib.dir}"/>
        <delete dir="docs"/>
        <delete file="src/freemarker/core/FMParser.java" />
        <delete file="src/freemarker/core/FMParserConstants.java" />
        <delete file="src/freemarker/core/FMParserTokenManager.java" />
        <delete file="src/freemarker/core/SimpleCharStream.java" />
        <delete file="src/freemarker/core/Token.java" />
        <delete file="src/freemarker/core/TokenMgrError.java" />
    </target>

    <target depends="" name="prepare" description="Create the target directories">
        <mkdir dir="${build.dir}"/>
        <mkdir dir="${lib.dir}"/>
    </target>

    <target depends="" name="javadoc" description="Build the JavaDoc documentation" >
        <mkdir dir="${build.javadoc.dir}"/>
        <delete includeEmptyDirs="yes">
            <fileset dir="${build.javadoc.dir}" includes="**/*" />
        </delete>
        <javadoc author="true"
                destdir="${build.javadoc.dir}"
                doctitle="FreeMarker ${version}"
                packagenames="freemarker.debug, freemarker.template.*, freemarker.core.*, freemarker.ext.*, freemarker.cache.*, freemarker.log.*"
                sourcepath="${src.dir}"
                version="true"
                windowtitle="FreeMarker ${version} API"
                classpathref="compile.classpath.javadoc"
                use="${javadoc.use}">
        </javadoc>
    </target>

    <target name="javacc"
        description="Build the JavaCC parser from its grammar file">
        <!-- mkdir dir="${build.javacc.dir}/freemarker/core"/ -->
        <copy todir="${build.javacc.dir}/freemarker/core" file="${src.dir}/freemarker/core/ParseException.java" />
        <taskdef name="javacc" classname="org.apache.tools.ant.taskdefs.optional.javacc.JavaCC" classpath="lib/javacc.jar"/>
        <javacc
            target="${src.dir}/freemarker/core/FMParser.jj"
            outputdirectory="src/freemarker/core"
            javacchome="lib"
        />
       <replace
            file="src/freemarker/core/FMParserConstants.java"
            token="public interface FMParserConstants"
            value="interface FMParserConstants"
        />
        <replace
            file="src/freemarker/core/FMParserTokenManager.java"
            token="public class FMParserTokenManager"
            value="class FMParserTokenManager"
        />
  <replace
      file="src/freemarker/core/Token.java"
      token="public class Token"
      value="class Token"
  />
  <replace
      file="src/freemarker/core/SimpleCharStream.java"
      token="public final class SimpleCharStream"
      value="final class SimpleCharStream"
      />
   <replace
	file="src/freemarker/core/FMParser.java"
	token="enum"
	value="ENUM"
	/>
    </target>

    <target depends="init, prepare, javacc" name="compile"
            description="Compile Java source files">
        <mkdir dir="${build.classes.dir}"/>
        <javac deprecation="off" destdir="${build.classes.dir}" debug="on" optimize="off" bootclasspath="lib/rt122.jar" source="1.2" target="1.2">
            <src path="${src.dir}"/>
            <patternset refid="freemarker.compile"/>
            <!-- src path="${build.javacc.dir}"/ -->
            <classpath refid="compile.classpath"/>
        </javac>
        <rmic base="${build.classes.dir}" classpathref="compile.classpath"
          includes="freemarker/debug/impl/Rmi*Impl.class" verify="yes" stubversion="1.2"/>
        <antcall target="compile-log4j"/>
        <antcall target="compile-logkit"/>
        <antcall target="compile-jdk14"/>
        <antcall target="compile-jdk15"/>
        <antcall target="compile-jsp1"/>
        <antcall target="compile-jsp2"/>
        <antcall target="compile-jython"/>
        <antcall target="compile-dom4j"/>
        <antcall target="compile-jdom"/>
        <antcall target="compile-xalan"/>
        <antcall target="compile-jaxen"/>
        <antcall target="compile-rhino"/>
        <copy toDir="${build.classes.dir}">
          <fileset
            dir="${src.dir}"
            excludes="**/CVS/**,**/*.bak,**/*.java,**/*.jj,**/package.html,freemarker/testcase/**"/>
        </copy>
    </target>

    <target name="compile-log4j" if="log4j.available">
        <javac deprecation="off" destdir="${build.classes.dir}" debug="on" optimize="off" bootclasspath="${boot.class.path}" target="1.2" source="1.2">
            <src path="${src.dir}"/>
            <classpath refid="compile.classpath"/>
            <patternset refid="freemarker.compile.log4j"/>
        </javac>
    </target>

    <target name="compile-logkit" if="logkit.available">
        <javac deprecation="off" destdir="${build.classes.dir}" debug="on" optimize="off" bootclasspath="${boot.class.path}" target="1.2" source="1.2">
            <src path="${src.dir}"/>
            <classpath refid="compile.classpath"/>
            <patternset refid="freemarker.compile.logkit"/>
        </javac>
    </target>

    <target name="compile-jdk14" if="jdk14.available">
        <javac deprecation="off" destdir="${build.classes.dir}" debug="on" optimize="off" source="1.4" target="1.4">
            <src path="${src.dir}"/>
            <classpath refid="compile.classpath"/>
            <patternset refid="freemarker.compile.jdk14"/>
        </javac>
    </target>

    <target name="compile-jdk15" if="jdk15.available">
        <javac deprecation="off" destdir="${build.classes.dir}" debug="on" optimize="off" source="1.5" target="1.5">
            <src path="${src.dir}"/>
            <classpath refid="compile.classpath"/>
            <patternset refid="freemarker.compile.jdk15"/>
        </javac>
    </target>

    <target name="compile-jython" if="jython.available">
        <javac deprecation="off" destdir="${build.classes.dir}" debug="on" optimize="off" bootclasspath="${boot.class.path}" target="1.2" source="1.2">
            <src path="${src.dir}"/>
            <classpath refid="compile.classpath"/>
            <patternset refid="freemarker.compile.jython"/>
        </javac>
    </target>

    <target name="compile-jsp1">
        <javac deprecation="off" destdir="${build.classes.dir}" debug="on" optimize="off" bootclasspath="${boot.class.path}" target="1.2" source="1.2">
            <src path="${src.dir}"/>
            <classpath refid="compile.jsp1.classpath"/>
            <patternset refid="freemarker.compile.jsp1"/>
        </javac>
    </target>

    <target name="compile-jsp2">
        <javac deprecation="off" destdir="${build.classes.dir}" debug="on" optimize="off" bootclasspath="${boot.class.path}" target="1.2" source="1.2">
            <src path="${src.dir}"/>
            <classpath refid="compile.jsp2.classpath"/>
            <patternset refid="freemarker.compile.jsp2"/>
        </javac>
    </target>

    <target name="compile-rhino" if="rhino.available">
        <javac deprecation="off" destdir="${build.classes.dir}" debug="on" optimize="off" bootclasspath="${boot.class.path}" target="1.2" source="1.2">
            <src path="${src.dir}"/>
            <classpath refid="compile.classpath"/>
            <patternset refid="freemarker.compile.rhino"/>
        </javac>
    </target>

    <target name="compile-dom4j" if="dom4j.available">
        <javac deprecation="off" destdir="${build.classes.dir}" debug="on" optimize="off" bootclasspath="${boot.class.path}" target="1.2" source="1.2">
            <src path="${src.dir}"/>
            <classpath refid="compile.classpath"/>
            <patternset refid="freemarker.compile.dom4j"/>
        </javac>
    </target>

    <target name="compile-jaxen" if="jaxen.available">
        <javac deprecation="off" destdir="${build.classes.dir}" debug="on" optimize="off" bootclasspath="${boot.class.path}" target="1.2" source="1.2">
            <src path="${src.dir}"/>
            <classpath refid="compile.classpath"/>
            <patternset refid="freemarker.compile.jaxen"/>
        </javac>
    </target>

    <target name="compile-jdom" if="jdom.available">
        <javac deprecation="off" destdir="${build.classes.dir}" debug="on" optimize="off" bootclasspath="${boot.class.path}" target="1.2" source="1.2">
            <src path="${src.dir}"/>
            <classpath refid="compile.classpath"/>
            <patternset refid="freemarker.compile.jdom"/>
        </javac>
    </target>
    
    <target name="compile-xalan" if="xalan.available">
        <javac deprecation="off"
               destdir="${build.classes.dir}"
               debug="on"
               optimize="off"
               target="1.2" source="1.2">
            <src path="${src.dir}"/>
            <classpath refid="compile.classpath"/>
            <patternset refid="freemarker.compile.xalan"/>
        </javac>
    </target>

    <target depends="compile" name="jar" description="Create the freemarker.jar">
        <jar basedir="${build.classes.dir}" jarfile="${lib.dir}/freemarker.jar">
            <patternset refid="freemarker.jar"/>
            <manifest>
                <attribute name="Main-Class" value="freemarker.core.CommandLine" />
                <attribute name="Extension-name" value="FreeMarker" />
                <attribute name="Specification-Title" value="FreeMarker" />
                <attribute name="Specification-Version" value="${versionForMf}" />
                <attribute name="Specification-Vendor" value="Visigoth Software Society" />
                <attribute name="Implementation-Title" value="VSS Java FreeMarker" />
                <attribute name="Implementation-Version" value="${versionForMf}" />
                <attribute name="Implementation-Vendor" value="Visigoth Software Society" />
            </manifest>
       </jar>
    </target>

    <target depends="compile" name="testcases" description="Build test cases">
        <mkdir dir="${testcase.dir}"/>
        <copy toDir="${testcase.dir}">
            <fileset dir="${build.classes.dir}"/>
        </copy>
        <javac deprecation="on" destdir="${testcase.dir}" debug="on" optimize="off">
            <src path="${src.dir}"/>
            <classpath refid="compile.classpath.testcases"/>
            <patternset refid="freemarker.compile.testcases"/>
        </javac>

        <copy todir="${testcase.dir}">
            <fileset dir="${src.dir}">
                <patternset refid="freemarker.testcases"/>
            </fileset>
        </copy>
    </target>

    <target name="test" depends="compile, testcases" description="Run test cases">
        <junit haltonfailure="off" fork="true">
            <classpath>
              <path path="${java.class.path}"/>
              <path refid="compile.classpath"/>
              <pathelement path="${lib.junit}"/>
              <pathelement path="${lib.jdom}"/>
              <pathelement path="${build.classes.dir}"/>
              <pathelement path="${testcase.dir}"/>
            </classpath>
            <formatter type="plain"/>
            <formatter type="xml"/>

            <test
              name="freemarker.testcase.TemplateTestSuite"
              todir="${testcase.dir}"/>
        </junit>
    </target>

    <!--
      Reusable task for building example webapps. Invoke with antcall task.
      Params:
      - webapp: The directory of the webapp relative to the example directory
    -->
    <target name="example-general-webapp" depends="init"
            description="Reusable task for building example webapps. For internal usage only.">
        <mkdir dir="${build.examples.dir}/${webapp}"/>
        <copy toDir="${build.examples.dir}/${webapp}">
          <fileset dir="${examples.dir}/${webapp}" excludes="**/CVS/**,**/*.bak"/>
        </copy>
        <javac deprecation="on" destdir="${build.examples.dir}/${webapp}/WEB-INF/classes">
            <src path="${examples.dir}/${webapp}/WEB-INF/classes"/>
            <classpath refid="compile.classpath.examples" />
        </javac>
        <mkdir dir="${build.examples.dir}/${webapp}/WEB-INF/lib"/>
        <copy file="lib/freemarker.jar" toDir="${build.examples.dir}/${webapp}/WEB-INF/lib"/>
    </target>

    <target name="example-webapp1" depends="init" description="Build the example webapps">
        <antcall target="example-general-webapp">
          <param name="webapp" value="webapp1"/>
        </antcall>
    </target>

    <target name="example-webapp2" depends="init" description="Build the example webapps">
        <antcall target="example-general-webapp">
          <param name="webapp" value="webapp2"/>
        </antcall>
    </target>

    <target name="example-jsp-webapp" depends="init" description="Build the JSP example webapp">
        <antcall target="example-general-webapp">
          <param name="webapp" value="jsp-webapp"/>
        </antcall>
    </target>

    <target name="example-struts-webapp" depends="init" description="Build the struts example webapp">
        <antcall target="example-general-webapp">
          <param name="webapp" value="struts-webapp"/>
        </antcall>
    </target>

    <target name="prepare-jython-webapp">
        <property name="twit.jar.loc" location="${build.jython-webapp.dir}/WEB-INF/lib/twit.jar"/>
        <uptodate
            property="jython-webapp.upToDate"
          targetfile="${twit.jar.loc}"
      >
          <srcfiles dir="examples/jython-webapp/WEB-INF" includes="UpperClassTwitOfTheYearServlet.py"/>
          <srcfiles dir="${src.dir}" includes="freemarker/ext/servlet/FreemarkerServlet.java"/>
      </uptodate>

        <mkdir dir="${build.jython-webapp.dir}/WEB-INF/lib"/>
          <copy toDir="${build.jython-webapp.dir}">
          <fileset dir="${examples.dir}/jython-webapp" excludes="**/CVS/**,**/*.bak"/>
        </copy>

        <property name="jythonc" location="${jython.home}/Tools/jythonc/jythonc.py"/>
        <property name="freemarker.jar.loc" location="lib/freemarker.jar"/>
        <copy file="lib/freemarker.jar" toDir="${build.jython-webapp.dir}/WEB-INF/lib"/>
    </target>

    <target name="example-jython-webapp" depends="init, prepare-jython-webapp" if="jython.available" unless="jython-webapp.upToDate"
            description="Build the Jython Webapp example code">
        <java fork="true" classname="org.python.util.jython" dir="${build.jython-webapp.dir}/WEB-INF">
            <classpath>
              <path  refid="compile.classpath"/>
              <pathelement location="${freemarker.jar.loc}"/>
            </classpath>
            <sysproperty key="python.home" value="${jython.home}"/>
            <sysproperty key="python.home" value="${jython.home}"/>
            <arg value="${jythonc}"/>
            <arg value="--core"/>
            <arg value="--bean"/>
            <arg value="${twit.jar.loc}"/>
            <arg value="UpperClassTwitOfTheYearServlet.py"/>
        </java>

        <delete dir="${build.jython-webapp.dir}/WEB-INF/jpywork"/>
        
    </target>

    <target name="examples"
        depends="example-webapp1, example-webapp2, example-struts-webapp, example-jsp-webapp, example-jython-webapp"/>
    
    <target name="fail.logkit" unless="logkit.available">
      <fail message="Can't build dist because LogKit classes are not available."/>
    </target>

    <target name="fail.log4j" unless="log4j.available">
      <fail message="Can't build dist because Log4J classes are not available."/>
    </target>

    <target name="fail.jdk14" unless="jdk14.available">
      <fail message="Can't build dist because JDK 1.4 classes are not available."/>
    </target>

    <target name="fail.jdk15" unless="jdk15.available">
      <fail message="Can't build dist because JDK 1.5 classes are not available."/>
    </target>

   <target name="fail.jython" unless="jython.available">
      <fail message="Can't build dist because Jython classes are not available."/>
    </target>

    <target name="fail.jsp21" unless="jsp21.available">
      <fail message="Can't build dist because JSP 2.1 classes are not available."/>
    </target>

    <target name="fail.rhino" unless="rhino.available">
      <fail message="Can't build dist because Rhino classes are not available."/>
    </target>

    <target name="fail.jaxen" unless="jaxen.available">
      <fail message="Can't build dist because Jaxen classes are not available."/>
    </target>

    <target name="fail.xalan" unless="xalan.available">
      <fail message="Can't build dist because Xalan classes are not available."/>
    </target>

    <target
        name="dist"
        depends="init, fail.logkit, fail.log4j, fail.jdk14, fail.jdk15, fail.jython, fail.jsp21, fail.rhino, fail.jaxen, fail.xalan, jar"
        description="Build the FreeMarker distribution files">
        <delete dir="${dist.dir}" />
        <mkdir dir="${dist.dir}" />
        <mkdir dir="${dist.dir.versioned}" />
        <copy todir="${dist.dir.versioned}" includeEmptyDirs="no">
            <fileset dir=".">
                <patternset refid="freemarker.distribution.src"/>
            </fileset>
        </copy>
        <replace
            file="${dist.dir.versioned}/README.txt"
            token="{version}"
            value="${version}"
        />

        <copy todir="${dist.dir.versioned}/lib"  includeEmptyDirs="no">
          <fileset file="lib/freemarker.jar" />
        </copy>

        <!-- Generate website pages and copy them to distro -->
        <ant dir="${repositoryRootDir}site" target="all">
          <property name="site.offline" value="yes"/>
        </ant>
        <copy todir="${dist.dir.versioned}/docs">
          <fileset dir="${repositoryRootDir}site/build/site"/>
        </copy>
        
        <!-- Generate manual pages and copy them to distro -->
        <ant dir="../docgen" target="all">
          <property name="docgen.offline" value="yes"/>
        </ant>
        <copy todir="${dist.dir.versioned}/docs/docs" includeEmptyDirs="no">
          <fileset dir="../docgen/build/docs"/>
        </copy>

        <antcall target="packdist"/>
    </target>
    
    <target name="packdist">
        <delete file="${freemarker.tar}" />
        <tar tarfile="${freemarker.tar}" basedir="${dist.dir}" />
        <delete file="${freemarker.gzip}" />
        <gzip zipfile="${freemarker.gzip}" src="${freemarker.tar}" />
        <delete file="${freemarker.tar}" />
    </target>
    
    <target name="packdocs">
        <delete file="build/docs.tar" />
        <tar tarfile="build/docs.tar" basedir="${dist.dir.versioned}/docs" />
        <delete file="build/docs.tar.gz" />
        <gzip zipfile="build/docs.tar.gz" src="build/docs.tar" />
        <delete file="build/docs.tar" />
    </target>

    <target name="packapidocs">
        <delete file="build/apidocs.tar" />
        <tar tarfile="build/apidocs.tar" basedir="build/api" />
        <delete file="build/apidocs.tar.gz" />
        <gzip zipfile="build/apidocs.tar.gz" src="build/apidocs.tar" />
        <delete file="build/apidocs.tar" />
    </target>

<!-- The following ant target builds a war file for the HelloServlet
and guestbook examples. Once you build the .war file and drop it in
the appropriate directory, you should be able to see the following
URL's: http://localhost:8080/fmexamples/servlet/hello
and: http://localhost:8080/fmexamples/servlet/guestbook -->

    <target name="war-jython-webapp"
             depends="example-jython-webapp" if="jython.available">
        <jar jarfile="fm-jython-example.war" basedir="${build.jython-webapp.dir}" />
    </target>

    <target depends="clean,
                    prepare,
                    javadoc,
                    jar,
                    example-webapp1, example-webapp2,
                    testcases"

            name="all"
            description="Build everything" />

</project>