File: build.xml

package info (click to toggle)
libcommons-logging-java 1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,196 kB
  • sloc: java: 5,419; xml: 3,922; makefile: 8
file content (811 lines) | stat: -rw-r--r-- 31,231 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
<!--

 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at
 
      http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

-->

<!--
  - Ant build file for commons-logging.
  -
  - Quick build instructions:
  -  * ant getlibs
  -  * cp build.properties.sample build.properties
  -  * ant -lib lib/junit-3.8.1.jar dist 
  -
  - Note that this build file uses the optional <junit> task. While the
  - task "adapter" class comes by default with ant 1.6+, the junit libraries
  - (3.8.1 or later) are also required to be made available to ant. This
  - requires that you do one of the following:
  -  * create directory ~/.ant/lib and place the junit jar there
  -  * put the junit jar in $ANT_HOME/lib
  -  * run ant as "ant -lib path-to-junit-jar"
  -  * put the junit jar in $CLASSPATH
  -
  - Note when building JCL for release it is strongly recommended that a 1.2 JVM
  - is used for the main compile and the home.jdk4 property used to specify
  - the path to a 1.4 J2SDK. This will be used to compile those classes
  - which require the 1.4 API. 
  -
  - $Id: build.xml 1608092 2014-07-05 18:11:22Z tn $
  -->

<project name="Logging" default="all" basedir=".">


<!-- ========== Initialize Properties ===================================== -->


  <property file="build.properties"/>                <!-- Component local   -->
  <property file="../build.properties"/>             <!-- Commons local     -->
  <property file="${user.home}/build.properties"/>   <!-- User local        -->


<!-- ========== External Dependencies ===================================== -->


  <!-- The directories corresponding to your necessary dependencies -->
  <property name="junit.home"              value="/usr/local/junit3.5"/>
  <property name="jakarta.home"            value="../.."/>
  <property name="commons.home"            value="../.."/>

  <!--
    - The names of the unit tests to run. By default all tests are run, but
    - this can be overridden from the command line by something like:
    -   ant -Dtestmatch=**/FooTestCase test
    -->
  <property name="testmatch" value="**/*TestCase"/>


<!-- ========== Derived Values ============================================ -->


  <!-- The locations of necessary jar files -->
  <property name="junit.jar"               value="junit-3.8.1.jar"/>
  <property name="log4j12.jar"             value="log4j-1.2.17.jar"/>
  <property name="log4j13.jar"             value="log4j-1.3.0.jar"/>
  <property name="logkit.jar"              value="logkit-1.0.1.jar"/>
  <property name="avalon-framework.jar"    value="avalon-framework-4.1.5.jar"/>
  <property name="servletapi.jar"          value="servletapi-2.3.jar"/>


<!-- ========== Component Declarations ==================================== -->


  <!-- The name of this component -->
  <property name="component.name"          value="logging"/>

  <!-- The primary package name of this component -->
  <property name="component.package"       value="org.apache.commons.logging"/>

  <!-- The title of this component -->
  <property name="component.title"         value="Logging Wrapper Library"/>

  <!-- The current version number of this component -->
  <property name="component.version"       value="1.2"/>

  <!-- The base directory for compilation targets -->
  <property name="build.home"              value="${basedir}/target"/>

  <!-- The base directory for component configuration files -->
  <property name="conf.home"               value="src/conf"/>

  <!-- The base directory for distribution targets -->
  <property name="dist.home"               value="dist"/>

  <!-- The base directory for releases  -->
  <property name="artifacts.home"          value="artifacts"/>

  <!-- The base directory for component sources -->
  <property name="source.home"             value="src/main/java"/>

  <!-- The base directory for unit test sources -->
  <property name="test.home"               value="src/test/java"/>

  <!-- The base directory for unit test resources -->
  <property name="test.resources"          value="src/test/resources"/>

  <!-- jar names -->
  <property name="core.jar.name" value="commons-${component.name}-${component.version}.jar"/>
  <property name="api.jar.name" value="commons-${component.name}-api-${component.version}.jar"/>
  <property name="adapters.jar.name" value="commons-${component.name}-adapters-${component.version}.jar"/>
  <property name="src.ide.name" value="commons-${component.name}-${component.version}-ide.zip"/>

  <!-- dist names -->
  <property name="windows.dist.name" value="commons-${component.name}-${component.version}.zip"/>
  <property name="nix.dist.name" value="commons-${component.name}-${component.version}.tar.gz"/>
  
<!-- ========== Compiler Defaults ========================================= -->

  <!-- Version of java class files to generate. -->
  <property name="target.version" value="1.2"/>

  <!-- Version of java source to accept -->
  <property name="source.version" value="1.2"/>

  <!-- Should Java compilations set the 'debug' compiler option? -->
  <property name="compile.debug"           value="true"/>

  <!-- Should Java compilations set the 'deprecation' compiler option? -->
  <property name="compile.deprecation"     value="false"/>

  <!-- Should Java compilations set the 'optimize' compiler option? -->
  <property name="compile.optimize"        value="false"/>

  <!-- Construct compile classpath -->
  <path id="compile.classpath">
    <pathelement location="${build.home}/classes"/>
    <pathelement location="${junit.jar}"/>
    <pathelement location="${logkit.jar}"/>
    <pathelement location="${avalon-framework.jar}"/>
    <pathelement location="${servletapi.jar}"/>
  </path>


<!-- ========== Test Execution Defaults =================================== -->


  <!-- 
    - Construct unit test classpath (generic tests).
    -
    - Note that unit tests that use the PathableTestSuite approach don't need
    - any of this (except junit). However unit tests that don't use PathableTestSuite
    - to configure their classpath will need the basic classes to be provided
    - via this mechanism.
    -->
  <path id="test.classpath">
    <pathelement location="${build.home}/classes"/>
    <pathelement location="${build.home}/tests"/>
    <pathelement location="${junit.jar}"/>
    <pathelement location="${logkit.jar}"/>
    <pathelement location="${avalon-framework.jar}"/>
    <pathelement location="${conf.home}"/>
    <pathelement location="${servletapi.jar}"/>
  </path>

  <!-- Construct unit test classpath (Log4J tests) -->
  <path id="test.classpath.log4j13">
    <pathelement location="${build.home}/classes"/>
    <pathelement location="${build.home}/tests"/>
    <pathelement location="${junit.jar}"/>
    <pathelement location="${log4j13.jar}"/>
  </path>

  <!-- Construct unit test classpath (Log4J tests) -->
  <path id="test.classpath.log4j12">
    <pathelement location="${build.home}/classes"/>
    <pathelement location="${build.home}/tests"/>
    <pathelement location="${junit.jar}"/>
    <pathelement location="${log4j12.jar}"/>
  </path>

  <!-- Construct javadoc classpath -->
  <path id="javadoc.classpath">
    <path refid="compile.classpath"/>
    <pathelement location="${log4j12.jar}"/>
  </path>

  <!-- Should all tests fail if one does? -->
  <property name="test.failonerror"        value="true"/>

  <!-- The test runner to execute -->
  <property name="test.runner" value="junit.textui.TestRunner"/>

  <!-- libs to pass to the tests -->
  <property name="test.sysprops.testclasses" value="${build.home}/tests"/>
  <property name="test.sysprops.log4j12" value="${log4j12.jar}"/>
  <property name="test.sysprops.log4j13" value="${log4j13.jar}"/>
  <property name="test.sysprops.logkit" value="${logkit.jar}"/>
  <property name="test.sysprops.servlet-api" value="${servletapi.jar}"/>
  <property name="test.sysprops.commons-logging" value="${build.home}/${core.jar.name}"/>
  <property name="test.sysprops.commons-logging-api" value="${build.home}/${api.jar.name}"/>
  <property name="test.sysprops.commons-logging-adapters" value="${build.home}/${adapters.jar.name}"/>
  <propertyset id="test-lib-props">
    <propertyref prefix="test.sysprops."/>
    <mapper type="glob" from="test.sysprops.*" to="*"/>
  </propertyset>

<!-- ========== Executable Targets ======================================== -->


  <!--
    - Running this target will download all the necessary dependencies into the "lib" subdirectory.
    -->
  <property name="getlibs.base" value="http://repo1.maven.org/maven"/>
  <target name="getlibs">
    <mkdir dir="lib"/>
    <get dest="lib/junit-3.8.1.jar" src="${getlibs.base}/junit/jars/junit-3.8.1.jar"/>
    <get dest="lib/logkit-1.0.1.jar" src="${getlibs.base}/logkit/jars/logkit-1.0.1.jar"/>
    <get dest="lib/avalon-framework-4.1.3.jar" src="${getlibs.base}/avalon-framework/jars/avalon-framework-4.1.3.jar"/>
    <get dest="lib/log4j-1.2.12.jar" src="${getlibs.base}/log4j/jars/log4j-1.2.12.jar"/>
    <get dest="lib/servletapi-2.3.jar" src="${getlibs.base}/servletapi/jars/servletapi-2.3.jar"/>
  </target>

  <target name="init"
   description="Initialize and evaluate conditionals">
    <echo message="-------- ${component.title} ${component.version} --------"/>
    <filter  token="name"                  value="${component.name}"/>
    <filter  token="package"               value="${component.package}"/>
    <filter  token="version"               value="${component.version}"/>
  </target>  
  
  <target name="prepare" depends="init"
   description="Prepare build directory">

    <echo>
    Log4j12: ${log4j12.jar}
    <!-- Note: log4j13 support is not available in the 1.1 release. -->
    <!--Log4j13: ${log4j13.jar}-->
    LogKit: ${logkit.jar}
    Avalon-Framework: ${avalon-framework.jar}
    </echo>

    <mkdir dir="${build.home}"/>
    <mkdir dir="${build.home}/classes"/>
    <mkdir dir="${build.home}/conf"/>
    <mkdir dir="${build.home}/tests"/>
  </target>


  <target name="static" depends="prepare"
   description="Copy static files to build directory">
    <tstamp/>
    <copy  todir="${build.home}/conf" filtering="on">
      <fileset dir="${conf.home}" includes="*.MF"/>
      <fileset dir="${conf.home}" includes="*.properties"/>
    </copy>
  </target>

  <target name="compile" depends="static,compile-only"
          description="Compile shareable components"/>

  <target name='discovery' depends='init'>
    <available property="jdk.1.4.present"
               classname="java.util.logging.Logger"/>

    <available property="logkit.present"
               classpathref="compile.classpath"
               classname="org.apache.log.Logger"/>

    <available property="avalon-framework.present"
               classpathref="compile.classpath"
               classname="org.apache.avalon.framework.logger.Logger"/>

    <available file="${log4j12.jar}" property="log4j12.present"/>
    <available file="${log4j13.jar}" property="log4j13.present"/>
    <available file="${build.home}/docs" property="maven.generated.docs.present"/>
  </target>

  <target name="log4j12-warning" unless='log4j12.present' depends='init,discovery'>
    <echo>
    *** WARNING ***
    Log4j 1.2 not found: Cannot Build Log4JLogger
    </echo>
  </target>
  
  <target name="log4j13-warning" unless='log4j13.present' depends='init,discovery'>
    <!--
      - Note: log4j13 support is not available in the 1.1 release.
      - If we add it in a future release, the code below should be uncommented.
      -->
    <!--
    <echo>
    *** WARNING ***
    Log4j 1.3 not found: Cannot Build Log4J13Logger
    </echo>
    -->
  </target>
  
  <target name="logkit-warning" unless='logkit.present' depends='init,discovery'>
    <echo>
    *** WARNING ***
    LogKit not found: Cannot Build LogKitLogger
    </echo>
  </target>
  
  <target name="avalon-framework-warning" unless='avalon-framework.present' depends='init,discovery'>
    <echo>
    *** WARNING ***
    Avalon-Framework not found: Cannot Build AvalonLogger
    </echo>
  </target>
  
  <target name="jdk1.4-warning" unless='jdk.1.4.present' depends='init,discovery'>
    <echo>
    *** WARNING ***
    JDK 1.4 not present: Cannot Build Jdk14Logger
    </echo>
  </target>
  
  <target name="log4j12-test-warning" unless='log4j12.jar' depends='init,discovery'>
    <echo>
    *** WARNING ***
    Log4J 1.2.x Jar not found: Cannot execute 1.2.x tests
    </echo>
  </target>
    
  <target name='warning' 
    depends='log4j12-warning,log4j13-warning,logkit-warning,jdk1.4-warning,avalon-framework-warning,compile-1.4'/>

  <target name="compile-only" 
    depends="prepare,discovery,warning,show-lib-presence,compile-non-log4j,compile-log4j12,compile-log4j13,build-jar"/>

  <target name="show-lib-presence">
    <echo  message="jdk.1.4.present=${jdk.1.4.present}"/>
    <echo  message="log4j12.present=${log4j12.present}"/>
    <!-- Note: log4j13 support is not available in the 1.1 release. -->
    <!--<echo  message="log4j13.present=${log4j13.present}"/>-->
    <echo  message="logkit.present=${logkit.present}"/>
    <echo  message="avalon-framework.present=${avalon-framework.present}"/>
  </target>

  <target name="compile-non-log4j" depends="prepare,discovery">
    <!-- compile everything except Log4J classes -->
    <javac srcdir="${source.home}"
           destdir="${build.home}/classes"
           debug="${compile.debug}"
           deprecation="${compile.deprecation}"
           optimize="${compile.optimize}"
           source="${source.version}"
           target="${target.version}">

      <classpath refid="compile.classpath"/>
    
      <exclude name="org/apache/commons/logging/impl/Log4J*.java"/>

      <exclude name="org/apache/commons/logging/impl/Jdk13LumberjackLogger.java"
               unless="jdk.1.4.present"/>
      <exclude name="org/apache/commons/logging/impl/Jdk14Logger.java"
               unless="jdk.1.4.present"/>
      <exclude name="org/apache/commons/logging/impl/LogKitLogger.java"
               unless="logkit.present"/>
      <exclude name="org/apache/commons/logging/impl/AvalonLogger.java"
               unless="avalon-framework.present"/>
    </javac>
  </target>

  <target name="compile-1.4" depends="prepare,discovery,compile-non-log4j" if='executable.javac1.4'>
    <!-- 
      - Compiles those classes which require a 1.4+ JSDK.
      - This target will only be executed when ant is running a pre-1.4 JVM
      - and the home.jdk4 property is set.
      - This configuration is typically used to create a release only.
      -->
    <echo  message=""/>
    <echo  message="************************************************************"/>
    <echo  message="    Compiling 1.4 only classes using compiler@${executable.javac1.4}"/>
    <echo  message="************************************************************"/>
    <echo  message=""/>
    <javac srcdir="${source.home}"
           destdir="${build.home}/classes"
           debug="${compile.debug}"
           deprecation="${compile.deprecation}"
           optimize="${compile.optimize}"
           source="${source.version}"
           target="${target.version}"
           compiler='javac1.4'
           fork='yes'
           executable='${executable.javac1.4}'>

      <classpath refid="compile.classpath"/>
    
      <include name="org/apache/commons/logging/impl/Jdk13LumberjackLogger.java"
               unless="jdk.1.4.present"/>
      <include name="org/apache/commons/logging/impl/Jdk14Logger.java"
               unless="jdk.1.4.present"/>
    </javac>
  </target>

  <target name="compile-log4j12" depends="prepare,discovery">
    <!-- compile the log4j1.2 support classes -->
    <javac srcdir="${source.home}"
           destdir="${build.home}/classes"
           debug="${compile.debug}"
           deprecation="${compile.deprecation}"
           optimize="${compile.optimize}"
           source="${source.version}"
           target="${target.version}">

      <classpath refid="compile.classpath"/>
      <classpath>
        <!--
        <pathelement refid="compile.classpath"/>
        <classpath refid="compile.classpath"/>
        -->
        <pathelement location="${log4j12.jar}"/> 
      </classpath>

      <include name="org/apache/commons/logging/impl/Log4JLogger.java"
               if="log4j12.present"/>
    </javac>
  </target>

  <target name="compile-log4j13" depends="prepare,discovery">
    <!-- compile the log4j1.3 support classes -->
    <javac srcdir="${source.home}"
           destdir="${build.home}/classes"
           debug="${compile.debug}"
           deprecation="${compile.deprecation}"
           optimize="${compile.optimize}"
           source="${source.version}"
           target="${target.version}">

      <classpath refid="compile.classpath"/>
      <classpath>
        <pathelement location="${log4j13.jar}"/> 
      </classpath>

    <!--
      - Note: log4j13 support not available in 1.1 release. However if we do add it
      - in a future release, this entry will pick it up. In the meantime, this
      - simply compiles no classes.
      -->
      <include name="org/apache/commons/logging/impl/Log4J13Logger.java"
               if="log4j13.present"/>
    </javac>
  </target>

  <target name="build-jar">
    <copy  todir="${build.home}/classes" filtering="on">
      <fileset dir="${source.home}" excludes="**/*.java"/>
    </copy>
    <mkdir      dir="${build.home}/classes/META-INF"/>
    <copy      file="LICENSE.txt"
              todir="${build.home}/classes/META-INF"/>
    <copy      file="NOTICE.txt"
              todir="${build.home}/classes/META-INF"/>

    <jar jarfile="${build.home}/${core.jar.name}"
         basedir="${build.home}/classes"
         manifest="${build.home}/conf/MANIFEST.MF">
      <include name="org/apache/commons/logging/**" />
      <include name="META-INF/LICENSE.txt"/>
      <include name="META-INF/NOTICE.txt"/>
      <exclude name="**/package.html"/>
    </jar>

    <jar jarfile="${build.home}/${api.jar.name}"
         basedir="${build.home}/classes"
         manifest="${build.home}/conf/MANIFEST.MF">
      <include name="org/apache/commons/logging/*.class" />
      <include name="org/apache/commons/logging/impl/LogFactoryImpl*.class" />
      <include name="org/apache/commons/logging/impl/WeakHashtable*.class" />
      <include name="org/apache/commons/logging/impl/SimpleLog*.class" />
      <include name="org/apache/commons/logging/impl/NoOpLog*.class" />
      <include name="org/apache/commons/logging/impl/Jdk14Logger.class" />
      <include name="META-INF/LICENSE.txt"/>
      <include name="META-INF/NOTICE.txt"/>
      <exclude name="**/package.html"/>
    </jar>

    <jar jarfile="${build.home}/${adapters.jar.name}"
         basedir="${build.home}/classes"
         manifest="${build.home}/conf/MANIFEST.MF">
      <include name="org/apache/commons/logging/impl/**.class" />
      <include name="META-INF/LICENSE.txt"/>
      <include name="META-INF/NOTICE.txt"/>
      <exclude name="org/apache/commons/logging/impl/WeakHashtable*.class" />
      <exclude name="org/apache/commons/logging/impl/LogFactoryImpl*.class" />
    </jar>
  </target>

  <target name='compile.jdk1.4.tests' if='jdk.1.4.present'>
    <javac  srcdir="${test.home}"
           destdir="${build.home}/tests"
             debug="${compile.debug}"
       deprecation="${compile.deprecation}"
          optimize="${compile.optimize}"
            source="${source.version}"
            target="${target.version}">
      <classpath refid="test.classpath"/>
        <include name='**/jdk14/**'/>
    </javac>
  </target>

  <target name='compile.log4j.tests' if='log4j12.present'>
    <javac  srcdir="${test.home}"
           destdir="${build.home}/tests"
             debug="${compile.debug}"
       deprecation="${compile.deprecation}"
          optimize="${compile.optimize}"
            source="${source.version}"
            target="${target.version}">
      <classpath refid="test.classpath.log4j12"/>
        <include name='**/log4j/**'/>
        <!-- NOTE -->
        <!--
        Pathable tests do not reference the Log4J Logger directly
        but try to load them by reflection from particular loaders.
        They will therefore fail unless this logger is available.
        -->
        <include name='**/pathable/**'/>
        <!-- END NOTE -->
    </javac>
  </target>


  <target name='compile.avalon.tests' if='avalon-framework.present'>
    <javac  srcdir="${test.home}"
           destdir="${build.home}/tests"
             debug="${compile.debug}"
       deprecation="${compile.deprecation}"
          optimize="${compile.optimize}"
            source="${source.version}"
            target="${target.version}">
      <classpath refid="test.classpath"/>
      <include name='**/avalon/**'/>
    </javac>
  </target>
  
  <target name='compile.logkit.tests' if='logkit.present'>
    <javac  srcdir="${test.home}"
           destdir="${build.home}/tests"
             debug="${compile.debug}"
       deprecation="${compile.deprecation}"
          optimize="${compile.optimize}"
            source="${source.version}"
            target="${target.version}">
      <classpath refid="test.classpath"/>
      <include name='**/logkit/**'/>
    </javac>
  </target>

  <target name="compile.tests" depends="compile"
   description="Compile unit test cases">
    <javac  srcdir="${test.home}"
           destdir="${build.home}/tests"
             debug="${compile.debug}"
       deprecation="${compile.deprecation}"
          optimize="${compile.optimize}"
            source="${source.version}"
            target="${target.version}">
      <classpath refid="test.classpath"/>
      <exclude name='**/jdk14/**'/>
      <exclude name='**/log4j/**'/>
      <!-- NOTE -->
      <!--
      Pathable tests do not reference the Log4J Logger directly
      but try to load them by reflection from particular loaders.
      They will therefore fail unless this logger is available.
      -->
      <exclude name='**/pathable/**'/>
      <!-- END NOTE -->
      <exclude name='**/avalon/**'/>
      <exclude name='**/logkit/**'/>
    </javac>
    <antcall target='compile.log4j.tests'/>
    <antcall target='compile.jdk1.4.tests'/>
    <antcall target='compile.avalon.tests'/>
    <antcall target='compile.logkit.tests'/>
    <copy    todir="${build.home}/tests" filtering="on">
      <fileset dir="${test.resources}" excludes="**/*.java"/>
    </copy>
    <jar jarfile="${build.home}/commons-${component.name}-tests.jar"
         basedir="${build.home}/tests"
        manifest="${build.home}/conf/MANIFEST.MF">
      <exclude name="org/apache/commons/logging/Wrapper.class"/>
      <exclude name="org/apache/commons/logging/jdk14/TestHandler.class"
                 if="jdk.1.4.present"/>
    </jar>

  </target>


  <target name="clean" description="Clean build and distribution directories">
    <mkdir dir='${build.home}'/>
    <delete includeemptydirs='yes'>
      <fileset dir="${build.home}" excludes='docs/**/*'/>
    </delete>
    <delete    dir="${dist.home}"/>
    <delete    dir="${artifacts.home}"/>
  </target>


  <target name="all" depends="clean,compile,test,javadoc"
   description="Clean and compile all components"/>


  <target name="maven-docs-warning" unless="maven.generated.docs.present" depends="discovery">
    <echo>
    *** WARNING ***
    Maven generated documentation not found: Documentation distribution will be empty
    </echo>
  </target>
  

  <target name="dist" depends="all,maven-docs-warning"
     description="Create binary distribution">
  
    <!--
      - Maven is used to generate the documentation.
      - However, we cannot assume that it has been run.
      - So, create the appropriate directories.
      -->
    <mkdir dir='${build.home}'/>
    <mkdir dir='${build.home}/docs'/>
    <mkdir dir='${build.home}/docs/apidocs'/>
  
    <!--
      - Create a dist directory to hold all the files that go into a distribution.
      - Copy the needed files from the build directory to the dist directory.
      -->
    <mkdir dir="${dist.home}"/>
    <copy todir="${dist.home}">
      <fileset dir=".">
        <include name="LICENSE.txt"/>
        <include name="NOTICE.txt"/>
        <include name="RELEASE-NOTES.txt"/>
      </fileset>
      <fileset dir="${build.home}">
        <include name="${core.jar.name}"/>
        <include name="${api.jar.name}"/>
        <include name="${adapters.jar.name}"/>
      </fileset>
    </copy>
  
    <!-- Copy documentation generated by maven -->
    <mkdir dir="${dist.home}/docs"/>
    <copy todir="${dist.home}/docs">
      <fileset dir="${build.home}/docs"/>
    </copy>
  
    <!--
      - And copy the source too; we don't have separate source and binary distributions
      - for logging; the source is so small there's little point.
      -->
    <mkdir dir="${dist.home}/src"/>
    <copy todir="${dist.home}/src" filtering="on">
      <fileset dir="${source.home}"/>
    </copy>
    <zip destfile='${dist.home}/${src.ide.name}'>
      <zipfileset dir='${dist.home}/src'/>
      <zipfileset dir='${dist.home}/docs/apidocs'/>
      <zipfileset dir='${dist.home}' prefix='META-INF'>
          <include name="LICENSE.txt"/>
          <include name="NOTICE.txt"/>
      </zipfileset>
    </zip>
  
    <!-- Create release artifacts in the artifacts directory -->
    <mkdir dir="${artifacts.home}"/>
    <fixcrlf srcdir='${dist.home}' eol='dos' includes='**/*.txt,**/*.java,**/*.html'/>
    <zip destfile='${artifacts.home}/${windows.dist.name}'>
      <zipfileset dir='${dist.home}' prefix='commons-${component.name}-${component.version}'/>
    </zip>
    <fixcrlf srcdir='${dist.home}' eol='unix' includes='**/*.txt,**/*.java,**/*.html'/>
    <tar compression="gzip" destfile='${artifacts.home}/${nix.dist.name}' longfile='gnu'>
      <tarfileset dir='${dist.home}' prefix='commons-${component.name}-${component.version}'/>
    </tar>
    <copy todir="${artifacts.home}">
      <fileset dir="${build.home}">
        <include name="${core.jar.name}"/>
        <include name="${api.jar.name}"/>
        <include name="${adapters.jar.name}"/>
      </fileset>
    </copy>
  </target>


<!-- ========== Unit Test Targets ========================================= -->


  <!--
    - Target to run all unit tests.
    -
    - The batchtest task auto-detects what tests are available without
    - any need to define TestSuite objects in the code to compose
    - sets of tests to be run.
    -
    - Details of the unit test results for each TestCase will appear in
    - a file in directory ${build.home}/test-reports, together with any
    - output to stdout or stderr generated by the test code.
    -
    - If you're having problems running this target due to the use of
    - the "junit" task below, see the comments at the head of this file.
    - 
    - Individual tests (or subsets of tests) can be run by doing
    -   ant -Dtestmatch=**/FooTestCase testall
    -->

  <target name="test" depends="log4j12-test-warning, compile.tests"
   description="Run all unit tests">
    <echo message="Test output can be found in directory ${build.home}/test-reports."/>
    <delete dir="${build.home}/test-reports"/>
    <mkdir dir="${build.home}/test-reports"/>

    <echo message="executing tests [${testmatch}.java]"/>
    <!--
      - Note that the fork/forkmode settings define default behaviour for tests. 
      - The <test> and <batchtest> tags can override these settings if needed.
      - The default settings cause a single VM to be created in which all of
      - the tests are then run. 
      -->
    <junit printsummary="off" showoutput="no" fork="yes" forkmode="once" failureproperty="test.failure">
      <!-- plain output to file; brief output to console. -->
      <formatter type="plain"/>
      <formatter usefile="false" type="brief"/>

      <!-- 
        - Provide a set of properties pointing to the logging libs for
        - the use of the PathableClassLoader class used by some unit tests.
        -->
      <syspropertyset refid="test-lib-props"/>
      <classpath refid="test.classpath"/>

      <!--
        - Uncomment this to enable logging diagnostics for tests
        - <jvmarg value="-Dorg.apache.commons.logging.diagnostics.dest=STDERR"/>
        -->

      <!--
        - Auto-detect the tests to run. Checking the ${build.home}/tests
        - directory for .class files rather than the src/test directory
        - for .java files means that when we run the tests on platforms
        - where some components (eg jdk14 logging) is not available, 
        - just ensuring the tests are skipped from the compile will
        - also cause them to be skipped from the testing.
        -
        - This does introduce the danger that if tests accidentally
        - fail to compile then we won't notice it here. However that
        - should have been reported earlier anyway.
        -->
      <batchtest todir="${build.home}/test-reports">
        <fileset dir="${build.home}/tests">
          <include name="${testmatch}.class"/>
        </fileset>
      </batchtest>
    </junit>

    <fail if="test.failure">
      One or more unit tests failed.
    </fail>
  </target>

  <target name="javadoc" depends="compile"
         description="Create component Javadoc documentation">
    <mkdir      dir="${dist.home}"/>
    <mkdir      dir="${dist.home}/docs"/>
    <mkdir      dir="${dist.home}/docs/api"/>
    <javadoc sourcepath="${source.home}"
             destdir="${dist.home}/docs/api"
             overview="${source.home}/overview.html"
             packagenames="org.apache.commons.*"
             author="true"
             private="true"
             version="true"
             doctitle="&lt;h1&gt;${component.title} (Version
                      ${component.version})&lt;/h1&gt;"
             windowtitle="${component.title} (Version
                         ${component.version})"
             bottom='Copyright 2002-2013 The Apache Software
                    Foundation.&lt;!--

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
See the License for the specific language governing permissions and
limitations under the License.--&gt;'>
      <classpath refid="test.classpath"/>
    </javadoc>
  </target>

</project>