File: build.xml

package info (click to toggle)
apache-log4j1.2 1.2.17-7%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,880 kB
  • sloc: java: 35,228; xml: 4,813; cpp: 252; perl: 69; makefile: 30; sh: 14
file content (563 lines) | stat: -rw-r--r-- 22,926 bytes parent folder | download | duplicates (6)
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
<!--
 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.

-->

<!-- This file is an ANT build script. ANT is a Java based build tool. -->
<!-- It is availale from http://ant.apache.org/                -->


<!-- ================================================================= -->
<!-- NOTE: all directories are relative to jakarta-log4j/tests         -->
<!-- ================================================================= -->
<project name="log4j" default="usage" basedir="." >

  <property file="build.properties"/>

  <!--   if a Maven build has been attempted,
              the Maven repository can provide all the dependencies.  -->
  <property name="m2_repo" location="${user.home}/.m2/repository"/>
  <property name="oro.version" value="2.0.8"/>
  <property name="jakarta.oro.jar" location="${m2_repo}/oro/oro/${oro.version}/oro-${oro.version}.jar"/>
  <property name="checkstyle.version" value="4.1"/>
  <property name="checkstyle.jar" location="${m2_repo}/checkstyle/checkstyle/${checkstyle.version}/checkstyle-${checkstyle.version}.jar"/>
  <property name="javamail.jar" location="${m2_repo}/javax/mail/mail/1.4.3/mail-1.4.3.jar"/>
  <property name="junit.version" value="3.8.1"/>
  <property name="junit.jar" location="${m2_repo}/junit/junit/${junit.version}/junit-${junit.version}.jar"/>


  <!-- Read the system environment variables and stores them in properties, -->
  <!-- prefixed with "env". -->
  <property environment="env"/>

  <!-- The base directory relative to which most targets are built -->
  <property name="base" value="."/>
 
  <!-- The directory where source files are stored. -->
  <property name="project.source.home" value="../src/main/java/"/>
  <property name="project.classes.home" value="../dist/classes/"/>

  <property name="tests.source.home" value="./src/java/"/>
  <property name="excludes" value=""/>
  
  <property name="javac.source" value="1.1"/>
  <property name="javac.target" value="1.1"/>

  <path id="tests.classpath">
    <pathelement location="${log4j.jar}"/>
    <pathelement location="${project.source.home}"/>
    <pathelement location="${project.classes.home}"/>
    <pathelement location="${tests.source.home}"/>
    <pathelement location="./classes"/>
    <pathelement location="./resources"/>
    <pathelement location="${jakarta.oro.jar}"/>
    <pathelement location="${jaxp.jaxp.jar}"/>
    <pathelement location="${jaxp.parser.jar}"/>
    <pathelement location="${clover.jar}"/>
    <pathelement location="${junit.jar}"/>
    <pathelement location="${javamail.jar}"/>
    <pathelement path="${java.class.path}"/>
  </path>

  <!-- ================================================================= -->
  <!--                        TARGETS                                    -->
  <!-- ================================================================= -->



  <!-- ================================================================= -->
  <!-- Default target                                                    -->
  <!-- ================================================================= -->
  
  <target name="usage">
    <echo>

    These are the targets supported by this ANT build scpript:

    build  - compile all project files, if a certain library is missing, 
         then the compilation of its dependents are skipped.

    regression - Run regression tests which check large parts of log4j.

    runAll     - run all available tests

    Specify the log4j.jar property to test an arbitrary jar,
        otherwise the parent log4j will be built and tested.
    </echo>
  </target>

  <target name="prepare">
    <!--  if target directory available, use it
             otherwise assume it is a distribution and jar is in root  -->
    <available property="project.lib.home" value="../target" file="../target"/>
    <property name="project.lib.home" value=".."/>
    <mkdir dir="./classes" />
    <mkdir dir="./output" />
    <condition property="is-windows" value="true">
        <os family="windows"/>
    </condition>
  </target>

  <!-- Clean the parent project                                          -->
  <!-- ================================================================= -->
  <target name="parentClean" unless="log4j.jar">
    <ant dir=".." target="clean" inheritRefs="true"/>
  </target>
  
  
  
  <!-- ================================================================= -->
  <!-- Build the parent project                                          -->
  <!-- ================================================================= -->  
  <target name="parentBuild" unless="log4j.jar">    
    <ant dir=".." target="build.core" inheritRefs="true"/>
    <ant dir=".." target="build.xml" inheritRefs="true"/>
  </target>


  <!-- ================================================================= -->
  <!-- Compile test cases and related source files.                      -->
  <!-- ================================================================= -->
  <target name="build" depends="parentBuild, prepare">
    <property name="haltonfailure" value="yes"/>
    <javac srcdir="${tests.source.home}"
            destdir="./classes"
           deprecation="${deprecation}"
           target="${javac.target}"
           source="${javac.source}"
           debug="on"
           excludes="${excludes}">        
      <classpath refid="tests.classpath"/>
    </javac>
  </target>

  <!-- ================================================================= -->
  <!-- Remove all generated files such as compiled class files and test  -->
  <!-- case output.                                                     -->
  <!-- ================================================================= -->
  <target name="clean">
    <delete dir="./classes/" />
    <delete dir="./output/" />
  </target>

  <!-- ================================================================= -->
  <!-- Run all tests                                                     -->
  <!-- ================================================================= -->  
  <target name="runAll" depends="regression, longUnit"/>

  <!-- ================================================================= -->
  <!-- Tests multiple parts of log4j. These tests are much more fragile  -->
  <!-- unit tests. Regression tests compare output with a previously     -->
  <!-- created witness file.                                             -->
  <!-- ================================================================= -->  
  <target name="regression" depends="Core, Minimum, Logger, DOM, CustomLevel,
                                     CustomLogger,PatternLayout,
                                     HierarchyThreshold, DefaultInit, SocketServer,
                                     XMLLayout, AsyncAppender,
                                     OptionConverter, BoundedFIFO,
                                     CyclicBuffer, OR,
                                     LevelMatchFilter, PatternParser, 
                                     ErrorHandler,Rewrite"/>

  <!-- ================================================================= -->
  <!-- Longer unit tests                                                 -->
  <!-- ================================================================= -->
  <target name="longUnit" depends=""/>

  <!-- ================================================================= -->
  <!-- ============== Regression and Unit Tests follow ================= -->  
  <!-- ================================================================= -->
    <target name="Core" depends="build">
      <junit printsummary="yes" fork="yes" 
         haltonfailure="${haltonfailure}" dir="${basedir}">
        <classpath refid="tests.classpath"/>
        <formatter type="plain" usefile="false"/>
        <test name="org.apache.log4j.CoreTestSuite" />
      </junit>
    </target>


  <target name="Minimum" depends="build">
    <junit printsummary="yes" fork="yes" 
        haltonfailure="${haltonfailure}"  dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.MinimumTestCase" />
    </junit>
  </target>

  <target name="Logger" depends="build">
    <junit printsummary="yes" fork="yes" 
       haltonfailure="${haltonfailure}"  dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.LoggerTestCase" />
    </junit>
  </target>

  <target name="PatternLayout" depends="build">
    <junit printsummary="yes" fork="yes" 
        haltonfailure="${haltonfailure}"  dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.PatternLayoutTestCase" />
    </junit>
    <junit printsummary="yes" fork="yes" 
        haltonfailure="${haltonfailure}"  dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.EnhancedPatternLayoutTestCase" />
    </junit>
  </target>

  <target name="HierarchyThreshold" depends="build">
    <delete file="output/temp"/>
    <junit printsummary="yes" fork="yes" 
       haltonfailure="${haltonfailure}"  dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.HierarchyThresholdTestCase" />
    </junit>
  </target>

  <target name="DOM" depends="build">
    <junit printsummary="yes" fork="yes" 
        haltonfailure="${haltonfailure}"  dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.xml.DOMTestCase" />
    </junit>
  </target>

  <target name="CustomLevel" depends="build">
    <junit printsummary="yes" fork="yes" 
        haltonfailure="${haltonfailure}"  dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false" />
      <test name="org.apache.log4j.xml.CustomLevelTestCase" />
    </junit>
  </target>

  <target name="CustomLogger" depends="build">
    <junit printsummary="yes" fork="yes" 
        haltonfailure="${haltonfailure}"  dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false" />
      <test name="org.apache.log4j.customLogger.XLoggerTestCase" />
    </junit>
  </target>

  <target name="DefaultInit" depends="build">
    <!-- Delete possible cruft from previous runs. -->
    <delete file="${basedir}/classes/log4j.xml"/>
    <delete file="${basedir}/classes/log4j.properties"/>

    <junit printsummary="yes" fork="yes" 
       haltonfailure="${haltonfailure}"  dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test fork="true" name="org.apache.log4j.defaultInit.TestCase1" />
    </junit>

    <copy file="${basedir}/input/xml/defaultInit.xml" tofile="${basedir}/classes/log4j.xml"/>
    <junit printsummary="yes" fork="yes" 
        haltonfailure="${haltonfailure}"  dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test fork="true" name="org.apache.log4j.defaultInit.TestCase2" />      
    </junit>
    <delete file="${basedir}/classes/log4j.xml"/>

    <!-- test handling of log4j.defaultInitOverride system property -->
    <copy file="${basedir}/input/xml/defaultInit.xml" tofile="${basedir}/classes/log4j.xml"/>
    <junit printsummary="yes" fork="yes" 
       haltonfailure="${haltonfailure}"  dir="${basedir}">
      <jvmarg value="-Dlog4j.defaultInitOverride=true"/>
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test fork="true" name="org.apache.log4j.defaultInit.TestCase1" />
    </junit>
    <delete file="${basedir}/classes/log4j.xml"/>

    <!-- test default initialization from log4j.xml -->
    <copy file="${basedir}/input/defaultInit3.properties" tofile="${basedir}/classes/log4j.properties"/>
    <junit printsummary="yes" fork="yes" 
        haltonfailure="${haltonfailure}"  dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test fork="true" name="org.apache.log4j.defaultInit.TestCase3" />      
    </junit>
    <delete file="${basedir}/classes/log4j.properties"/>

    <!-- test default initialization from log4j.properties -->
    <copy file="${basedir}/input/xml/defaultInit.xml" tofile="${basedir}/classes/log4j.xml"/>
    <copy file="${basedir}/input/defaultInit3.properties" tofile="${basedir}/classes/log4j.properties"/>
    <junit printsummary="yes" fork="yes" 
         haltonfailure="${haltonfailure}"  dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test fork="true" name="org.apache.log4j.defaultInit.TestCase4" />      
    </junit>
    <delete file="${basedir}/classes/log4j.xml"/>
    <delete file="${basedir}/classes/log4j.properties"/>
  </target>

  <target name="SocketServer" depends="build">
    <parallel>
      <java classname="org.apache.log4j.net.ShortSocketServer" 
          fork="yes" dir="${basedir}">
   <arg value="8"/> 
   <arg value="input/socketServer"/> 
   <classpath refid="tests.classpath"/>
      </java>
      <sequential>
   <sleep seconds="2"/>
   <junit printsummary="yes" fork="yes" 
       haltonfailure="${haltonfailure}" dir="${basedir}">
     <sysproperty key="testNumber" value="1"/>
     <classpath refid="tests.classpath"/>
     <formatter type="plain" usefile="false" />
     <test name="org.apache.log4j.net.SocketServerTestCase" />
   </junit>
      </sequential>
    </parallel>
  </target>

  <target name="XMLLayout" depends="build">
    <junit printsummary="yes" fork="yes" 
        haltonfailure="${haltonfailure}" dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false" />
      <test name="org.apache.log4j.xml.XMLLayoutTestCase" />
    </junit>
  </target>

  <target name="AsyncAppender" depends="build">
    <junit printsummary="yes" fork="yes" 
      haltonfailure="${haltonfailure}" dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false" />
      <test name="org.apache.log4j.AsyncAppenderTestCase" />
    </junit>
  </target>

  <target name="LevelMatchFilter" depends="build">
    <junit printsummary="yes" fork="yes" 
       haltonfailure="${haltonfailure}" dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.varia.LevelMatchFilterTestCase" />
    </junit>
  </target>

  <target name="ErrorHandler" depends="build">
    <junit printsummary="yes" fork="yes" 
         haltonfailure="${haltonfailure}" dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false" />
      <test name="org.apache.log4j.varia.ErrorHandlerTestCase" />
    </junit>
  </target>

  <target name="OptionConverter" depends="build">
    <junit printsummary="yes" fork="yes" 
        haltonfailure="${haltonfailure}" dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.helpers.OptionConverterTestCase" />
    </junit>
  </target>

  <target name="BoundedFIFO" depends="build">
    <junit printsummary="yes" fork="yes" 
        haltonfailure="${haltonfailure}" dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.helpers.BoundedFIFOTestCase" />
    </junit>
  </target>

  <target name="CyclicBuffer" depends="build">
    <junit printsummary="yes" fork="yes" 
         haltonfailure="${haltonfailure}" dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.helpers.CyclicBufferTestCase" />
    </junit>
  </target>

  <target name="PatternParser" depends="build">
    <junit printsummary="yes" fork="yes" 
       haltonfailure="${haltonfailure}" dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.helpers.PatternParserTestCase" />
    </junit>
  </target>


  <target name="OR" depends="build">
    <junit printsummary="yes" fork="yes" 
       haltonfailure="${haltonfailure}" dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.or.ORTestCase" />
    </junit>
  </target>

  <target name="DRFA" depends="build">
    <junit printsummary="yes" fork="yes" 
       haltonfailure="${haltonfailure}" dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.DRFATestCase" />
    </junit>
  </target>

  <target name="RFA" depends="build">
    <junit printsummary="yes" fork="yes" 
       haltonfailure="${haltonfailure}" dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.RFATestCase" />
    </junit>
  </target>

  <target name="ERFA" depends="build">
    <junit printsummary="yes" fork="yes" 
        haltonfailure="${haltonfailure}" dir="${basedir}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.varia.ERFATestCase" />
    </junit>
  </target>

  <target name="Syslog" depends="build">
      <junit printsummary="yes" fork="yes" 
          haltonfailure="${haltonfailure}" dir="${basedir}">
        <classpath refid="tests.classpath"/>
        <formatter type="plain" usefile="false"/>
        <test name="org.apache.log4j.net.SyslogAppenderTest" />
      </junit>
  </target>

  <target name="NTEventLogAppender" depends="build" if="is-windows">
    <junit printsummary="yes" 
        fork="yes" 
        haltonfailure="${haltonfailure}"
        dir="${project.lib.home}">
      <classpath refid="tests.classpath"/>
      <formatter type="plain" usefile="false"/>
      <test name="org.apache.log4j.nt.NTEventLogAppenderTest" />
    </junit>
  </target>

  <target name="Socket" depends="build">
      <junit printsummary="yes" fork="yes" 
        haltonfailure="${haltonfailure}" dir="${basedir}">
        <classpath refid="tests.classpath"/>
        <formatter type="plain" usefile="false"/>
        <test name="org.apache.log4j.net.SocketAppenderTest" />
      </junit>
  </target>

  <target name="Rewrite" depends="build">
      <junit printsummary="yes" fork="yes" 
        haltonfailure="${haltonfailure}" dir="${basedir}">
        <classpath refid="tests.classpath"/>
        <formatter type="plain" usefile="false"/>
        <test name="org.apache.log4j.rewrite.RewriteAppenderTest" />
      </junit>
  </target>

  <!-- ================================================================= -->
  <!-- ========================= Very long Tests ======================= -->
  <!-- ================================================================= -->
  
  <!-- none yet, but StressCategory is a good candidate... -->
  
   <!-- ============================================================= --> 
   <!--                      Coverage analysis                        -->
   <!-- ============================================================= --> 
   <target name="with.clover">
        <!-- some tests fail when running clover
                setting this property will cause testing to continue  -->
        <property name="haltonfailure" value="no"/>
        <available resource="clovertasks" property="clover-present"/>

        <fail unless="clover-present">
          clover.jar must be in the classpath and should also be
          placed in the lib directory.  A version of clover 
          (http://www.cenqua.com/clover) for use with ASF projects 
          is available from the committers/donated-licenses/clover module 
          in the SVN repository. 
       </fail>
         
       <taskdef resource="clovertasks"/>
       <clover-setup initString="log4j.db"/>
    </target>

    <target name="coverageReport" depends="parentClean, clean, with.clover, runAll">
      <mkdir dir="coverage"/>
      <taskdef resource="clovertasks"/>
      <clover-report>
        <current title="log4j coverage" outfile="coverage">
          <format type="html"/>
        </current>
      </clover-report>
    </target>


  <!-- ================================================================= -->
  <!-- This target reformats the source with Jalopy.                      -->
  <!-- ================================================================= -->

  <target name="jalopy" depends="prepare" description="Reformat source code using Jalopy">
        <fail unless="jalopy.files">
Specify files to reformat with -Djalopy.files=PATTERN.
</fail>
		<taskdef name="jalopy"
         	classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
  		    <classpath>
    	        <fileset dir="${jalopy-ant.dir}/lib">
                    <include name="*.jar" />
                </fileset>
            </classpath>
        </taskdef>
        <jalopy backup="no" 
             convention="log4j-coding-convention.xml"
             classpathref="tests.classpath">
            <fileset dir="${tests.source.home}" includes="${jalopy.files}"/>
        </jalopy>
          
  </target>

  <!-- ================================================================= -->
  <!-- This target checks code conventions with checkstyle.              -->
  <!-- ================================================================= -->

  <target name="checkstyle" depends="prepare" description="Check source code using checkstyle">
        <property name="checkstyle.files" value="**/*.java"/>
        <taskdef resource="checkstyletask.properties"
         classpath="${checkstyle.jar}"/>
        <checkstyle config="sun_checks.xml">
            <fileset dir="${tests.source.home}" includes="${checkstyle.files}"/>
        </checkstyle>          
  </target>

  
</project>