-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
1390 lines (1240 loc) · 64.3 KB
/
Copy pathbuild.xml
File metadata and controls
1390 lines (1240 loc) · 64.3 KB
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
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8"?>
<project name="canyon" basedir="." default="package-web">
<!-- import properties (app settings, classpath, jar file locations) -->
<import file="properties.xml"/>
<target name="init" description="defines custom tasks">
<!-- Taskdefs -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${ant-contrib.jar}"/>
<!-- Ensure that Ant 1.6.2+ is being used -->
<available classname="org.apache.tools.ant.DynamicAttribute" property="ant-1.6.2"/>
<fail unless="ant-1.6.2" message="AppFuse requires Ant 1.6.2 for faster unit testing"/>
<!-- Check that junit.jar is in $ANT_HOME/lib or junit task fails -->
<available classname="junit.framework.TestCase" property="junit.present"/>
<fail unless="junit.present" message="Please copy junit.jar into ${env.ANT_HOME}/lib"/>
<taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask" classpathref="dao.test.classpath"/>
<!-- Test for Tomcat 5.0.x -->
<available classname="org.apache.catalina.ant.SessionsTask" property="tomcat5">
<classpath>
<pathelement path="${tomcat.home}/server/lib/catalina-ant.jar"/>
</classpath>
</available>
<!-- Test for Tomcat 5.5.x -->
<available file="${tomcat.home}/common/lib/jasper-compiler-jdt.jar" property="tomcat5.5"/>
<!-- Conditionally set property for converting to JSP 2.0 -->
<condition property="convert.to.jsp2">
<equals arg1="${jsp.2}" arg2="true"/>
</condition>
<!-- Conditionally set property for pre-compiling JSPs -->
<condition property="precompile.jsp">
<equals arg1="${jsp.precompile}" arg2="true"/>
</condition>
</target>
<!-- Check timestamp on files -->
<target name="prepare" depends="init" description="create target directories">
<tstamp/>
<tstamp><format property="copyright.year" pattern="yyyy"/></tstamp>
<echo message="Preparing target directory '${webapp.target}'"/>
<mkdir dir="${webapp.target}"/>
<mkdir dir="${webapp.target}/WEB-INF"/>
<mkdir dir="${webapp.dist}"/>
<delete dir="${out.instr.dir}"/>
<!-- Make sure hibernatedoclet is necessary -->
<uptodate property="hibernatedoclet.unnecessary">
<srcfiles dir="src/dao" includes="**/*.java"/>
<srcfiles dir="${build.dir}/dao/gen" includes="**/*.xml"/>
<mapper type="glob" from="*.java" to="${build.dir}/dao/gen/*.hbm.xml"/>
</uptodate>
<!-- Make sure webdoclet is necessary -->
<uptodate property="webdoclet.uptodate">
<srcfiles dir="src/web" includes="**/*.java"/>
<mapper type="glob" from="*.java" to="${build.dir}/web/classes/*.class"/>
</uptodate>
<condition property="webdoclet.unnecessary">
<and>
<equals arg1="${webdoclet.uptodate}" arg2="true"/>
<available file="${webapp.target}/WEB-INF/${webapp.name}.tld"/>
</and>
</condition>
</target>
<!-- List of variables in .properties files that will be replaced at build time -->
<filterset id="variables.to.replace">
<filter token="APPNAME" value="${webapp.name}"/>
<filter token="ENCRYPT-ALGORITHM" value="${encrypt.algorithm}"/>
<filter token="ERROR-MAILTO" value="${error.mailTo}"/>
<filter token="ERROR-MAILFROM" value="${mail.default.from}"/>
<filter token="ERROR-MAILHOST" value="${mail.host}"/>
<filter token="ERROR-SERVER" value="${error.server}"/>
<filter token="SECURE-LOGIN" value="${secure.login}"/>
<filter token="HIBERNATE-DIALECT" value="${hibernate.dialect}"/>
</filterset>
<!-- List of variables to replace when configuring Tomcat -->
<filterset id="db.variables">
<filter token="DB-DRIVERNAME" value="${database.driver_class}"/>
<filter token="DB-URL" value="${database.url}"/>
<filter token="DB-NAME" value="${database.name}"/>
<filter token="DB-USERNAME" value="${database.username}"/>
<filter token="DB-PASSWORD" value="${database.password}"/>
</filterset>
<!-- Copy any resource or configuration files -->
<target name="copy-resources" depends="prepare"
description="Copy .properties and .xml files from source directory">
<copy todir="${build.dir}/web/classes" includeEmptyDirs="no">
<fileset dir="web/WEB-INF/classes">
<exclude name="ApplicationResources_zh*.properties"/>
<exclude name="ApplicationResources_de.properties"/>
<exclude name="ApplicationResources_fr.properties"/>
<exclude name="ApplicationResources_nl.properties"/>
<exclude name="ApplicationResources_pt*.properties"/>
<include name="*.properties"/>
<include name="*.xml"/>
<include name="*.vm"/>
</fileset>
<filterset refid="variables.to.replace"/>
</copy>
<native2ascii src="web/WEB-INF/classes" dest="${build.dir}/web/classes"
includes="ApplicationResources_zh*.properties" encoding="UTF-8"/>
<native2ascii src="web/WEB-INF/classes" dest="${build.dir}/web/classes"
encoding="8859_1">
<include name="ApplicationResources_de.properties"/>
<include name="ApplicationResources_fr.properties"/>
<include name="ApplicationResources_nl.properties"/>
<include name="ApplicationResources_pt*.properties"/>
</native2ascii>
<generate-database-properties/>
<copy todir="${build.dir}/web/classes" file="database.properties"/>
</target>
<!-- =================================================================== -->
<!-- The "copy-web-files" target copies the static web resources portion -->
<!-- of your web application source into the build target area -->
<!-- =================================================================== -->
<target name="copy-web-files" depends="prepare" description="Copy static files">
<echo message="Copying static files"/>
<!-- Remove the copy block below if you're not displaying version/copyright in the footer -->
<tstamp>
<format property="build.timestamp" pattern="EEEE MMM dd, yyyy 'at' hh:mm a zz"/>
</tstamp>
<copy todir="${webapp.target}">
<fileset dir="web" includes="common/footer.jsp"/>
<filterset>
<filter token="APPVERSION" value="${webapp.version}"/>
<filter token="COPYRIGHT-YEAR" value="${copyright.year}"/>
<filter token="BUILD-TIME" value="${build.timestamp} by ${user.name}"/>
</filterset>
</copy>
<copy todir="${webapp.target}" includeEmptyDirs="no">
<fileset dir="${basedir}/web">
<include name="**"/>
<exclude name="pages/**"/>
<exclude name="**/classes/**"/>
<exclude name="**/*-resources.xml"/>
</fileset>
</copy>
<!-- Copy JSP Pages under WEB-INF/pages -->
<copy todir="${webapp.target}/WEB-INF">
<fileset dir="${basedir}/web">
<include name="pages/**/*.jsp"/>
</fileset>
<fileset dir="${spring.dir}" includes="*.xml"/>
<fileset dir="${basedir}/web/WEB-INF" includes="**/*-resources.xml"/>
<filterset refid="db.variables"/>
</copy>
<!-- Copy *.txt files so they can be included in release notes -->
<copy todir="${webapp.target}">
<fileset dir="${basedir}">
<include name="*.txt"/>
</fileset>
</copy>
</target>
<!-- =================================================================== -->
<!-- The "jsp-2" replaces JSTL's <c:out> tags with what's in "value" and -->
<!-- removes JSTL's 1.0 JARS -->
<!-- =================================================================== -->
<target name="jsp-2" depends="webdoclet" if="convert.to.jsp2"
description="Convert JSP 1.2 tags (i.e. JSTL) to JSP 2.0">
<echo level="info">Change JSTL Tags to Run-Time</echo>
<replaceregexp flags="g">
<regexp pattern='uri="http://java.sun.com/jstl/core"'/>
<substitution expression='uri="http://java.sun.com/jsp/jstl/core"'/>
<fileset dir="${webapp.target}" includes="**/*.jsp"/>
</replaceregexp>
<replaceregexp flags="g">
<regexp pattern='uri="http://java.sun.com/jstl/fmt"'/>
<substitution expression='uri="http://java.sun.com/jsp/jstl/fmt"'/>
<fileset dir="${webapp.target}" includes="**/*.jsp"/>
</replaceregexp>
<replaceregexp flags="g">
<regexp pattern='uri="http://java.sun.com/jstl/sql"'/>
<substitution expression='uri="http://java.sun.com/jsp/jstl/sql"'/>
<fileset dir="${webapp.target}" includes="**/*.jsp"/>
</replaceregexp>
<echo level="info">Removing JSTL's c:out tags</echo>
<replaceregexp flags="g">
<regexp pattern='<c:out value="([^"]*)"/>'/>
<substitution expression="\1"/>
<fileset dir="${webapp.target}" includes="**/*.jsp"/>
</replaceregexp>
<echo level="info">Replacing 2.3 DTD with 2.4 XSD in web.xml</echo>
<replace file="${webapp.target}/WEB-INF/web.xml">
<replacetoken><![CDATA[<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>]]></replacetoken>
<replacevalue><![CDATA[<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
]]></replacevalue>
</replace>
</target>
<!-- =================================================================== -->
<!-- The "stage-web" is used to gather all static web recourses in the -->
<!-- build directory. -->
<!-- =================================================================== -->
<target name="stage-web" depends="copy-resources,copy-web-files"
description="Calls other targets to gather static resources"/>
<!-- =================================================================== -->
<!-- The "hibernatedoclet" target generates Hibernate mapping files -->
<!-- based on XDoclet marked-up Plain Old Java Object (POJO) -->
<!-- =================================================================== -->
<target name="hibernatedoclet" depends="prepare" unless="hibernatedoclet.unnecessary"
description="Generate Hibernate mapping files">
<taskdef name="hibernatedoclet"
classname="xdoclet.modules.hibernate.HibernateDocletTask"
classpathref="xdoclet.classpath"/>
<!-- generate hibernate files -->
<hibernatedoclet destdir="${build.dir}/dao/gen" mergedir="metadata/dao"
excludedtags="@version,@author" addedtags="@xdoclet-generated at ${TODAY}"
force="${xdoclet.force}">
<fileset dir="src/dao"/>
<hibernate validatexml="true" version="3.0"/>
</hibernatedoclet>
</target>
<target name="compile-dao" depends="hibernatedoclet" description="Compile dao module">
<compile module="dao"/>
</target>
<target name="package-dao" depends="prepare,compile-dao" description="Package DAO JAR">
<!-- Copy XML and properties files from source -->
<copy todir="${build.dir}/dao/gen">
<fileset dir="src/dao" excludes="**/*-${dao.type}.xml">
<include name="**/*.xml"/>
<include name="**/*.properties"/>
</fileset>
<filterset refid="variables.to.replace"/>
</copy>
<!-- Copy Spring configuration files -->
<mkdir dir="${build.dir}/dao/gen/META-INF"/>
<copy overwrite="true" tofile="${build.dir}/dao/gen/META-INF/applicationContext-${dao.type}.xml">
<fileset dir="src/dao" includes="**/*-${dao.type}.xml"/>
<filterset refid="variables.to.replace"/>
</copy>
<jar destfile="${dist.dir}/${webapp.name}-dao.jar">
<manifest>
<attribute name="Class-Path" value="${webapp.name}-dao.jar"/>
</manifest>
<fileset dir="${build.dir}/dao/classes"/>
<fileset dir="${build.dir}/dao/gen" includes="**/*.xml"
excludes="**/applicationContext-*.xml"/>
<metainf dir="${build.dir}/dao/gen/META-INF"/>
</jar>
</target>
<target name="test-dao" depends="copy-resources,package-dao,db-load,check-debug" description="Test dao module">
<test-module module="dao" additional.src.dirs="${build.dir}/dao/gen"/>
</target>
<!-- Service -->
<target name="compile-service" depends="package-dao" description="Compile service module">
<compile module="service"/>
</target>
<target name="package-service" depends="compile-service">
<mkdir dir="${build.dir}/service/classes/META-INF"/>
<copy tofile="${build.dir}/service/classes/META-INF/applicationContext-service.xml">
<fileset dir="src/service" includes="**/*-service.xml"/>
</copy>
<jar destfile="${dist.dir}/${webapp.name}-service.jar">
<manifest>
<attribute name="Class-Path"
value="${webapp.name}-dao.jar ${webapp.name}-service.jar"/>
</manifest>
<fileset dir="${build.dir}/service/classes" includes="**/*.class"/>
<metainf dir="${build.dir}/service/classes/META-INF"/>
</jar>
</target>
<target name="test-service" depends="copy-resources,compile-service,check-debug" description="Test service module">
<test-module module="service"/>
</target>
<target name="compile-web" depends="package-service,stage-web" description="Compile web module">
<compile module="web"/>
</target>
<!-- Simple alias to compile-web -->
<target name="compile" depends="compile-web"
description="alias for compile-web"/>
<target name="webdoclet" depends="compile-web" unless="webdoclet.unnecessary"
description="Generate JSP TLD and other web artifacts">
<taskdef name="webdoclet" classname="xdoclet.modules.web.WebDocletTask">
<classpath>
<path refid="xdoclet.classpath"/>
<path refid="web.compile.classpath"/>
</classpath>
</taskdef>
<webdoclet destdir="${webapp.target}/WEB-INF" force="${xdoclet.force}"
mergedir="metadata/web" excludedtags="@version,@author" verbose="true">
<fileset dir="src/web"/>
<fileset dir="src/dao"/>
<jsptaglib validateXML="true" templateFile="metadata/templates/taglib_tld.xdt"
description="Custom tag library for this application"
shortName="${webapp.name}" filename="${webapp.name}.tld"/>
<springvalidationxml/>
</webdoclet>
</target>
<!-- Simple alias to package-web -->
<target name="war" depends="package-web" description="alias for package-web"/>
<target name="package-web" depends="compile-web,compile-jsp" description="Package WAR">
<!-- If Servlet 2.4, uncomment the <dispatcher> elements in filter-mappings -->
<if>
<or>
<isset property="convert.to.jsp2"/>
</or>
<then>
<replaceregexp flags="g"
file="${webapp.target}/WEB-INF/web.xml"
match='<!--dispatcher>'
replace='<dispatcher>'/>
<replaceregexp flags="g"
file="${webapp.target}/WEB-INF/web.xml"
match='</dispatcher-->'
replace='</dispatcher>'/>
<property name="jstl.final.dir" value="${jsp2.jstl.dir}"/>
</then>
<else>
<property name="jstl.final.dir" value="${jstl.dir}"/>
</else>
</if>
<echo>Preparing tomcat-context.xml for inclusion in war</echo>
<!-- Copy tomcat-context.xml file to context.xml -->
<if>
<and>
<isset property="tomcat5"/>
<not><isset property="tomcat5.5"/></not>
</and>
<then>
<copy tofile="${webapp.dist}/context.xml"
file="metadata/conf/tomcat-context.xml" overwrite="true">
<filterset refid="db.variables"/>
</copy>
</then>
<elseif>
<isset property="tomcat5.5"/>
<then>
<copy tofile="${webapp.dist}/context.xml"
file="metadata/conf/tomcat-context-5.5.xml" overwrite="true">
<filterset refid="db.variables"/>
</copy>
</then>
</elseif>
</if>
<!-- Copy .properties files in src tree to build/web/classes -->
<copy todir="${build.dir}/web/classes">
<fileset dir="src/web">
<include name="**/*.properties"/>
<include name="**/*.xml"/>
</fileset>
</copy>
<war destfile="${webapp.dist}/${webapp.war}" duplicate="preserve"
webxml="${webapp.target}/WEB-INF/web.xml" compress="true">
<fileset dir="${webapp.target}" excludes="**/web.xml"/>
<metainf dir="${webapp.dist}" includes="context.xml"/>
<classes dir="${build.dir}/web/classes">
<exclude name="**/database.properties"/>
</classes>
<webinf dir="${build.dir}/dao/gen/META-INF" includes="*.xml"/>
<webinf dir="${build.dir}/service/classes/META-INF" includes="*.xml"/>
<lib file="${dist.dir}/${webapp.name}-dao.jar"/>
<lib file="${dist.dir}/${webapp.name}-service.jar"/>
<lib file="${clickstream.jar}"/>
<lib file="${dwr.jar}"/>
<lib dir="${commons.dir}" includes="*.jar"/>
<lib dir="${jstl.final.dir}/lib" includes="*.jar"/>
<lib dir="${javamail.dir}" includes="*.jar"/>
<lib file="${log4j.jar}"/>
<lib file="${strutsmenu.jar}"/>
<lib file="${database.jar}"/>
<lib dir="${displaytag.dir}" includes="*.jar"/>
<lib file="${hibernate.jar}"/>
<lib dir="${hibernate.dir}/lib" includes="*.jar"/>
<lib dir="${spring.dir}" includes="*.jar" excludes="*mock.jar"/>
<lib file="${sitemesh.jar}"/>
<lib dir="${velocity.dir}" includes="*.jar"/>
<lib file="${urlrewrite.jar}"/>
<lib file="${quartz.jar}"/>
<lib file="${opencsv.jar}"/>
<lib file="${radeox.jar}"/>
</war>
</target>
<target name="test-web" depends="webdoclet,db-load,check-debug" description="Test web module">
<copy todir="${webapp.target}/WEB-INF" file="${spring.dir}/validator-rules.xml"/>
<test-module module="web"/>
</target>
<macrodef name="compile">
<attribute name="module"/>
<attribute name="additional.src.dirs" default=""/>
<element name="options" optional="yes"/>
<sequential>
<echo>Compiling @{module}...</echo>
<mkdir dir="${build.dir}/@{module}/classes"/>
<mkdir dir="${test.dir}/@{module}/classes"/>
<javac srcdir="${src}/@{module};@{additional.src.dirs}"
destdir="${build.dir}/@{module}/classes" debug="${compile.debug}"
deprecation="${compile.deprecation}" optimize="${compile.optimize}"
classpathref="@{module}.compile.classpath">
<options/>
</javac>
<javac srcdir="test/@{module}" debug="true"
destdir="${test.dir}/@{module}/classes">
<classpath>
<path refid="@{module}.test.classpath"/>
<path location="${build.dir}/@{module}/classes"/>
</classpath>
<options/>
</javac>
<emma enabled="${emma.enabled}" >
<instr instrpath="${build.dir}/@{module}/classes"
destdir="${out.instr.dir}/@{module}/classes"
metadatafile="${coverage.dir}/metadata-@{module}.emma"
merge="true"/>
</emma>
</sequential>
</macrodef>
<macrodef name="test-module">
<attribute name="module"/>
<attribute name="additional.src.dirs" default=""/>
<element name="options" optional="yes"/>
<sequential>
<echo level="info">Testing @{module}...</echo>
<mkdir dir="${test.dir}/data"/>
<propertycopy name="testcase" from="@{module}-testcase" silent="true"/>
<!-- Replace tokens in test properties files -->
<copy todir="${test.dir}/@{module}/classes">
<fileset dir="test/@{module}" excludes="**/*.java"/>
<filterset refid="variables.to.replace"/>
</copy>
<junit printsummary="no" forkmode="once" errorProperty="test.failed"
failureProperty="test.failed" fork="${junit.fork}" showoutput="${junit.showoutput}">
<jvmarg value="-Duser.language=en"/>
<classpath>
<!-- Instrumented classes - must be BEFORE the normal ones -->
<!-- ============================= -->
<pathelement location="${out.instr.dir}/@{module}/classes"/>
<pathelement path="@{additional.src.dirs}"/>
<path refid="@{module}.test.classpath"/>
<pathelement location="${build.dir}/@{module}/classes"/>
<pathelement location="${test.dir}/@{module}/classes"/>
<pathelement path="${java.class.path}"/>
<pathelement path="${webapp.target}"/>
<pathelement path="${build.dir}/dao/gen"/>
<!-- For .properties and .xml files -->
<pathelement path="${build.dir}/web/classes"/>
<pathelement path="src/@{module}"/>
<!-- Emma library -->
<!-- ============================= -->
<pathelement location="${emma.jar}"/>
</classpath>
<!-- emma-specific jvm parameter -->
<!-- =========================== -->
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage-@{module}.emma"/>
<formatter type="xml"/>
<formatter type="brief" usefile="false"/>
<batchtest todir="${test.dir}/data" if="testcase">
<fileset dir="${test.dir}/@{module}/classes">
<include name="**/*${testcase}*"/>
<exclude name="**/*TestCase.class"/>
</fileset>
</batchtest>
<batchtest todir="${test.dir}/data" unless="testcase">
<fileset dir="${test.dir}/@{module}/classes">
<include name="**/*Test.class*"/>
</fileset>
</batchtest>
</junit>
<!-- emma report task -->
<!-- ================================== -->
<emma enabled="${emma.enabled}">
<report sourcepathref="all.sources" depth="method">
<fileset dir="${coverage.dir}">
<include name="*.emma"/>
</fileset>
<html outfile="${coverage.dir}/coverage.html"/>
</report>
</emma>
<fail if="test.failed">
Unit tests failed. For error messages, check the log files in
${test.dir}/data or run "ant test-reports"
to generate reports at ${test.dir}/reports.</fail>
</sequential>
</macrodef>
<target name="test-reports" description="Generate test reports">
<mkdir dir="${test.dir}/reports"/>
<junitreport todir="${test.dir}">
<fileset dir="${test.dir}/data">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${test.dir}/reports"/>
</junitreport>
<echo level="info">
Test reports generated at ${test.dir}/reports
</echo>
</target>
<target name="deploy-test-reports" depends="test-reports"
description="Deploys Generated JUnit test reports to server">
<mkdir dir="${test.dir}/reports"/>
<copy todir="${tomcat.home}/webapps/${webapp.name}/test-reports">
<fileset dir="${test.dir}/reports"/>
</copy>
</target>
<!-- =================================================================== -->
<!-- Compile JSPs using jspc -->
<!-- =================================================================== -->
<target name="compile-jsp" depends="jsp-2" if="precompile.jsp">
<property name="jsp.src" value="${build.dir}/web/jsp/src"/>
<mkdir dir="${jsp.src}"/>
<taskdef classname="org.apache.jasper.JspC" name="jasper" classpathref="jspc.classpath"/>
<jasper verbose="0" package="org.tll.canyon.jsp" uriroot="${webapp.target}"
webXmlFragment="${jsp.src}/jsp-servlets.xml" outputDir="${jsp.src}"/>
<javac srcdir="${jsp.src}" destdir="${build.dir}/web/classes"
debug="${compile.debug}" deprecation="${compile.deprecation}"
optimize="${compile.optimize}" classpathref="jspc.classpath"/>
<loadfile property="jsp.mappings" srcfile="${jsp.src}/jsp-servlets.xml"/>
<replace file="${webapp.target}/WEB-INF/web.xml" value="${jsp.mappings}"
token="<!-- precompiled jsp mappings -->"/>
</target>
<!-- =================================================================== -->
<!-- Run Canoo WebTests in Tomcat -->
<!-- =================================================================== -->
<target name="test-canoo" if="tomcat.home" depends="ping-tomcat,db-load,compile-web"
description="Runs Canoo WebTests in Tomcat to test JSPs">
<copy todir="${test.dir}/properties">
<filterchain>
<filterreader classname="org.tll.canyon.buildtools.EscapeHtmlEntities">
<classpath>
<path refid="web.test.classpath"/>
<pathelement location="${test.dir}/web/classes"/>
</classpath>
<param name="mode" value="unescape"/>
</filterreader>
</filterchain>
<fileset dir="web/WEB-INF/classes" includes="**/ApplicationResources*.properties"/>
</copy>
<taskdef resource="webtest_base_relaxed.taskdef">
<classpath>
<path refid="web.test.classpath"/>
<!-- for log4j.properties -->
<path location="${build.dir}/web/classes"/>
</classpath>
</taskdef>
<mkdir dir="${test.dir}/data"/>
<!-- Delete old results file if it exists -->
<delete file="${test.dir}/data/web-tests-result.xml"/>
<!-- This is so the default will be used if no test case is specified -->
<property name="testcase" value="run-all-tests"/>
<echo level="info">Testing with locale '${user.language}'</echo>
<ant antfile="test/web/web-tests.xml" target="${testcase}"/>
</target>
<!-- =================================================================== -->
<!-- Run Canoo WebTests using Cargo -->
<!-- =================================================================== -->
<target name="test-jsp" if="tomcat.home" depends="war,check-debug"
description="Runs Canoo WebTests using Cargo">
<taskdef resource="cargo.tasks">
<classpath>
<fileset dir="${cargo.dir}" includes="*.jar"/>
</classpath>
</taskdef>
<echo>running canoo tests at:
http://${tomcat.server}:${http.port}/${webapp.name}</echo>
<if>
<isset property="tomcat5"/>
<then><property name="cargoId" value="tomcat5x"/></then>
<else><property name="cargoId" value="tomcat4x"/></else>
</if>
<echo message="Starting ${cargoId}..."/>
<cargo containerId="${cargoId}" id="${cargoId}" home="${tomcat.home}" action="start"
output="${test.dir}/cargo.log" wait="false">
<configuration home="${test.dir}/${cargoId}">
<property name="cargo.logging" value="high"/>
<property name="cargo.servlet.port" value="${http.port}"/>
<!--<property name="cargo.jvmargs" value="${run.canyon.test.debugargline}"/>-->
<deployable type="war" file="${webapp.dist}/${webapp.war}"/>
</configuration>
</cargo>
<antcall target="test-canoo"/>
<cargo refid="${cargoId}" action="stop"/>
</target>
<!-- =================================================================== -->
<!-- Run all tests (tomcat not running) -->
<!-- =================================================================== -->
<target name="test-all" depends="test-dao,test-service,test-web,test-jsp"
description="runs all tests for dao, service, web and jsp">
<antcall target="db-load"/>
</target>
<!-- =================================================================== -->
<!-- Run all tests (tomcat IS running). The deploy task -->
<!-- should be run before this one. -->
<!-- =================================================================== -->
<target name="test-all-running"
description="runs all tests for DAOs, Services, Controllers and JSPs">
<antcall target="test-dao"/>
<antcall target="test-service"/>
<antcall target="test-web"/>
<antcall target="test-canoo"/>
<antcall target="db-load"/>
</target>
<!-- =================================================================== -->
<!-- Simple task to ping tomcat and make sure it's running -->
<!-- =================================================================== -->
<target name="ping-tomcat" description="pings tomcat to make sure it's running">
<echo level="info">Verifying that tomcat is running...</echo>
<get src="http://${tomcat.server}:${http.port}/${webapp.name}"
dest="../ping-${tomcat.server}.html"/>
</target>
<!-- =================================================================== -->
<!-- Export the data -->
<!-- =================================================================== -->
<target name="db-export" depends="prepare"
description="Exports the current data in the database">
<dbunit driver="${database.driver_class}" url="${database.url}"
userid="${database.username}" password="${database.password}">
<export dest="db-export.xml" format="xml"/>
</dbunit>
</target>
<target name="db-load" depends="prepare" description="Loads the database with sample data">
<!-- Conditionally change operation based on whether database is mssql -->
<condition property="operation" value="MSSQL_CLEAN_INSERT" else="CLEAN_INSERT">
<equals arg1="${database.type}" arg2="sqlserver"/>
</condition>
<property name="file" value="metadata/sql/sample-data.xml"/>
<dbunit driver="${database.driver_class}"
supportBatchStatement="false" url="${database.url}"
userid="${database.username}" password="${database.password}">
<operation type="${operation}" src="${file}" format="xml"/>
</dbunit>
</target>
<!-- =================================================================== -->
<!-- The "db-create" target creates a database based on properties -->
<!-- from the database.properties file -->
<!-- =================================================================== -->
<target name="db-create" depends="init"
description="create database for ${database.type}">
<echo level="debug">${database.jar}</echo>
<if>
<equals arg1="${database.type}" arg2="mysql"/>
<then>
<echo message="Detected MySQL, creating database..."/>
<echo>Creating '${database.name}' database with: ${database.type}-create.sql</echo>
<echo>URL: ${database.admin.url}</echo>
<copy tofile="${build.dir}/dao/gen/${database.type}-create.sql" overwrite="true" filtering="true">
<fileset file="metadata/sql/${database.type}-create.sql"/>
<filterset refid="db.variables"/>
</copy>
<sql onerror="continue"
driver="${database.driver_class}"
url="${database.admin.url}"
userid="${database.admin.username}"
password="${database.admin.password}">
<classpath>
<pathelement location="${database.jar}"/>
</classpath>
<fileset dir="${build.dir}/dao/gen">
<include name="${database.type}-create.sql"/>
</fileset>
</sql>
</then>
<else>
<echo level="warning">WARNING:</echo>
<echo>You selected a '${database.type}' database which </echo>
<echo>does NOT support creating a database via JDBC. </echo>
<echo>Please create a '${database.name}' database manually</echo>
<echo>and then run "ant db-prepare" to create the </echo>
<echo>database tables. You might want to check the </echo>
<echo>metadata/sql directory to see if the file</echo>
<echo>'${database.type}-create.sql' exists.</echo>
</else>
</if>
</target>
<!-- =================================================================== -->
<!-- The "db-prepare" target generates the database schema and creates -->
<!-- tables based on the mapping files -->
<!-- =================================================================== -->
<target name="db-prepare" depends="clean,package-dao"
description="creates database tables">
<taskdef name="schemaexport"
classname="org.hibernate.tool.hbm2ddl.SchemaExportTask">
<classpath>
<path refid="xdoclet.classpath"/>
<path refid="hibernate.classpath"/>
</classpath>
</taskdef>
<generate-database-properties/>
<schemaexport quiet="no" text="no" drop="no" delimiter=";"
properties="database.properties" output="create-tables.sql">
<fileset dir="${build.dir}/dao/gen" includes="**/*.hbm.xml"/>
</schemaexport>
</target>
<target name="db-drop" depends="hibernatedoclet"
description="drops database tables">
<taskdef name="schemaexport"
classname="org.hibernate.tool.hbm2ddl.SchemaExportTask">
<classpath>
<path refid="xdoclet.classpath"/>
<path refid="hibernate.classpath"/>
</classpath>
</taskdef>
<generate-database-properties/>
<schemaexport quiet="no" text="no" drop="yes" delimiter=";"
properties="database.properties" output="drop-tables.sql">
<fileset dir="${build.dir}/dao/gen" includes="**/*.hbm.xml"/>
</schemaexport>
</target>
<!-- =================================================================== -->
<!-- Setup Database -->
<!-- =================================================================== -->
<target name="setup-db" depends="db-create,db-prepare,db-load"
description="creates database and populates by calling other tasks"/>
<!-- Remove classes directory for clean build -->
<target name="clean" description="Removes build artifacts">
<echo level="info">Cleaning build and distribution directories</echo>
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
<delete file="database.properties"/>
<delete file="create-tables.sql"/>
<delete dir="${out.instr.dir}"/>
<delete dir="${coverage.dir}"/>
<delete dir="${tomcat.home}/webapps/${webapp.name}"/>
</target>
<!-- =================================================================== -->
<!-- Create JavaDoc Documentation -->
<!-- =================================================================== -->
<target name="javadoc" depends="java2html"
description="Generate JavaDoc API docs">
<javadoc
destdir="${build.dir}/docs/api"
packagenames="org.tll.canyon.*"
author="true"
version="true"
windowtitle="${webapp.name} api"
doctitle="<h1>${webapp.name} javadocs for
version ${webapp.version}</h1>"
bottom="Copyright © 2002-${copyright.year}"
stylesheetfile="${build.dir}/docs/api/stylesheet.css">
<fileset dir="${src}">
<patternset refid="java.files.pattern"/>
</fileset>
<fileset dir="test">
<patternset refid="java.files.pattern"/>
</fileset>
<classpath refid="web.test.classpath"/>
<classpath>
<pathelement location="${jmock.jar}"/>
<pathelement location="${build.dir}/web/gen"/>
</classpath>
<!-- XDoclet Tags -->
<tag name="hibernate.class" scope="all" description="Class:"/>
<tag name="hibernate.id" scope="all" description="Id:"/>
<tag name="hibernate.property" scope="all" description="Property:"/>
<tag name="jsp.tag" scope="all" description="JSP Tag:"/>
<tag name="jsp.attribute" scope="all" description="JSP Attribute:"/>
<tag name="struts.action" scope="all" description="Mapping:"/>
<tag name="struts.action-forward" scope="all" description="ActionForward:"/>
<tag name="struts.form" scope="all" description="Form Name:"/>
<tag name="struts.validator" scope="all" description="Validator:"/>
<tag name="struts.validator-args" scope="all" description="Validator Args:"/>
<tag name="struts.validator-var" scope="all" description="Validator Var:"/>
<!-- Application frameworks -->
<link href="http://jakarta.apache.org/commons/lang/api"/>
<link href="http://struts.apache.org/struts-doc-1.2.9/api"/>
<link href="http://www.springframework.org/docs/api"/>
<link href="http://www.hibernate.org/hib_docs/api"/>
<!-- Testing frameworks -->
<link href="http://www.junit.org/junit/javadoc/${junit.version}"/>
<link href="http://strutstestcase.sf.net/api/"/>
<!-- SDKs -->
<link href="http://java.sun.com/j2se/1.4/docs/api/"/>
<link href="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/"/>
</javadoc>
</target>
<!-- =================================================================== -->
<!-- Create HTML versions of the Java code in this project -->
<!-- =================================================================== -->
<target name="java2html" depends="hibernatedoclet"
description="creates HTML pages of code for online viewing">
<taskdef name="java2html" classname="com.java2html.Java2HTMLTask"
classpath="${j2h.jar}"/>
<java2html
destination="${build.dir}/docs/api">
<fileset dir="${src}">
<patternset refid="java.files.pattern"/>
</fileset>
<fileset dir="test">
<patternset refid="java.files.pattern"/>
</fileset>
</java2html>
</target>
<!-- =================================================================== -->
<!-- The "deploy-web" target deploys the web application in the in the -->
<!-- non-war format. -->
<!-- =================================================================== -->
<target name="deploy-web" depends="compile-jsp" if="tomcat.home"
description="deploy only web classes to servlet container's deploy directory">
<echo message="Deploying web application to ${tomcat.home}/webapps"/>
<copy todir="${tomcat.home}/webapps/${webapp.name}">
<fileset dir="${webapp.target}"
excludes="**/web-test.xml,**/web.xml,**/*-resources.xml"/>
</copy>
</target>
<!-- =================================================================== -->
<!-- Refresh - Stops Tomcat, and refreshes everything -->
<!-- =================================================================== -->
<target name="refresh" depends="undeploy,clean,deploy"
description="Undeploys, cleans, then re-deploys"/>
<!-- =================================================================== -->
<!-- The "deploy" target deploys the web application by packaging it as -->
<!-- a WAR and then unpackaging it into Tomcat's webapps directory -->
<!-- =================================================================== -->
<target name="deploy" depends="package-web" if="tomcat.home"
description="unwar into the servlet container's deployment directory">
<unwar src="${webapp.dist}/${webapp.war}"
dest="${tomcat.home}/webapps/${webapp.name}"/>
</target>
<!-- =================================================================== -->
<!-- The "undeploy" target deletes the web application archive and the -->
<!-- web application directory in the compatible servlet container. -->
<!-- =================================================================== -->
<target name="undeploy" if="tomcat.home"
description="undeploy war file to servlet container's deployment dir">
<echo message="Undeploying webapp from Tomcat"/>
<delete file="${tomcat.home}/webapps/${webapp.war}"/>
<delete dir="${tomcat.home}/webapps/${webapp.name}"/>
</target>
<!-- =================================================================== -->
<!-- The "deploy-war" deploys the web application in the in a war format -->
<!-- =================================================================== -->
<target name="deploy-war" depends="package-web" if="tomcat.home"
description="Deploy '${webapp.name}.war' to local Tomcat">
<copy file="${webapp.dist}/${webapp.war}"
todir="${tomcat.home}/webapps"/>
</target>
<!-- Utilities -->
<patternset id="java.files.pattern" includes="**/*.java"/>
<target name="checkstyle" depends="prepare"
description="Check code style for compliance with coding standards">
<property name="checkstyle.data.dir"
location="${build.dir}/docs/checkstyle"/>
<property name="checkstyle.data.file"
location="${checkstyle.data.dir}/checkstyle.xml"/>
<property name="checkstyle.report.file"
location="${checkstyle.data.dir}/checkstyle.html"/>
<property name="checkstyle.xsl.file"
location="${checkstyle.dir}/contrib/checkstyle-noframes.xsl"/>
<mkdir dir="${checkstyle.data.dir}"/>
<taskdef resource="checkstyletask.properties" classpath="${checkstyle.jar}"/>
<checkstyle config="${checkstyle.dir}/sun_checks.xml"
failOnViolation="false" failureProperty="checkstyle.failure">
<fileset dir="src">
<patternset refid="java.files.pattern"/>
</fileset>
<!-- uncomment to print to console as well -->
<!--formatter type="plain"/-->
<formatter type="xml" toFile="${checkstyle.data.file}"/>
</checkstyle>
<xslt in="${checkstyle.data.file}" out="${checkstyle.report.file}"
style="${checkstyle.xsl.file}"/>
</target>
<target name="pmd" if="pmd.jar" depends="prepare"
description="Locates unused imports, unused variables, etc.">
<mkdir dir="${build.dir}/docs/pmd"/>
<property name="pmd.data.file" value="${build.dir}/docs/pmd/pmdreport.html"/>
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
<classpath location="${pmd.jar}"/>
<classpath location="${pmd.dir}/lib/jaxen-core-1.0-fcs.jar"/>
<classpath location="${pmd.dir}/lib/saxpath-1.0-fcs.jar"/>
</taskdef>
<pmd rulesetfiles="rulesets/unusedcode.xml,rulesets/imports.xml"
failonerror="no" shortFilenames="true">
<formatter type="html" toFile="${pmd.data.file}"/>
<fileset dir="src">
<patternset refid="java.files.pattern"/>
</fileset>
</pmd>
</target>
<target name="emma" description="turns on EMMA instrumentation/reporting" >
<property name="emma.enabled" value="true"/>
<mkdir dir="${out.instr.dir}"/>
<!-- Filter for classes to instrument -->
<property name="emma.filter" value="org.tll.canyon.*"/>
</target>
<target name="todo" description="creates report of todos in code">
<taskdef name="todo"
classname="xdoclet.modules.doc.DocumentDocletTask"
classpathref="xdoclet.classpath"/>
<mkdir dir="${build.dir}/docs/todo"/>
<todo destdir="${build.dir}/docs/todo">
<fileset dir="${src}">
<patternset refid="java.files.pattern"/>
</fileset>
</todo>
</target>
<target name="docs" depends="javadoc, todo, checkstyle, pmd"
description="runs javadoc, todo, checkstyle and pmd tasks">
<echo level="info">API and Reports generated successfully...</echo>
</target>