File: build.xml

package info (click to toggle)
checkstyle 4.4%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 6,440 kB
  • ctags: 7,629
  • sloc: java: 47,540; xml: 15,957; makefile: 32; sh: 4
file content (797 lines) | stat: -rw-r--r-- 32,692 bytes parent folder | download | duplicates (2)
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
<project name="checkstyle" default="compile.checkstyle" basedir=".">

  <!-- set global properties for this build -->
  <!-- Give user a chance to override without editing this file -->
  <!-- (and without typing -D each time it compiles it) -->
  <property name="target.dir" value="${basedir}/target" />
  <property file="checkstyle.buildproperties" />
  <property file="${user.home}/checkstyle.buildproperties" />

  <property name="version" value="4.4" />
  <property name="ant.jar" value="${ant.home}/lib/ant.jar" />
  <property name="antlr.jar" value="lib/antlr.jar" />
  <property name="velocity.jar" value="lib/velocity-dep-1.4.jar" />
  <property name="jdom.jar" value="lib/jdom-b9.jar" />
  <property name="junit.jar" value="lib/junit.jar" />
  <property name="beanutils.jar" value="lib/commons-beanutils-core.jar" />
  <property name="collections.jar" value="lib/commons-collections.jar" />
  <property name="cli.jar" value="lib/commons-cli.jar" />
  <property name="logging.jar" value="lib/commons-logging.jar" />
  <property name="tools.jar" value="${java.home}/../lib/tools.jar" />
  <property name="emma.enabled" value="true" />

  <property name="checkstyle.dir"
            value="src/checkstyle/com/puppycrawl/tools/checkstyle" />
  <property name="checkstyle.grammar.dir"
            value="${checkstyle.dir}/grammars" />
  <property name="testreport.dir" value="${target.dir}/testreports"/>
  <property name="dist.dir" value="${target.dir}/dist"/>
  <property name="checkstyle.dest" value="${target.dir}/checkstyle" />
  <property name="tests.dest" value="${target.dir}/tests" />
  <property name="testinputs.dest" value="${target.dir}/testinputs" />
  <property name="emma.dest" value="${target.dir}/emma" />

  <property name="xdocs.src" value="src/xdocs"/>
  <property name="xdocs.dest" value="${target.dir}/docs"/>
  <property name="checkstyle.minimum.javaversion" value="1.4" />
  <property name="checkstyle.testinputs.minimum.javaversion" value="1.5" />
  <property name="testcases" value="**/*Test.java"/>

  <path id="build.classpath">
    <pathelement location="${antlr.jar}" />
    <pathelement location="${collections.jar}" />
    <pathelement location="${cli.jar}" />
    <pathelement location="${beanutils.jar}" />
    <pathelement location="${logging.jar}" />
    <pathelement location="${ant.jar}" />
    <pathelement location="${tools.jar}" />
  </path>

  <path id="run.classpath">
    <pathelement location="${checkstyle.dest}" />
    <pathelement location="${antlr.jar}" />
    <path refid="build.classpath" />
  </path>

  <!-- add classes to generate Javadoc -->
  <path id="javadoc.classpath">
    <path refid="run.classpath" />
  </path>

  <path id="tests.buildpath">
    <pathelement location="${junit.jar}" />
    <path refid="run.classpath" />
  </path>

  <path id="tests.runpath">
    <!-- Need the instrumented classes first -->
    <pathelement location="${emma.dest}/classes" />
    <pathelement location="${tests.dest}" />
    <pathelement location="${testinputs.dest}" />
    <pathelement location="lib/emma.jar"/>
    <path refid="tests.buildpath" />
  </path>

  <path id="velocity.classpath">
    <pathelement location="${velocity.jar}"/>
    <pathelement location="${jdom.jar}" />
  </path>

  <target name="display.classpath" description="Displays the run classpath">
    <property name="asd" refid="run.classpath" />
    <echo message="Classpath is ${asd}" />
  </target>

  <!-- -->
  <!-- Cleanup targets -->
  <!-- -->
  <target name="clean" description="Cleans any directories and generated files">
    <delete>
      <fileset dir="src/checkstyle">
        <include name="**/Generated*"/>
        <include name="**/expandedjava*.g"/>
      </fileset>
    </delete>
    <delete dir="${target.dir}" />
    <delete file="velocity.log" />
  </target>

  <!-- -->
  <!-- ANTLR targets -->
  <!-- -->

  <!-- Checks whether the grammar file is newer that the generated code -->
  <target name="-check.antlr"
          description="Checks whether the grammar file is newer that the generated code">
    <uptodate property="uptodate.antlr"
              targetfile="${checkstyle.grammar.dir}/GeneratedJavaLexer.java" >
      <srcfiles dir= "${checkstyle.grammar.dir}" includes="java.g"/>
    </uptodate>
  </target>

  <!-- Conditionally will compile the grammar. Deliberately do not use the -->
  <!-- antlr task as it requirs the ANTLR classes to be in the classpath -->
  <!-- which creates lots of problems. -->
  <target name="build.antlr" depends="-check.antlr" unless="uptodate.antlr"
          description="Conditionally compiles the grammar files">
    <java classname="antlr.Tool"
          classpath="${antlr.jar}"
          fork="yes"
          failonerror="true"
          dir="${checkstyle.grammar.dir}">
      <arg value="java.g" />
    </java>
  </target>

  <!-- -->
  <!-- COMPILE TARGETS -->
  <!-- -->
  <target name="compile.checkstyle" depends="build.antlr"
          description="Compiles the source code">
    <mkdir dir="${checkstyle.dest}" />
    <depend srcdir="src/checkstyle"
            destdir="${checkstyle.dest}" closure="yes"/>
    <javac srcdir="src/checkstyle"
           destdir="${checkstyle.dest}"
           includes="**/*.java"
           deprecation="on" debug="on"
           source="${checkstyle.minimum.javaversion}"
           target="${checkstyle.minimum.javaversion}"
           classpathref="build.classpath"
           encoding="iso-8859-1"
           includeAntRuntime="false"/>

    <propertyfile file="${checkstyle.dest}/checkstylecompilation.properties">
      <entry key="checkstyle.compile.version" value="${version}"/>
      <entry key="checkstyle.compile.timestamp" type="date" value="now" pattern="E MMMM dd yyyy, HH:mm z"/>
    </propertyfile>

    <native2ascii src="src/checkstyle"
                  dest="${checkstyle.dest}"
                  encoding="EUC-JP"
                  includes="**/*_ja.properties" />

    <copy todir="${checkstyle.dest}">
      <fileset dir="src/checkstyle" includes="**/*.properties"/>
      <fileset dir="src/checkstyle" includes="**/*.xml"/>
      <fileset dir="src/checkstyle" includes="**/*.dtd"/>
    </copy>

    <!-- fix for bug #594469:
         create a copy of the english property file, necessary to run
         the tests in an environment that has a supported language (e.g. de)
         in the default locale. See algorithm in ResourceBundle.getBundle() -->

    <copy todir="${checkstyle.dest}" >
      <fileset dir="src/checkstyle" includes="**/messages.properties"/>
      <mapper type="glob" from="*messages.properties" to="*messages_en.properties"/>
    </copy>

    <javadoc sourcefiles="src/checkstyle/com/puppycrawl/tools/checkstyle/api/TokenTypes.java"
             classpathref="javadoc.classpath"
             encoding="iso-8859-1"
             source="${checkstyle.minimum.javaversion}"
             failonerror="yes">
      <doclet name="com.puppycrawl.tools.checkstyle.doclets.TokenTypesDoclet"
              path="${checkstyle.dest}">
        <param name="-destfile" value="${checkstyle.dest}/com/puppycrawl/tools/checkstyle/api/tokentypes.properties"/>
      </doclet>
    </javadoc>
  </target>

  <target name="compile.testinputs" description="Compile test inputs">
    <mkdir dir="${testinputs.dest}" />
    <depend srcdir="src/testinputs" destdir="${testinputs.dest}" closure="yes"/>
    <!-- start of a change to turn on compilation of all input files -->
    <!-- under JDK1.5. -->
    <javac srcdir="src/testinputs"
           destdir="${testinputs.dest}"
           deprecation="on" debug="on"
           source="${checkstyle.testinputs.minimum.javaversion}"
           target="${checkstyle.testinputs.minimum.javaversion}"
           includeAntRuntime="false">
      <exclude name="**/j2ee/*" />
      <exclude name="**/InputAssertIdentifier.java" />
      <exclude name="**/InputClone.java" />
      <exclude name="**/InputCovariant.java" />
      <exclude name="**/InputGrammar.java" />
      <exclude name="**/InputImport.java" />
      <exclude name="**/InputJUnitTest.java" />
      <exclude name="**/InputSetterGetter.java" />
      <exclude name="**/InputSimple.java" />
      <exclude name="**/InputValidMethodIndent.java" />
      <exclude name="**/Post13KeywordsAsIdentifiersOK.java" />
    </javac>
  </target>

  <!-- Compiles only the test code. Input files are excluded from
       compilation, they contain code like assert statements
       that does not compile on all JDKs -->
  <target name="compile.tests" depends="compile.checkstyle, setup.emma"
          description="Compiles the test code">

    <mkdir dir="${tests.dest}" />
    <depend srcdir="src/tests" destdir="${tests.dest}" closure="yes"/>
    <javac srcdir="src/tests"
           destdir="${tests.dest}"
           deprecation="on" debug="on"
           classpathref="tests.buildpath"
           encoding="iso-8859-1"
           source="${checkstyle.minimum.javaversion}"
           target="${checkstyle.minimum.javaversion}"
           includeAntRuntime="false"/>

    <!-- now instrument the classes -->
    <mkdir dir="${emma.dest}/classes"/>
    <emma enabled="${emma.enabled}">
      <instr destdir="${emma.dest}/classes"
             metadatafile="${emma.dest}/metadata.emma"
             >
        <instrpath>
          <pathelement location="${checkstyle.dest}"/>
        </instrpath>
        <filter excludes="com.puppycrawl.tools.checkstyle.doclets.*"/>
        <filter excludes="com.puppycrawl.tools.checkstyle.gui.*"/>
        <filter excludes="com.puppycrawl.tools.checkstyle.grammars.*"/>
      </instr>
    </emma>
  </target>

  <!-- -->
  <!-- TEST TARGETS -->
  <!-- -->

  <!-- Run the GUI -->
  <target name="run.gui" depends="compile.checkstyle"
          description="Run the GUI for displaying a tree">
    <java classname="com.puppycrawl.tools.checkstyle.gui.Main"
          fork="yes" classpathref="run.classpath">
    </java>
  </target>

  <!-- runs the command line version on a file -->
  <target name="run.checkstyle" depends="compile.tests"
          description="Runs the command line version on a file">
    <java classname="com.puppycrawl.tools.checkstyle.Main"
          fork="yes"
          dir="."
          classpathref="run.classpath">
      <sysproperty key="checkstyle.allow.tabs" value="yes"/>
      <arg value="-c"/>
      <arg file="checkstyle_checks.xml"/>
      <arg value="src/testinputs/com/puppycrawl/tools/checkstyle/InputSimple.java"/>
    </java>
    <java classname="com.puppycrawl.tools.checkstyle.Main"
          fork="yes"
          dir="."
          classpathref="run.classpath">
      <arg value="-c"/>
      <arg file="checkstyle_checks.xml"/>
      <arg value="-r"/>
      <arg file="src/checkstyle/com/puppycrawl/tools/checkstyle/api"/>
    </java>
  </target>

  <target name="enable.todo" description="Will enable checking for TODO's">
    <property name="todo.pattern" value="TODO:"/>
  </target>

  <target name="checkstyle.checkstyle" depends="compile.checkstyle"
          description="Runs checkstyle against it's own sources">
    <taskdef name="checkstyle"
             classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
      <classpath refid="run.classpath"/>
    </taskdef>
    <delete file="${target.dir}/cachefile" />

    <property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/>
    <property name="check.config" location="checkstyle_checks.xml"/>
    <property name="translation.severity" value="ignore"/>
    <checkstyle config="${check.config}"
                failOnViolation="false"
                failureProperty="checkstyle.failure.property"
                >
      <fileset dir="src/checkstyle"
               includes="**/*.java,**/*.properties"
               excludes="**/Generated*.java,**/gui/*,**/transmogrify/*"/>
      <formatter type="plain"/>
      <formatter type="xml" toFile="${target.dir}/cs_errors.xml"/>
      <classpath refid="run.classpath"/>
      <property key="checkstyle.cache.file" file="${target.dir}/cachefile"/>
      <property key="checkstyle.header.file" file="java.header"/>
      <property key="checkstyle.importcontrol.file" file="import-control.xml"/>
      <property key="checkstyle.suppressions.file"
                file="suppressions.xml"/>
    </checkstyle>

    <fail if="checkstyle.failure.property"
          message="Checkstyle failed: ${checkstyle.failure.property}"
          />
  </target>

  <target name="checkstyle.style" depends="compile.checkstyle"
          description="Runs checkstyle against it's own sources to test generation of error reports">
    <taskdef name="checkstyle"
             classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
      <classpath refid="run.classpath"/>
    </taskdef>
    <delete file="${target.dir}/cachefile" />

    <property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/>
    <property name="check.config" location="checkstyle_checks.xml"/>
    <property name="translation.severity" value="ignore"/>
    <checkstyle failonviolation="false" config="${check.config}">
      <fileset dir="src/checkstyle"
               includes="**/*.java,**/*.properties"
               excludes="**/Generated*.java,**/gui/*,,**/transmogrify/*"/>
      <formatter type="xml" toFile="${target.dir}/cs_errors.xml"/>
      <classpath refid="run.classpath"/>
      <property key="checkstyle.cache.file" file="${target.dir}/cachefile"/>
      <property key="checkstyle.header.file" file="java.header"/>
      <property key="checkstyle.importcontrol.file" file="import-control.xml"/>
      <property key="checkstyle.suppressions.file"
                file="suppressions.xml"/>
    </checkstyle>
    <mkdir dir="${target.dir}/style/frames"/>
    <mkdir dir="${target.dir}/style/noframes"/>
    <mkdir dir="${target.dir}/style/noframes-sorted"/>
    <mkdir dir="${target.dir}/style/simple"/>
    <mkdir dir="${target.dir}/style/csv"/>
    <mkdir dir="target/style/author"/>
    <style basedir="${target.dir}"
           destdir="${target.dir}/style/noframes"
           includes="cs_errors.xml"
           style="contrib/checkstyle-noframes.xsl"/>
    <style basedir="${target.dir}"
           destdir="${target.dir}/style/noframes-sorted"
           includes="cs_errors.xml"
           style="contrib/checkstyle-noframes-sorted.xsl"/>
    <style basedir="${target.dir}"
           destdir="${target.dir}/style/frames"
           includes="cs_errors.xml"
           style="contrib/checkstyle-frames.xsl"/>
    <style basedir="${target.dir}"
           destdir="${target.dir}/style/simple"
           includes="cs_errors.xml"
           style="contrib/checkstyle-simple.xsl"/>
    <style out="${target.dir}/style/csv/report-csv.txt"
           in="${target.dir}/cs_errors.xml"
           style="contrib/checkstyle-csv.xsl"/>
    <style basedir="target"
           destdir="target/style/author"
           includes="cs_errors.xml"
           style="contrib/checkstyle-author.xsl"/>
  </target>

  <!-- Targets to verify that JUnit is in the classpath -->
  <target name="-check.junit"
          description="Checks whether JUnit is in the classpath">
    <available property="have.junit"
               classname="junit.framework.TestListener"/>
  </target>

  <target name="-require.junit" depends="-check.junit" unless="have.junit"
          description="Fails if JUnit is not present in the classpath">
    <fail message="Need to have JUnit in your CLASSPATH to run the tests. Consider using the one in the lib directory."/>
  </target>

  <!-- Targets to verify that Xalan is in the classpath -->
  <target name="-check.xalan"
          description="Checks whether xalan is in the classpath">
    <condition property="have.xalan">
      <or>
        <!-- jdk 1.3 with modern Xalan -->
        <available classname="org.apache.xalan.Version" />
        <!-- Xalan classes in jdk 1.4 (beta 3) are OK for running -->
        <!-- the tests, but there is no Version class in jdk 1.4: -->
        <!-- fallback to stable jaxp implementation class -->
        <available classname="org.apache.xalan.transformer.TransformerImpl"/>
        <!--
             In JDK 1.5 Sun has decided to repackage Xalan in it's own
             package com.sun.org.apache..., see Java bug 4740355.
             Additionally at least Ant 1.6.2 is required to make junitreport
             work with Xalan XSLTC and/or JDK 1.5 (Ant bug 27541)
             -->
        <and>
      	  <or>
            <equals arg1="${ant.java.version}" arg2="1.5" />
            <equals arg1="${ant.java.version}" arg2="1.6" />
          </or>
          <!-- TODO: find a more elegant way to specify *minimum* version -->
          <not>
            <or>
              <contains string="${ant.version}" substring="version 1.4" />
              <contains string="${ant.version}" substring="version 1.5" />
              <contains string="${ant.version}" substring="version 1.6.0" />
              <contains string="${ant.version}" substring="version 1.6.1" />
            </or>
          </not>
        </and>
      </or>
    </condition>
  </target>

  <target name="-require.xalan" depends="-check.xalan" unless="have.xalan"
          description="Fails if xalan is not present in the classpath">
    <fail>
Need to have Xalan in your CLASSPATH to run the tests.
You can download it from http://xml.apache.org/.
Alternatively you can upgrade JDK 1.4 or higher.
For users of JDK 1.5 at least version 1.6.2 of Ant is required.
    </fail>
  </target>

  <!-- To run the tests need Xalan in the classpath -->
  <target name="run.tests"
          depends="compile.tests,-require.ant15,-require.junit,-require.xalan,compile.testinputs"
          description="Runs the tests for checkstyle">

    <mkdir dir="${testreport.dir}"/>
    <property name="testinputs.dir"
              location="${basedir}/src/testinputs/com/puppycrawl/tools/checkstyle"/>

    <junit printsummary="yes"
           fork="yes"
           forkmode="perBatch"
           haltonfailure="no"
           showoutput="yes"
           failureProperty="tests.have.failed">

      <sysproperty key="testinputs.dir" value="${testinputs.dir}"/>
      <sysproperty key="checkstyle.use.recursive.algorithm"
                   value="${checkstyle.use.recursive.algorithm}"/>
      <sysproperty key="checkstyle.root" value="${basedir}" />

      <sysproperty key="emma.coverage.out.file"
                   file="${emma.coverage.out.file}"
                   />
      <sysproperty key="emma.coverage.out.merge"
                   value="true" />

      <formatter type="xml" />
      <classpath refid="tests.runpath"/>
      <batchtest todir="${testreport.dir}">
        <fileset dir="src/tests">
          <include name="${testcases}" />
        </fileset>
      </batchtest>
    </junit>

    <junitreport todir="${testreport.dir}">
      <fileset dir="${testreport.dir}">
        <include name="TEST-*.xml"/>
      </fileset>
      <report todir="${testreport.dir}"/>
    </junitreport>

    <property name="report"
              value="${basedir}/${testreport.dir}/index.html"/>

    <!-- generate the emma report -->
    <emma enabled="${emma.enabled}">
      <report sourcepath="src/checkstyle">
        <fileset dir="${emma.dest}" includes="*.emma"/>
        <html outfile="${emma.report.dir}/index.html"/>
      </report>
    </emma>

    <fail if="tests.have.failed"
          message="Unit tests failed - Report is available in ${report}"/>
  </target>

  <!-- -->
  <!-- DIST TARGETS -->
  <!-- -->
  <target name="build.bindist" depends="compile.checkstyle, javadoc, xdocs"
          description="Builds the compressed distribution files">
    <delete dir="${dist.dir}/checkstyle-${version}" />
    <mkdir dir="${dist.dir}/checkstyle-${version}" />
    <copy file="config/manifest.mf" todir="${target.dir}">
      <filterset>
        <filter token="CHECKSTYLE_VERSION" value="${version}" />
      </filterset>
    </copy>
    <jar jarfile="${dist.dir}/checkstyle-${version}/checkstyle-${version}.jar"
         basedir="${checkstyle.dest}"
         excludes="**/j2ee/**"
         manifest="${target.dir}/manifest.mf" />
    <jar jarfile="${dist.dir}/checkstyle-${version}/checkstyle-optional-${version}.jar"
         basedir="${checkstyle.dest}"
         includes="**/j2ee/**"/>
    <!-- copy the JARS and make a mega JAR out of them -->
    <copy file="${antlr.jar}" todir="${dist.dir}/checkstyle-${version}" />
    <copy file="${beanutils.jar}" todir="${dist.dir}/checkstyle-${version}" />
    <copy file="${collections.jar}" todir="${dist.dir}/checkstyle-${version}" />
    <copy file="${cli.jar}" todir="${dist.dir}/checkstyle-${version}" />
    <copy file="${logging.jar}" todir="${dist.dir}/checkstyle-${version}" />
    <jar jarfile="${dist.dir}/checkstyle-${version}/checkstyle-all-${version}.jar"
    	 manifest="${target.dir}/manifest.mf" 
    	 filesetmanifest="skip">
        <zipfileset src="${dist.dir}/checkstyle-${version}/antlr.jar" excludes="META-INF/*"/>
        <!-- beanutils packages parts of commons collections, exclude it here so we don't have it in checkstyle-all.jar twice -->
    	<zipfileset src="${dist.dir}/checkstyle-${version}/commons-beanutils-core.jar" excludes="META-INF/*,org/apache/commons/collections/*,**/*.html"/>
        <zipfileset src="${dist.dir}/checkstyle-${version}/commons-collections.jar" excludes="META-INF/*"/>
        <zipfileset src="${dist.dir}/checkstyle-${version}/commons-cli.jar" excludes="META-INF/*"/>
        <zipfileset src="${dist.dir}/checkstyle-${version}/commons-logging.jar" excludes="META-INF/*,**/package.html"/>
        <zipfileset src="${dist.dir}/checkstyle-${version}/checkstyle-${version}.jar" excludes="META-INF/*"/>
    </jar>	
    <!-- copy stuff without filtering -->
    <copy todir="${dist.dir}/checkstyle-${version}">
      <fileset dir=".">
        <include name="**/.cvsignore"/>
        <include name="**/CVS"/>
        <include name="*.xml"/>
        <include name="LICENSE*"/>
        <include name="README"/>
        <include name="RIGHTS.antlr"/>
        <include name="TODO"/>
        <include name="contrib/**"/>
        <include name="java.header"/>
      </fileset>
    </copy>

    <!-- Make the docs directory -->
    <mkdir dir="${dist.dir}/checkstyle-${version}/docs" />
    <copy todir="${dist.dir}/checkstyle-${version}/docs">
      <fileset dir="${xdocs.dest}"/>
    </copy>

    <!-- create the final zip & tar/gzip files -->
    <zip zipfile="${dist.dir}/checkstyle-${version}.zip">
      <fileset dir="${dist.dir}">
        <include name="checkstyle-${version}/**"/>
      </fileset>
    </zip>
    <tar tarfile="${dist.dir}/checkstyle-${version}.tar" longfile="gnu"
         basedir="${dist.dir}" includes="checkstyle-${version}/**" />
    <gzip zipfile="${dist.dir}/checkstyle-${version}.tar.gz"
          src="${dist.dir}/checkstyle-${version}.tar" />
  </target>

  <target name="build.srcdist" depends="checkstyle.checkstyle"
          description="Builds the compressed source files for distribution">
    <delete dir="${dist.dir}/checkstyle-src-${version}" />
    <mkdir dir="${dist.dir}/checkstyle-src-${version}" />
    <copy todir="${dist.dir}/checkstyle-src-${version}">
      <fileset dir=".">
        <exclude name="src/checkstyle/**/Generated*"/>
        <include name="*.xml"/>
        <include name="LICENSE*"/>
        <include name="README"/>
        <include name="RIGHTS.antlr"/>
        <include name="TODO"/>
        <include name="build.xml"/>
        <include name="config/**"/>
        <include name="contrib/**"/>
        <include name="java.header"/>
        <include name="lib/**"/>
        <include name="src/**"/>
      </fileset>
    </copy>

    <!-- Produce the final distributions -->
    <zip zipfile="${dist.dir}/checkstyle-src-${version}.zip">
      <fileset dir="${dist.dir}">
        <include name="checkstyle-src-${version}/**"/>
      </fileset>
    </zip>
    <tar tarfile="${dist.dir}/checkstyle-src-${version}.tar" longfile="gnu"
         basedir="${dist.dir}" includes="checkstyle-src-${version}/**" />
    <gzip zipfile="${dist.dir}/checkstyle-src-${version}.tar.gz"
          src="${dist.dir}/checkstyle-src-${version}.tar" />
  </target>

  <!-- -->
  <!-- DOC TARGETS -->
  <!-- -->
  <target name="javadoc" depends="compile.checkstyle"
          description="Creates the javadoc html files">
    <mkdir dir="${xdocs.dest}/api" />
    <javadoc sourcepath="src/checkstyle" destdir="${xdocs.dest}/api"
             Windowtitle="Checkstyle API"
             classpathref="javadoc.classpath"
             Use="true"
             Footer="&lt;a target=&quot;_top&quot; href=&quot;./{@docRoot}/../index.html&quot;&gt;Back to the Checkstyle Home Page&lt;/a&gt;"
             useExternalFile="yes"
             encoding="iso-8859-1"
             source="${checkstyle.minimum.javaversion}"
             failonerror="yes" >
      <link packagelistLoc="${basedir}/config/jdk-package-list"
              offline="yes"
              href="http://java.sun.com/j2se/1.4.2/docs/api/" />
      <link packagelistLoc="${basedir}/config/antlr-package-list"
              offline="yes"
              href="http://www.antlr.org/javadoc/" />
      <fileset dir="src/checkstyle">
        <include name="**/*.java"/>
        <exclude name="**/Generated*.java" />
        <exclude name="**/gui/*.java" />
        <exclude name="**/checks/**"/>
      </fileset>
    </javadoc>
  </target>

  <target name="xdocs" depends="compile.checkstyle"
          description="generate documentation">

    <mkdir dir="${xdocs.dest}"/>

    <mkdir dir="${target.dir}/xdocs"/>

    <copy todir="${target.dir}/xdocs">
      <fileset dir="${xdocs.src}">
        <exclude name="**/*.css"/>
        <exclude name="**/*.gif"/>
        <exclude name="**/*.png"/>
      </fileset>
      <filterset>
        <filter token="CHECKSTYLE_VERSION" value="${version}" />
      </filterset>
    </copy>

    <javadoc sourcepath="src/checkstyle" destdir="${target.dir}/xdocs"
             classpathref="build.classpath"
             encoding="iso-8859-1"
             source="${checkstyle.minimum.javaversion}"
             failonerror="yes">
      <doclet name="com.puppycrawl.tools.checkstyle.doclets.CheckDocsDoclet"
              path="${checkstyle.dest}">
      </doclet>
      <fileset dir="src/checkstyle">
        <include name="**/checks/**/*Check.java" />
        <exclude name="**/checks/j2ee/AbstractInterfaceCheck.java" />
      </fileset>
    </javadoc>

    <taskdef name="anakia" classname="org.apache.velocity.anakia.AnakiaTask">
      <classpath refid="velocity.classpath"/>
    </taskdef>

    <copy todir="${xdocs.dest}">
      <fileset dir="${xdocs.src}">
        <include name="**/*.css"/>
        <include name="**/*.gif"/>
        <include name="**/*.png"/>
      </fileset>
    </copy>

    <anakia basedir="${target.dir}/xdocs"
            destdir="${xdocs.dest}/"
            extension=".html"
            style="site.vsl"
            projectFile="stylesheets/project.xml"
            excludes="**/stylesheets/**"
            includes="**/*.xml"
            lastModifiedCheck="true"
            templatePath="${xdocs.src}/stylesheets">
    </anakia>

  </target>

  <target name="report.translation"
          description="Sets up reporting on translation errors"
          >
    <property name="translation.severity" value="error"/>
  </target>

  <target name="gump" depends="build.bindist,build.srcdist,run.tests"
          description="Runs the test for GUMP testing"/>


  <target name="validate.xml"
          description="Validates checkstyle XML file">
    <xmlvalidate file="checkstyle_checks.xml">
      <xmlcatalog>
        <dtd
          publicId="-//Puppy Crawl//DTD Check Configuration 1.1//EN"
          location="${checkstyle.dir}/configuration_1_1.dtd"/>
      </xmlcatalog>
    </xmlvalidate>
  </target>

  <!-- Targets to verify that ANT version if at least 1.5 -->
  <target name="-check.ant15">
    <echo>version is ${ant.version}</echo>
    <condition property="have.ant15">
      <not>
        <or>
          <equals arg1="${ant.version}"
                  arg2="Ant version 1.4.1 compiled on October 11 2001"/>
        </or>
      </not>
    </condition>
  </target>

  <target name="-require.ant15" depends="-check.ant15" unless="have.ant15">
    <fail message="Need at least version 1.5 of ANT - you have ${ant.version}"/>
  </target>

  <target name="checkstyle.run" depends="compile.checkstyle"
          description="Runs checkstyle.">
    <taskdef name="checkstyle"
             classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
      <classpath refid="run.classpath"/>
    </taskdef>
    <delete file="${target.dir}/cachefile" />

    <property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/>
    <property name="check.config" location="checkstyle_checks.xml"/>
    <property name="translation.severity" value="ignore"/>
    <checkstyle config="${custom.config}" file="${file.to.check}">
      <formatter type="plain"/>
      <formatter type="xml" toFile="${target.dir}/cs_errors.xml"/>
      <classpath refid="run.classpath"/>
    </checkstyle>
  </target>

  <target name="setup.emma">
    <taskdef resource="emma_ant.properties">
      <classpath>
        <fileset dir="lib" includes="emma*.jar"/>
      </classpath>
    </taskdef>

    <property name="emma.coverage.out.file"
              value="${emma.dest}/coverage.emma"/>
    <property name="emma.report.dir" value="${emma.dest}/report"/>
    <mkdir dir="${emma.report.dir}"/>
  </target>

  <!-- contrib related targets -->
  <property name="bcel.dest" value="${target.dir}/bcel" />
  <property name="bcel.src" value="contrib/bcel/src/checkstyle/" />

  <path id="bcel.classpath">
    <pathelement location="${bcel.jar}" />
    <path refid="run.classpath" />
  </path>

  <target name="compile.bcel" depends="compile.checkstyle"
          description="Compiles bcel-checks">
    <echo message="${bcel.jar}" />
    <mkdir dir="${bcel.dest}" />
    <depend srcdir="${bcel.src}"
            destdir="${bcel.dest}" closure="yes"/>
    <javac srcdir="${bcel.src}"
           destdir="${bcel.dest}"
           includes="**/*.java"
           deprecation="on" debug="on"
           source="${checkstyle.minimum.javaversion}"
           target="${checkstyle.minimum.javaversion}"
           classpathref="bcel.classpath"
           encoding="iso-8859-1"
           includeAntRuntime="false"/>

    <copy todir="${bcel.dest}">
      <fileset dir="${bcel.src}" includes="**/*.properties"/>
      <fileset dir="${bcel.src}" includes="**/*.xml"/>
      <fileset dir="${bcel.src}" includes="**/*.dtd"/>
    </copy>
  </target>

  <target name="build.mavenbundles" depends="build.bindist"
          description="Builds bundles that can be uploaded to Maven's central repository"
          >
    <mkdir dir="${dist.dir}/maven-bundles" />
    <!-- Bundle for checkstyle -->
    <jar jarfile="${dist.dir}/maven-bundles/checkstyle-${version}-bundle.jar">
      <fileset dir="${basedir}" includes="pom.xml"/>
      <fileset dir="${dist.dir}/checkstyle-${version}">
        <include name="checkstyle-${version}.jar"/>
      </fileset>
    </jar>
    <!-- Bundle for checkstyle-optional -->
    <mkdir dir="${dist.dir}/maven-bundles/temp" />
    <!-- Create a temporary copy of the optional pom with another name so that
         it can be included in the optional-bundle -->
    <copy file="${basedir}/pom-optional.xml" tofile="${dist.dir}/maven-bundles/temp/pom.xml" />
    <jar jarfile="${dist.dir}/maven-bundles/checkstyle-optional-${version}-bundle.jar">
      <fileset dir="${dist.dir}/maven-bundles/temp" includes="pom.xml"/>
      <fileset dir="${dist.dir}/checkstyle-${version}">
        <include name="checkstyle-optional-${version}.jar"/>
      </fileset>
    </jar>
    <!-- Remove the temporary directory -->
    <delete dir="${dist.dir}/maven-bundles/temp"/>
  </target>
</project>