summaryrefslogtreecommitdiff
path: root/qpid/java/module.xml
blob: 8c6a05e0358099913872ca726e44329f668a11f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
<!--
 -
 - 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.
 -
 -->
<project name="module" xmlns:artifact="antlib:org.apache.maven.artifact.ant">

  <import file="common.xml"/>

  <path id="maven-ant-tasks.classpath" path="${project.root}/lib/maven-ant-tasks-2.1.1.jar" />
  <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
           uri="antlib:org.apache.maven.artifact.ant"
           classpathref="maven-ant-tasks.classpath" />

  <map property="module" value="${basedir}" split="${path.separator}">
    <globmapper from="${project.root}${file.separator}*" to="*"/>
  </map>

  <map property="module.name" value="${module}">
    <filtermapper>
        <replacestring from="${file.separator}" to="-"/>
    </filtermapper>
  </map>
	
  <echo message="Running ant for module : ${module}" level="info"/>

  <property file="${project.root}/build.deps"/>

  <property name="module.build"        location="${build.scratch}/${module}"/>
  <property name="module.classes"      location="${module.build}/classes"/>
  <property name="module.instrumented" location="${module.build}/classes-instrumented"/>
  <property name="module.precompiled"  location="${module.build}/src"/>
  <property name="module.api"          location="${build.api}/${module}/"/>
  <property name="module.test.api"     location="${build.test.api}/${module}"/>
  <property name="module.test.classes" location="${module.build}/test/classes"/>
  <property name="module.results"      location="${build.results}/${module}"/>
  <property name="module.failed"       location="${module.results}/FAILED"/>
  <property name="module.src"          location="src/main/java"/>
  <property name="module.test.src"     location="src/test/java"/>
  <property name="module.bin"          location="bin"/>
  <property name="module.etc"          location="etc"/>
    
  <property name="module.namever"      value="${project.name}-${module.name}-${project.version}"/>
  <property name="module.namever.osgi" value="${project.name}-${module.name}_${project.version}.0.osgi"/>
  <property name="module.release.base" value="${basedir}/release"/>
  <property name="module.release"      value="${module.release.base}/${module.namever}"/>
  <property name="module.release.lib"  value="${module.release}/lib"/>
  <property name="module.release.zip"  location="${module.release.base}/${module.namever}.zip"/>
  <property name="module.release.tar"  location="${module.release.base}/${module.namever}.tar"/>
  <property name="module.release.tgz"  location="${module.release.base}/${module.namever}.tar.gz"/>
  <property name="module.release.bz2"  location="${module.release}/${module.namever}.tar.bz2"/>

  <property name="module.genpom.args"  value=""/>
  <property name="maven.remote.repo"     value="file://${module.release.base}/maven"/>

  <property name="broker.log.prefix" value="BROKER: "/> 
  <property name="broker.log.interleave" value="true"/>

  <property name="module.qpid.jar"     location="${module.release.lib}/qpid-all.jar"/>
  <basename property="qpid.jar.name"  file="${module.qpid.jar}"/>

  <property name="module.coverage"     location="${module.build}/coverage"/>
  <property name="cobertura.datafile"  location="${module.instrumented}/cobetura.ser"/>


  <available property="module.test.src.exists" file="${module.test.src}"/>
  <available property="module.etc.exists" file="${module.etc}"/>
  <available property="module.bin.exists" file="${module.bin}"/>

  <property name="module.source.jar"
            location="${build.lib}/${project.name}-${module.name}-${project.version}-sources.jar"/>

  <!-- module.depends and module.test.depends are supplied by the importing file -->
  <property name="module.depends"       value=""/>
  <property name="module.test.depends"  value=""/>
  <property name="module.test.excludes" value=""/>

  <map property="module.depends.path" value="${module.depends}" join="${path.separator}">
    <globmapper from="*" to="${build.scratch}/*/classes"/>
  </map>

  <map property="module.test.depends.path" value="${module.test.depends}" join="${path.separator}">
    <globmapper from="*" to="${build.scratch}/*/classes"/>
  </map>


   <!-- Add depenencies dependencies to path -->
   <map property="module.depends.libs" value="${module.depends}" join=" ">
       <chainedmapper>
           <filtermapper>
               <replacestring from="${file.separator}" to="-"/>
           </filtermapper>
           <propertymapper from="*" to="*.libs"/>
       </chainedmapper>
   </map>
    <condition property="module.depends.libs.includes" value="__EMPTY__" else="${module.depends.libs}">
      <equals trim="true" arg1="${module.depends.libs}" arg2=""/>
    </condition>


    <!-- Add depenencies test dependencies to path -->
    <map property="module.test.depends.libs" value="${module.test.depends}" join=" ">
        <chainedmapper>
            <filtermapper>
                <replacestring from="${file.separator}" to="-"/>
            </filtermapper>
            <propertymapper from="*" to="*.libs"/>
        </chainedmapper>
    </map>
    <condition property="module.test.depends.libs.includes" value="__EMPTY__" else="${module.test.depends.libs}">
      <equals trim="true" arg1="${module.test.depends.libs}" arg2=""/>
    </condition>


  <indirect name="module.libs"         variable="${module.name}.libs"/>
  <condition property="module.libs.includes" value="__EMPTY__" else="${module.libs}">
    <equals trim="true" arg1="${module.libs}" arg2=""/>
  </condition>
    
  <indirect name="module.test.libs"    variable="${module.name}.test.libs"/>
  <condition property="module.test.libs.includes" value="__EMPTY__" else="${module.test.libs}">
    <equals trim="true" arg1="${module.test.libs}" arg2=""/>
  </condition>

  <path id="module.libs">
    <fileset dir="${project.root}" includes="${module.libs.includes}"/>
    <fileset dir="${project.root}" includes="${module.depends.libs.includes}"/>
  </path>

  <path id="module.test.libs">
    <fileset dir="${project.root}" includes="${module.test.libs.includes}"/>
    <fileset dir="${project.root}" includes="${module.test.depends.libs.includes}"/>
  </path>

  <path id="module.src.path">
    <pathelement location="${module.src}"/>
    <pathelement location="${module.precompiled}"/>
  </path>
	
  <path id="module.test.src.path">
    <pathelement location="${module.test.src}"/>
  </path>

  <condition property="module.jar"
             value="${build.plugins}/${project.name}-${module.name}-${project.version}.jar"
             else="${build.lib}/${project.name}-${module.name}-${project.version}.jar">
    <and>
      <isset property="module.plugin"/>
      <istrue value="${module.plugin}"/>
    </and>
  </condition>

  <property name="module.test.jar"
            location="${build.lib}/${project.name}-${module.name}-tests-${project.version}.jar"/>

  <path id="module.class.path">
    <pathelement location="${module.classes}"/>
    <pathelement path="${module.depends.path}"/>
    <path refid="module.libs"/>
  </path>

  <path id="module.test.path">
    <pathelement path="${module.test.classes}"/>
    <path refid="module.class.path"/>
    <pathelement path="${module.test.depends.path}"/>
    <path refid="module.test.libs"/>
  </path>

  <property name="javac.deprecation" value="off"/>

  <target name="debug">
    <echo-prop name="basedir"/>
    <echo-prop name="project.root"/>
    <echo-prop name="module"/>
    <echo-prop name="module.libs"/>
    <echo-prop name="module.test.libs"/>
    <echo-prop name="module.name"/>
    <echo-prop name="module.jar"/>
    <echo-prop name="module.depends"/>
    <echo-prop name="module.depends.path"/>
    <echo-prop name="module.test.depends"/>
    <echo-prop name="module.test.depends.path"/>
    <echo-prop name="module.depends.libs"/>
    <echo-prop name="module.test.depends.libs"/>      
    <echo-path refid="module.src.path"/>
    <echo-path refid="module.class.path"/>
    <echo-path refid="module.test.path"/>
  </target>

  <target name="prepare">
    <mkdir dir="${build.bin}"/>
    <mkdir dir="${build.etc}"/>
    <mkdir dir="${build.lib}"/>
    <mkdir dir="${build.results}"/>
    <mkdir dir="${build.data}"/>
    <mkdir dir="${build.plugins}"/>
    <mkdir dir="${module.classes}"/>
    <mkdir dir="${module.precompiled}"/>
    <mkdir dir="${module.api}"/>
    <mkdir dir="${module.test.api}"/>
    <mkdir dir="${module.test.classes}"/>
    <mkdir dir="${module.results}"/>
  </target>

  <target name="pom" depends="prepare" if="module.genpom">
    <jython path="${mllib.dir}">
      <args>
        <arg line='"${project.root}/genpom"'/>
        <arg line='-s "${project.root}/lib/poms"'/>
        <arg line='-o "${build.scratch}/qpid-${module.name}.pom"'/>
        <arg line="-u ${project.url}"/>
        <arg line="-g ${project.groupid}"/>
        <arg line="-v ${project.version}${maven.version.suffix}"/>
        <arg line="-p qpid"/>
        <arg line='-m "${module.depends}"'/>
        <arg line="-a ${module.name}"/>
        <arg line="${module.genpom.args}"/>
        <arg line="${module.libs}"/>
      </args>
    </jython>
  </target>

  <target name="release-mvn" depends="pom" if="module.genpom" description="Install the artifacts into the local repository and prepare the release">
    <antcall target="build"/>

    <artifact:pom id="module.pom" file="${build.scratch}/qpid-${module.name}.pom"/>

    <artifact:install file="${module.jar}" pomRefId="module.pom" settingsFile="${maven.settings.xml}">
        <localRepository path="${maven.local.repo}"/>
    </artifact:install>

    <artifact:deploy file="${module.jar}" pomRefId="module.pom" uniqueVersion="${maven.unique.version}" settingsFile="${maven.settings.xml}">
      <attach file="${module.source.jar}" classifier="sources"/>
      <localRepository path="${maven.local.repo}"/>
      <remoteRepository url="${maven.remote.repo}"/>
    </artifact:deploy>
  </target>

  <target name="precompile"/>

  <target name="compile" depends="prepare,precompile" description="compile sources">

    <echo message="Targeting : ${java.target}" level="info"/>

    <javac source="${java.source}" target="${java.target}" 
           destdir="${module.classes}" debug="on" debuglevel="lines,vars,source" includeantruntime="false"
           deprecation="${javac.deprecation}">
      <compilerarg line="${javac.compiler.args}"/>
      <src refid="module.src.path"/>
      <classpath refid="module.class.path"/>
    </javac>

    <!-- copy any non java src files into the build tree, e.g. log4j.properties -->
    <copy todir="${module.classes}" verbose="true">
      <fileset dir="${module.src}">
        <exclude name="**/*.java"/>
        <exclude name="**/package.html"/>
      </fileset>
    </copy>
  </target>

  <target name="precompile-tests" if="module.test.src.exists"/>

  <target name="compile-tests" depends="compile,precompile-tests" if="module.test.src.exists"
          description="compilte unit tests">
    <javac target="${java.target}" source="${java.source}"
           destdir="${module.test.classes}" debug="on"
           deprecation="${javac.deprecation}"
           srcdir="${module.test.src}">
      <classpath refid="module.test.path"/>
    </javac>

    <!-- copy any non java src files into the build tree, e.g. log4j.properties -->
    <copy todir="${module.test.classes}" verbose="true">
      <fileset dir="${module.test.src}">
        <exclude name="**/*.java"/>
        <exclude name="**/package.html"/>
      </fileset>
    </copy>
  </target>


  <property name="profile" value="default"/>
  <property name="testprofile.file" value="${test.profiles}/${profile}.testprofile"/>
  
  <available file="${testprofile.file}" property="testprofile.file.present"/>
  <fail unless="testprofile.file.present" message="The requested test profile was not found: ${testprofile.file}"/>

  <property file="${testprofile.file}" prefix="preload"/>
  <property name="preload.include" value=""/>
  <condition property="profiles"
             value="${preload.include} ${profile}"
             else="default ${preload.include} ${profile}">
    <equals arg1="${profile}" arg2="default"/>
  </condition>
  <map property="_profile_files" value="${profiles}" join=" ">
    <globmapper from="*" to="*.testprofile"/>
  </map>
  <concat destfile="${build.scratch}/test-${profile}.properties" force="no" fixlastline="yes">
    <filelist dir="${test.profiles}" files="${_profile_files}"/>
  </concat>
  <property file="${build.scratch}/test-${profile}.properties"/>

  <map property="test.excludefiles" value="${test.excludes}">
    <globmapper from="*" to="${test.profiles}/*"/>
  </map>


  <condition property="dontruntest" value="dontruntest" else="runtest">
         <contains substring="${module.name}" string="${exclude.modules}" />
  </condition>

  <property name="jvm.args" value=""/>
  <property name="broker.existing.qpid.work" value=""/>

  <target name="test" depends="build,compile-tests" if="module.test.src.exists"
         unless="${dontruntest}" description="execute unit tests">

    <delete file="${module.failed}"/>

    <echo message="Using profile:${profile}" level="info"/>
    <junit fork="yes" forkmode="once" maxmemory="${test.mem}" reloading="no"
           haltonfailure="${haltonfailure}" haltonerror="${haltonerror}"
           failureproperty="test.failures" printsummary="on" timeout="6000000" >

      <jvmarg line="${jvm.args}" />

      <sysproperty key="amqj.logging.level" value="${amqj.logging.level}"/>
      <sysproperty key="amqj.server.logging.level" value="${amqj.server.logging.level}"/>
      <sysproperty key="amqj.protocol.logging.level" value="${amqj.protocol.logging.level}"/>
      <sysproperty key="log4j.debug" value="${log4j.debug}"/>
      <sysproperty key="root.logging.level" value="${root.logging.level}"/>
      <sysproperty key="log4j.configuration" value="${log4j.configuration}"/>
      <sysproperty key="java.naming.factory.initial" value="${java.naming.factory.initial}"/>
      <sysproperty key="java.naming.provider.url" value="${java.naming.provider.url}"/>
      <sysproperty key="broker" value="${broker}"/>
      <sysproperty key="broker.clean" value="${broker.clean}"/>
      <sysproperty key="broker.clean.between.tests" value="${broker.clean.between.tests}"/>
      <sysproperty key="broker.existing.qpid.work" value="${broker.existing.qpid.work}"/>
      <sysproperty key="broker.persistent" value="${broker.persistent}"/>
      <sysproperty key="broker.version" value="${broker.version}"/>
      <sysproperty key="broker.ready" value="${broker.ready}" />
      <sysproperty key="broker.stopped" value="${broker.stopped}" />
      <sysproperty key="broker.config" value="${broker.config}" />
      <sysproperty key="messagestore.class.name" value="${messagestore.class.name}" />
      <sysproperty key="test.output" value="${module.results}"/>
      <sysproperty key="qpid.amqp.version" value="${qpid.amqp.version}"/>

      <syspropertyset>
        <propertyref prefix="test"/>
      </syspropertyset>
      <syspropertyset>
        <propertyref prefix="profile"/>
      </syspropertyset>
      <syspropertyset>
        <propertyref prefix="javax.net.ssl"/>
      </syspropertyset>  
      <syspropertyset>
         <propertyref prefix="broker"/>
      </syspropertyset>
      
      <sysproperty key="max_prefetch" value ="${max_prefetch}"/>
      <sysproperty key="qpid.dest_syntax" value ="${qpid.dest_syntax}"/>

      <sysproperty key="example.plugin.target" value="${project.root}/build/lib/plugins"/>
      <sysproperty key="QPID_EXAMPLE_HOME" value="${qpid.home}"/>
      <sysproperty key="QPID_HOME" value="${qpid.home}"/>
      <sysproperty key="QPID_WORK" value="${qpid.work}"/>

      <formatter type="plain"/>
      <formatter type="xml"/>

      <classpath refid="module.test.path"/>

      <batchtest todir="${module.results}">
        <fileset dir="${module.test.src}" excludes="${module.test.excludes}">
          <include name="**/${test}.java"/>
        </fileset>
      </batchtest>
    </junit>

    <antcall target="touch-failed"/>

    <condition property="failed">
      <and>
        <isfalse value="${test.failures.ignore}"/>
        <available file="${module.failed}"/>
      </and>
    </condition>

    <fail if="failed" message="TEST SUITE FAILED"/>

  </target>

  <target name="report-module" description="generate junit reports for each module">
    <junitreport todir="${module.results}">
        <fileset dir="${module.results}">
            <include name="TEST-*.xml"/>
        </fileset>
        <report format="frames" todir="${module.results}/report/html"/>
    </junitreport> 
  </target>

  <target name="touch-failed" if="test.failures">
    <touch file="${module.failed}"/>
    <touch file="${build.failed}"/>
  </target>

  <target name="copy-bin" if="module.bin.exists" description="copy bin directory if it exists to build tree">
    <copy todir="${build.bin}" failonerror="false">
      <fileset dir="${module.bin}"/>
    </copy>
    <chmod dir="${build.bin}" perm="ugo+rx" includes="**/*"/>
  </target>

  <target name="copy-bin-release" if="module.bin.exists" description="copy dependencies into module release">
    <copy todir="${module.release}/bin" failonerror="true">
      <fileset dir="${module.bin}" />
    </copy>
    <chmod dir="${module.release}/bin" perm="ugo+rx" includes="**/*"/>
  </target>

  <target name="copy-etc" if="module.etc.exists" description="copy etc directory if it exists to build tree">
    <copy todir="${build.etc}" failonerror="false">
      <fileset dir="${module.etc}"/>
    </copy>
  </target>

  <target name="copy-etc-release" if="module.etc.exists" description="copy etc directory if it exists to build tree">
    <copy todir="${module.release}/etc" failonerror="false" flatten="true">
        <fileset dir="${module.etc}"/>
    </copy>
  </target>

  <target name="postbuild" description="run after a build"/>

  <target name="build" depends="jar,jar-tests,jar-sources,libs,copy-bin,copy-etc,postbuild" description="compile and copy resources into build tree"/>
  <target name="jar.manifest" depends="compile" if="module.manifest">
    <jar destfile="${module.jar}" basedir="${module.classes}" manifest="${module.manifest}"/>
  </target>

  <target name="jar.nomanifest" depends="compile" unless="module.manifest">
    <jar destfile="${module.jar}" basedir="${module.classes}">
       <metainf dir="${project.root}/resources/" />
    </jar>
  </target>

  <target name="jar" depends="jar.manifest,jar.nomanifest" description="create jar"/>

  <target name="jar-tests" depends="compile-tests" description="create unit test jar">
    <jar destfile="${module.test.jar}" basedir="${module.test.classes}"/>
  </target>

  <target name="jar-sources" depends="prepare" description="create sources jar">
    <jar destfile="${module.source.jar}">
      <fileset dir="${project.root}/resources">
        <include name="LICENSE"/>
        <include name="NOTICE"/>
      </fileset>
      <fileset dir="${module.src}" includes="**/*.java"/>
      <fileset dir="${module.precompiled}" includes="**/*.java"/>
    </jar>
  </target>

  <target name="libs" description="copy dependencies into build tree">
    <copylist todir="${build.lib}" dir="${project.root}" files="${module.libs}"/>
  </target>

  <map property="module.depends.jars" value="${module.depends}" join=",">
    <globmapper from="*" to="${project.name}-*-${project.version}.jar"/>
    <filtermapper>
        <replacestring from="/" to="-"/>
    </filtermapper>
  </map>

 
  <target name="libs-release" description="copy dependencies into module release">
    <!-- Copy the module dependencies -->
      <echo message="${module.libs}"/>
    <copylist todir="${module.release}/lib" dir="${project.root}" files="${module.libs}"/>
    <copylist todir="${module.release}/lib" dir="${project.root}" files="${module.depends.libs}"/>

    <!-- Copy the jar for this module -->
    <copy todir="${module.release}/lib" failonerror="true">
        <fileset file="${module.jar}"/>
        <fileset dir="${build.lib}" includes="${module.depends.jars}"/>
    </copy>
  </target>

  <target name="resources" description="copy resources into build tree">
    <copy todir="${build}" failonerror="false" flatten="true">
      <fileset dir="${basedir}${file.separator}.." includes="${resources}"/>
    </copy>
  </target>

  <target name="resources-release" description="copy resources into module release">
    <copy todir="${module.release}" failonerror="false" flatten="true">
      <fileset dir="${resources}" excludes="META-INF"/>
    </copy>
  </target>

  <uptodate property="doc.done" targetfile="${module.api}/index.html">
    <srcfiles dir="${module.src}" includes="**/*.java"/>
  </uptodate>

  <property name="module.doc.access" value="package"/>
  <target name="doc" depends="prepare" unless="doc.done" description="generate api-doc">
    <javadoc access="${module.doc.access}" destdir="${module.api}" author="false" version="true" use="true"
        windowtitle="${project.name} - ${module.name} - API Documentation"
   		sourcepathref="module.src.path" classpathref="module.class.path" packagenames="*">
      <arg value="-J-Dhttp.proxyHost=${http.proxyHost}"/>
      <arg value="-J-Dhttp.proxyPort=${http.proxyPort}"/>
      <bottom><![CDATA[<em><a href="http://www.apache.org/licenses/LICENSE-2.0">Licensed to the Apache Software Foundation</a></em>]]></bottom>
      <link href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
      <link href="http://download.oracle.com/docs/cd/E17477_01/javaee/5/api/"/>
      <link href="http://commons.apache.org/configuration/apidocs/"/>
      <tag name="todo" scope="all" description="Todo:" />
    </javadoc>
  </target>

  <uptodate property="test-doc.done" targetfile="${module.test.api}/index.html">
    <srcfiles dir="${module.test.src}" includes="**/*.java"/>
  </uptodate>

  <property name="module.test.doc.access" value="public"/>
  <target name="test-doc" depends="prepare" unless="testdoc.done" if="module.test.src.exists" description="generate test api-doc">
    <javadoc access="${module.test.doc.access}" destdir="${module.test.api}" author="false" version="true" use="true"
        windowtitle="${project.name} - ${module.name} - Test API Documentation"
   		sourcepathref="module.test.src.path" classpathref="module.test.path" packagenames="*">
      <arg value="-J-Dhttp.proxyHost=${http.proxyHost}"/>
      <arg value="-J-Dhttp.proxyPort=${http.proxyPort}"/>
      <bottom><![CDATA[<em><a href="http://www.apache.org/licenses/LICENSE-2.0">Licensed to the Apache Software Foundation</a></em>]]></bottom>
      <link href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
      <link href="http://download.oracle.com/docs/cd/E17477_01/javaee/5/api/"/>
      <link href="http://commons.apache.org/configuration/apidocs/"/>
      <tag name="todo" scope="all" description="Todo:" />
    </javadoc>
  </target>
  
  <target name="release-bin-prepare">
    <mkdir dir="${module.release}"/>
    <available property="module.release.exists" file="${module.release}"/>
  </target>

  <target name="check-module-manifest">
    <uptodate property="module-manifest.done" targetfile="${qpid.jar}">
      <srcfiles dir="${build.lib}" includes="**/*.jar" excludes="**/${qpid.jar.name}"/>
    </uptodate>
  </target>

  <target name="module-manifest" depends="check-module-manifest" unless="module-manifest.done">
    <path id="class.path">
      <fileset dir="${module.release.lib}" >
        <include name="*.jar"/>
        <exclude name="${qpid.jar.name}"/>
      </fileset>
    </path>
    <pathconvert property="qpid.jar.classpath" pathsep=" " dirsep="/">
      <path refid="class.path"/>
      <globmapper from="${module.release.lib}${file.separator}*" to="*"/>
    </pathconvert>

    <jar destfile="${module.qpid.jar}">
      <manifest>
        <attribute name="Class-Path" value="${qpid.jar.classpath}"/>
      </manifest>
      <metainf dir="${project.root}/resources/"/>
    </jar>

    <touch file="${module.qpid.jar}"/>
  </target>


  <target name="zip-release"  depends="build-release-bin" description="build module release archive">
    <zip destfile="${module.release.zip}">
      <zipfileset dir="${module.release}" prefix="${module.namever}" filemode="755">
        <include name="bin/*"/>
	<exclude name="bin/*.txt"/>
      </zipfileset>

      <zipfileset dir="${module.release}" prefix="${module.namever}" filemode="644">
        <include name="bin/*.txt"/>
      </zipfileset>

      <zipfileset dir="${module.release}" prefix="${module.namever}" excludes="${module.release.excludes}" filemode="644" dirmode="755">
        <exclude name="bin/**"/>
	    <exclude name="**/*.class"/>          
      </zipfileset>
    </zip>
  </target>

  <target name="bundle" description="Build module osgi artifact. Override and depend on bundle-tasks to use"/>

  <target name="bundle-tasks" depends="jar">
   <taskdef resource="aQute/bnd/ant/taskdef.properties" classpath="${project.root}/lib/bnd-0.0.384.jar"/>
   <echo message="Bundling ${build}/lib/${module.namever}.jar with ${module.src}/${module.name}.bnd"/>
   <bnd 
      classpath="${build}/lib/${module.namever}.jar"
      eclipse="false" 
      failok="false" 
      exceptions="true"
      output="${build}/lib/${module.namever.osgi}.jar"
      files="${module.src}/${module.name}.bnd"/>
  </target>    

    <target name="tar-release" depends="zip-release" description="build release archive">
      <tar destfile="${module.release.tar}" longfile="gnu" >
        <zipfileset src="${module.release.zip}"/>
      </tar>
    </target>

    <target name="gzip-release" depends="tar-release" description="build release archive">
      <gzip src="${module.release.tar}" destfile="${module.release.tgz}"/>
    </target>

    <target name="bzip2-release" depends="tar-release" description="build release archive">
      <bzip2 src="${module.release.tar}" destfile="${module.release.bz2}"/>
    </target>

    <target name="doc-release" description="no-op override if a doc step is requried "/>


    <target name="build-release-bin" depends="release-bin-prepare,libs-release,copy-bin-release,
                                              copy-etc-release,doc-release,resources-release,release-bin-other,module-manifest"
            description="Task that includes all tasks required to create a module binary release"/>

    <!-- ,zip-release,gzip-release -->
  <target name="release-bin-tasks" depends="gzip-release" description="build all release archives except .bz2"/>

  <target name="release-bin-all-tasks" depends="bzip2-release" description="build all release archives"/>

  <!-- Dummy targets to no-op for most modules. Override if a module package is required -->
  <target name="release-bin-other" description="Override if there is tasks required for the module bin release to occur last"/>
  <target name="release-bin" description="Override and depend on release-bin-tasks to generate"/>
  <target name="release-bin-all" description="Override and depend on release-bin-tasks to generate"/>

  <target name="clean" description="remove build artifacts">
    <delete dir="${module.build}"/>
    <delete dir="${module.results}"/>
    <delete dir="${module.release.base}"/>
    <delete dir="${module.instrumented}"/>
  </target>

  <target name="instrument" depends="cobertura-init">
    <cobertura-instrument todir="${module.instrumented}"
                          datafile="${cobertura.datafile}">
      <fileset dir="${module.classes}">
        <include name="**/*.class"/>
      </fileset>
    </cobertura-instrument>
  </target>

  <target name="cover-test" depends="instrument">

    <mkdir dir="${build.coveragereport}" />
    <junit fork="yes" forkmode="once" maxmemory="${test.mem}" reloading="no"
           haltonfailure="${haltonfailure}" haltonerror="${haltonerror}"
           failureproperty="test.failures" printsummary="on" timeout="600000" >

      <sysproperty key="amqj.logging.level" value="${amqj.logging.level}"/>
      <sysproperty key="amqj.protocol.logging.level" value="${amqj.protocol.logging.level}"/>
      <sysproperty key="log4j.debug" value="${log4j.debug}"/>
      <sysproperty key="root.logging.level" value="${root.logging.level}"/>
      <sysproperty key="log4j.configuration" value="${log4j.configuration}"/>
      <sysproperty key="java.naming.factory.initial" value="${java.naming.factory.initial}"/>
      <sysproperty key="java.naming.provider.url" value="${java.naming.provider.url}"/>
      <sysproperty key="broker" value="${broker}"/>
      <sysproperty key="broker.clean" value="${broker.clean}"/>
      <sysproperty key="broker.version" value="${broker.version}"/>
      <sysproperty key="broker.ready" value="${broker.ready}" />
      <sysproperty key="test.output" value="${module.results}"/>

      <syspropertyset>
        <propertyref prefix="test"/>
      </syspropertyset>
      <syspropertyset>
          <propertyref prefix="broker"/>
      </syspropertyset>

      <sysproperty key="max_prefetch" value ="${max_prefetch}"/>
      <sysproperty key="example.plugin.target" value="${project.root}/build/lib/plugins"/>
      <sysproperty key="QPID_EXAMPLE_HOME" value="${project.root}/build"/>
      <sysproperty key="QPID_HOME" value="${project.root}/build"/>

      <sysproperty key="net.sourceforge.cobertura.datafile"
		file="${cobertura.datafile}" />
      
      <formatter type="plain"/>
      <formatter type="xml"/>

      <classpath path="${module.instrumented}"/>
      <classpath>
        <fileset dir="${build}">
	  <include name="**/classes-instrumented/*.class"/>
	</fileset>
      </classpath>
      <classpath refid="module.test.path"/>
      <classpath refid="cobertura.classpath"/>      

      <batchtest todir="${module.results}">
        <fileset dir="${module.test.src}" excludes="${module.test.excludes}">
          <include name="**/${test}.java"/>
        </fileset>
      </batchtest>
    </junit>
  </target>

  <target name="coverage-report" depends="cobertura-init">
      <echo message="${cobertura.datafile}"/>
      <cobertura-report format="html"
                      destdir="${module.coverage}"
		      datafile="${cobertura.datafile}">
      <fileset dir="${module.src}" includes="**/*.java" />
    </cobertura-report>
  </target>
  
  <property name="version.file" location="${module.classes}/qpidversion.properties"/>
  <property file="${version.file}" prefix="old."/>

  <target name="check-version">
    <exec executable="svnversion" spawn="false" failifexecutionfails="false"
        dir="${project.root}" outputproperty="svnversion.output">
      <arg line="."/>
    </exec>
    <condition property="version.stale">
      <not>
        <equals arg1="${svnversion.output}" arg2="${old.qpid.svnversion}"/>
      </not>
    </condition>
  </target>

  <target name="create-version" depends="check-version" if="version.stale">
    <!-- Write the version.properties out.-->
    <!-- Echos exactly as shown, so leave no spaces before/after lines -->
    <echo file="${version.file}" append="false">qpid.version=${project.version}
qpid.svnversion=${svnversion.output}
qpid.name=${project.name}
</echo>
  </target>

   <!-- Additions to perform LogMessage generation
    To activate for your plugin add the following to your plugin build.xml

    <target name="precompile" depends="gen_logging"/>

   -->

    <property name="gentools.home" location="${project.root}/../gentools" />
    <property name="generated.dir" location="${module.precompiled}" />
    <property name="velocity.compile.dir" value="${build.scratch}/broker/velocity"/>
    <property name="velocity.timestamp" location="${generated.dir}/velocity.timestamp" />

    <target name="compile_velocity" >
        <mkdir dir="${velocity.compile.dir}" />
        <!-- Compile LogMessages Velocity Generator -->
        <javac source="${java.source}" target="${java.target}"
               destdir="${velocity.compile.dir}" debug="on" includeantruntime="false"
               deprecation="${javac.deprecation}"
               srcdir="${project.root}/broker/src/velocity/java" >
          <classpath>
            <pathelement path="${gentools.home}/lib/velocity-1.4.jar" />
          </classpath>
          <compilerarg line="${javac.compiler.args}"/>
        </javac>
    </target>


    <target name="check_velocity_deps">
      <uptodate property="velocity.notRequired" targetfile="${velocity.timestamp}">
        <srcfiles dir="${module.src}" includes="**/*_logmessages.properties" />
        <srcfiles dir="${project.root}/broker/src/velocity/" includes="**/*.java **/*.vm" />
      </uptodate>
    </target>


    <target name="gen_logging" depends="compile_velocity,check_velocity_deps" unless="velocity.notRequired">
      <mkdir dir="${generated.dir}"/>

      <path id="logmessages.path">
        <fileset  dir="${module.src}">
          <include name="**/*_logmessages.properties"/>
        </fileset>
      </path>

      <pathconvert property="logmessages"
                   refid="logmessages.path"
                   pathsep="' '"/>

      <echo message="logmessages is ${logmessages}"/>

      <java classname="org.apache.qpid.server.logging.GenerateLogMessages" fork="true" dir="${gentools.home}/src" failonerror="true">
        <arg line="'${logmessages}'"/>
          <arg value="-j"/>
          <arg value="-o"/>
          <arg value="${generated.dir}"/>
          <arg value="-t"/>
          <arg value="${project.root}/broker/src/velocity/templates/org/apache/qpid/server/logging/messages"/>
          <arg value="-s"/>
          <arg value="${module.src}"/>


        <classpath>
          <pathelement path="${module.src}"/>
          <pathelement path="${velocity.compile.dir}" />
          <fileset dir="${project.root}/lib">
            <include name="**/*.jar"/>
          </fileset>
          <pathelement path="${gentools.home}/lib/velocity-1.4.jar" />
        </classpath>
      </java>
      <touch file="${velocity.timestamp}" />
    </target>

    <target name="eclipse" depends="eclipse-setup,eclipse-project,eclipse-source-only,eclipse-source-and-test"/>

    <target name="eclipse-setup">
      <taskdef name="eclipse" classname="prantl.ant.eclipse.EclipseTask" />

      <!-- Build set of directories representing the dependencies -->

      <dirset id="eclipse.required.projectdirs.path" dir="${project.root}" includes="${module.depends} ${module.test.depends} neverBeEmpty">
        <!-- Select only those projects from module.depends that contain a build.xml.  This serves to exclude dependencies that
             don't become Eclipse projects e.g. broker-plugins and common-tests -->
        <present targetdir="${project.root}">
          <mapper type="glob" from="*" to="*/build.xml"/>
        </present>
      </dirset>

      <!-- Convert from the set of directories into Eclipse project names proceeded by forward slashes -->

      <pathconvert property="eclipse.required.projectnames" refid="eclipse.required.projectdirs.path" pathsep=" " dirsep="-">
        <map from="${project.root}${file.separator}" to=''/>
      </pathconvert>
      <map property="eclipse.required.slashedprojectnames" value="${eclipse.required.projectnames}" join="${path.separator}">
        <globmapper from="*" to="/*"/>
      </map>

      <echo message="Ant module dependencies : ${module.depends} ${module.test.depends} converted to Eclipse required project(s): ${eclipse.required.slashedprojectnames}"/>
      <path id="eclipse.required.slashedprojectnames.path">
        <pathelement path="${eclipse.required.slashedprojectnames}"/>
      </path>
    </target>

    <!-- Create the Eclipse .project -->
    <target name="eclipse-project">
      <eclipse updatealways="${eclipse.updatealways}">
        <project name="${module.name}"/>

        <!-- If the Eclipse task were to ever support the generation of
             linked resources, we would configure it to generate
             the following:

             scratch_src -> ${module.precompiled}

             in each project.   This would avoid the 'linked sources'
             manual step documented on the Wiki.
        -->
      </eclipse>
    </target>
    
    <!-- Create the Eclipse .classpath -->
    <target name="eclipse-source-only" unless="module.test.src.exists">
      <eclipse updatealways="${eclipse.updatealways}">
        <settings>
          <jdtcore compilercompliance="${eclipse.compilercompliance}" />
        </settings>
        <classpath>
          <container path="${eclipse.container}" />
          <source path="${module.src}" />
          <source pathref="eclipse.required.slashedprojectnames.path" />
          <library pathref="module.libs"/>
          <output path="classes" />
        </classpath>
      </eclipse>
    </target>

    <!-- Create the Eclipse .classpath -->
    <target name="eclipse-source-and-test" if="module.test.src.exists">
      <eclipse updatealways="${eclipse.updatealways}">
        <settings>
          <jdtcore compilercompliance="${eclipse.compilercompliance}" />
        </settings>
        <classpath>
          <container path="${eclipse.container}" />
          <source path="${module.src}" />
          <source path="${module.test.src}" />
          <source pathref="eclipse.required.slashedprojectnames.path" />
          <library pathref="module.libs"/>
          <library pathref="module.test.libs"/>
          <output path="classes" />
        </classpath>
      </eclipse>
    </target>
</project>