forked from ESGF/esgf-web-fe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
777 lines (658 loc) · 29.8 KB
/
build.xml
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
<!--
Author: Gavin Bell
Description:
This is the ant build file for the esgf-web-fe project. This file
should not be modified. A user may set the values of the
properties used in this file by defining the property file
$HOME/.esgf-web-fe.ant.properties which will override the values set
here. An example of such a file is located in this etc directory.
NOTE:
If you get this error:
BUILD FAILED
java.lang.NoSuchMethodError: org.apache.tools.ant.util.FileUtils.getFileUtils()L
org/apache/tools/ant/util/FileUtils;
It means somewhere in your system and/or classpath is an old ANT clobbering
the one you want to run. Use the "-noclasspath" flag in the ant command.
-->
<!--
Description:
Builds the project via ant (obviously).
-->
<project name="esgf-web-fe" default="make" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="module" value="esgf-web-fe"/>
<property name="organization" value="Earth Systems Grid Federation"/>
<!--
************************************************************
Global Initialization and Preparation....
************************************************************
-->
<property file="${user.home}/.${module}.ant.properties"/>
<echo message="user property file ${user.home}/.${module}.ant.properties"/>
<property file="${user.home}/.esgf.ant.properties"/>
<echo message="user property file ${user.home}/.esgf.ant.properties"/>
<property file="${basedir}/etc/${module}.ant.properties"/>
<echo message="user property file ${basedir}/etc/${module}.ant.properties"/>
<exec executable="bash" dir="${basedir}" outputproperty="version_num">
<arg value="-c"/>
<arg value="git describe | sed -n 's/v\([a-zA-Z0-9.]*\)[-]*.*/\1/p'"/>
</exec>
<exec executable="bash" dir="${basedir}" outputproperty="branch">
<arg value="-c"/>
<arg value="git branch | grep '*' | sed -n 's/\*[ ]*//p'"/>
</exec>
<exec executable="bash" dir="${basedir}" outputproperty="commit">
<arg value="-c"/>
<arg value="git describe"/>
</exec>
<exec executable="bash" dir="${basedir}" outputproperty="release_name">
<arg value="-c"/>
<arg value="git tag | sed -ne 's/\(v[0-9]*\.[0-9]*\.[0-9]*\)-\([a-zA-Z0-9_-]*\)-release.*$/\2/p' | sort -k1,1 | tail -n 1"/>
</exec>
<property name="ivy.esgf-repo-local.default.root.dir" value="${user.home}/.ivy2/local"/>
<property name="ivy_retrieve_type" value="jar, bundle"/>
<property name="filter" value="false"/>
<property name="sign" value="false"/>
<property name="seal" value="false"/>
<!-- **static defines** -->
<property name="version_num" value="0.0.0"/>
<filter token="version_num" value="${version_num}"/>
<property name="branch" value="[nobranch]"/>
<filter token="branch" value="${branch}"/>
<property name="commit" value="ffffff"/>
<filter token="commit" value="${commit}"/>
<property name="release_name" value="no_name"/>
<filter token="release_name" value="${release_name}"/>
<filter token="module" value="${module}"/>
<!-- mail property values -->
<property name="mail.smtp.host" value="no_name"/>
<filter token="mail.smtp.host" value="${mail.smtp.host}"/>
<property name="mail.admin.address" value="no_name"/>
<filter token="mail.admin.address" value="${mail.admin.address}"/>
<property name="mail.notification.messageTemplateFile" value="no_name"/>
<filter token="mail.notification.messageTemplateFile" value="${mail.notification.messageTemplateFile}"/>
<property name="mail.notification.initialDelay" value="no_name"/>
<filter token="mail.notification.initialDelay" value="${mail.notification.initialDelay}"/>
<property name="mail.notification.period" value="no_name"/>
<filter token="mail.notification.period" value="${mail.notification.period}"/>
<!-- database property values -->
<property name="db.driver" value="no_name"/>
<filter token="db.driver" value="${db.driver}"/>
<property name="db.protocol" value="no_name"/>
<filter token="db.protocol" value="${db.protocol}"/>
<property name="db.host" value="no_name"/>
<filter token="db.host" value="${db.host}"/>
<property name="db.port" value="no_name"/>
<filter token="db.port" value="${db.port}"/>
<property name="db.database" value="no_name"/>
<filter token="db.database" value="${db.database}"/>
<property name="db.user" value="no_name"/>
<filter token="db.user" value="${db.user}"/>
<property name="db.password" value="no_name"/>
<filter token="db.password" value="${db.password}"/>
<property name="log_dir" value="/tmp/esg/logs"/>
<mkdir dir="${log_dir}" />
<filter token="log_dir" value="${log_dir}"/>
<property environment="env"/>
<!-- ****************** -->
<!--
************************************************************
Initialization and Preparation....
************************************************************
-->
<target name="-pre-init" unless="build.master">
<property name="build.compiler" value="javac1.5" />
<property name="build.compiler.emacs" value="true" />
<echo message="set build.compiler to ${build.compiler}"/>
</target>
<!-- ********************************************************* -->
<target name="init" depends="-pre-init" unless="build.master"
description="(View the properties defined in this file)">
<echo message="Initializing build environment..."/>
<!-- defaults to use if local .${module}.ant.properties file does not exist -->
<property name="src_dir" value="${basedir}/src/java/main"/>
<property name="lib_dir" value="${basedir}/lib"/>
<property name="lib_fetched_dir" value="${basedir}/lib/fetched"/>
<property name="lib_compile_dir" value="${lib_fetched_dir}/compile"/>
<property name="lib_runtime_dir" value="${lib_fetched_dir}/runtime"/>
<property name="build_dir" value="${basedir}/build"/>
<property name="dist_dir" value="${basedir}/dist"/>
<property name="bin_dir" value="${basedir}/bin"/>
<property name="test_src_dir" value="${basedir}/src/java/test"/>
<property name="test_build_dir" value="${basedir}/build/test"/>
<property name="test_build_dir_inst" value="${basedir}/build/test-instrumented" />
<property name="etc_dir" value="${basedir}/etc"/>
<property name="conf_dir" value="${etc_dir}/conf"/>
<property name="web_dir" value="${basedir}/web"/>
<property name="doc_dir" value="${basedir}/docs"/>
<property name="depcache_dir" value="${java.io.tmpdir}/${module}/depcache"/>
<property name="log_config" value="${conf_dir}/log4j.properties"/>
<property name="log_file" value="${log_dir}/${module}_v${version_num}.log"/>
<property name="javadoc_link_src" value="false"/>
<property name="main_class" value="esgf.xxx.core.Main"/>
<property name="doc_dir_generated" value="${basedir}/docs-generated"/>
<property name="jdoc_dir" value="${doc_dir_generated}/javadocs"/>
<property name="test_results_dir" value="${doc_dir_generated}/test-results"/>
<property name="test_reports_dir" value="${doc_dir_generated}/test-reports"/>
<property name="test_coverage_dir" value="${doc_dir_generated}/coverage-reports" />
<property name="lib_deps_reports_dir" value="${doc_dir_generated}/dep-reports"/>
<property name="jaxb_xsd_dir" value="${etc_dir}/xsd/"/>
<property name="jaxb_gen_src_dir" value="${src_dir}/esg/common/generated"/>
<property name="jaxb_gen_package" value="esgf.common.generated"/>
<property name="test_last_failed_file" location="${build_dir}/.lasttestsfailed"/>
<property name="test_coverage_file" value="${basedir}/.cobertura.ser"/>
<!--
<property name="ivy.lib.dir" value="${lib_fetched_dir}"/>
-->
<echo message="--------------------------------"/>
<echo message="module = ${module} "/>
<echo message="version_num = ${version_num} "/>
<echo message="release_name = ${release_name} "/>
<echo message="--------------------------------"/>
<echo message="src_dir = ${src_dir}"/>
<echo message="lib_dir = ${lib_dir}"/>
<echo message="lib_fetched_dir = ${lib_fetched_dir}"/>
<echo message="build_dir = ${build_dir}"/>
<echo message="dist_dir = ${dist_dir}"/>
<echo message="build_dir = ${build_dir}"/>
<echo message="test_src_dir = ${test_src_dir}"/>
<echo message="test_build_dir = ${test_build_dir}"/>
<echo message="etc_dir = ${etc_dir}"/>
<echo message="conf_dir = ${conf_dir}"/>
<echo message="web_dir = ${web_dir}"/>
<echo message="doc_dir = ${doc_dir}"/>
<echo message="depcache_dir = ${depcache_dir}"/>
<echo message="log_config = ${log_config}"/>
<echo message="log_file = ${log_file}"/>
<echo message="javadoc_link_src = ${javadoc_link_src}"/>
<echo message="filter = ${filter} "/>
<echo message="--------------------------------"/>
<echo message="doc_dir_generated = ${basedir}/docs-generated"/>
<echo message="jdoc_dir = ${jdoc_dir}"/>
<echo message="test_results_dir = ${test_results_dir}"/>
<echo message="test_reports_dir = ${test_reports_dir}"/>
<echo message="test_coverage_dir = ${test_coverage_dir}"/>
<echo message="lib_deps_reports_dir = ${doc_dir_generated}/dep-reports"/>
<echo message="--------------------------------"/>
<tstamp/>
</target>
<!--
************************************************************
Library and Resource Dependencies...
************************************************************
-->
<target name="init-ivy" depends="init">
<property name="ivy_version" value="2.3.0" />
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpath="${lib_dir}/ivy-${ivy_version}.jar"/>
<ivy:settings file="./ivysettings.xml" />
</target>
<target name="deps" depends="init-ivy" description="(Sets up library dependencies: Ivy)">
<mkdir dir="${lib_fetched_dir}" />
<mkdir dir="${lib_compile_dir}" />
<mkdir dir="${lib_runtime_dir}" />
<ivy:resolve type="${ivy_retrieve_type}"/>
<ivy:retrieve pattern="${lib_fetched_dir}/[conf]/[artifact]-[revision].[ext]" />
<ivy:deliver deliverpattern="dist/[artifact]-[revision].[ext]"
pubrevision="${version_num}" status="milestone" />
<ivy:cachepath pathid="compile.classpath" conf="compile" useOrigin="true" />
<ivy:cachepath pathid="runtime.classpath" conf="runtime" useOrigin="true" />
<path id="main_classpath">
<fileset dir="${lib_dir}">
<include name="**/*.jar"/>
<exclude name="**/junit*.jar"/>
<exclude name="**/*javadoc.jar"/>
<exclude name="**/*sources.jar"/>
</fileset>
<pathelement path="${build_dir}"/>
</path>
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
<classpath refid="compile.classpath"/>
</taskdef>
<echo message="Runtime Classpath:" />
<pathconvert property="_cp" refid="runtime.classpath" pathsep="${line.separator}"/>
<echo>${_cp}</echo>
<echo message="--------------------------------"/>
</target>
<target name="dep_report" depends="deps" description="(Generates a report of library dependencies)">
<mkdir dir="${lib_deps_reports_dir}"/>
<ivy:report todir="${lib_deps_reports_dir}"/>
</target>
<target name="dep_clean_cache" depends="init,init-ivy" description="(Cleans the Ivy cache)">
<ivy:cleancache />
</target>
<target name="dep_clean_libs" depends="init"
description="(Cleans out [removes] local workspace jars fetched by Ivy)">
<echo message="Removing local jars fetched by Ivy"/>
<delete dir="${lib_fetched_dir}"/>
</target>
<!--
************************************************************
Generation and Compilation....
************************************************************
-->
<target name="make" depends="deps"
description="(Java compiles all the main source code)">
<echo message="Java compiling ${module}..."/>
<mkdir dir="${build_dir}" />
<mkdir dir="${depcache_dir}" />
<depend srcdir="${src_dir}"
destdir="${build_dir}"
cache="${depcache_dir}"
closure="yes"/>
<javac srcdir="${src_dir}"
destdir="${build_dir}"
includes="**/*.java"
excludes="**/no_comp/**,**/ignore/**,**/*_,**/*_*/**"
classpathref="main_classpath"
debug="on"
verbose="off"
includeantruntime="false"
nowarn="on">
<compilerarg value="-Xlint"/>
</javac>
<copy todir="${build_dir}" filtering="${filter}" overwrite="true">
<fileset dir="${conf_dir}" includes="**/*.properties,**/*.template,**/*filter-web.xml"/>
<fileset dir="${src_dir}" includes="**/*.properties,**/*.template,**/*.xml,**/*.txt"/>
</copy>
<tstamp/>
</target>
<!--
************************************************************
PREPARATION & PACKAGING....
************************************************************
-->
<target name="make_jar" depends="make"
description="(Creates the jar file distribution of this project)">
<echo message="JAR - ${build_dir} ->> ${dist_dir}/${module}.${version_num}.jar"/>
<delete>
<fileset dir="." includes="${dist_dir}/${module}.${version_num}.jar"/>
</delete>
<mkdir dir="${dist_dir}" />
<jar destfile="${dist_dir}/${module}.${version_num}.jar">
<fileset dir="${build_dir}"
includes="org.esgf/**,**/*.properties,**/*filter-web.xml"
excludes="**/test/**,**/test-instrumented/**"/>
<manifest>
<attribute name="Organization" value="${organization}"/>
<attribute name="Author" value="${author}"/>
<attribute name="Project" value="${project_name}"/>
<attribute name="Module" value="${module}"/>
<attribute name="Version" value="${version_num}"/>
<attribute name="Branch" value="${branch}"/>
<attribute name="Commit" value="${commit}"/>
<attribute name="Release-Name" value="${release_name}"/>
<attribute name="Main-Class" value="${main_class}"/>
<section name="esg/">
<attribute name="Sealed" value="false"/>
</section>
</manifest>
</jar>
</target>
<target name="make_test_jar" depends="make_test" description="(Creates test jar file)">
<echo message="JAR - ${test_build_dir} ->> ${dist_dir}/${module}-test.${version_num}.jar"/>
<delete>
<fileset dir="." includes="${dist_dir}/${module}-test.${version_num}.jar"/>
</delete>
<mkdir dir="${dist_dir}" />
<jar destfile="${dist_dir}/${module}-test.${version_num}.jar">
<fileset dir="${test_build_dir}"/>
<manifest>
<attribute name="Organization" value="${organization}"/>
<attribute name="Author" value="${author}"/>
<attribute name="Project" value="${project_name} Tests"/>
<attribute name="Module" value="${module}"/>
<attribute name="Version" value="${version_num}"/>
<attribute name="Branch" value="${branch}"/>
<attribute name="Commit" value="${commit}"/>
<attribute name="Release-Name" value="${release_name}"/>
<section name="esg/">
<attribute name="Sealed" value="false"/>
</section>
</manifest>
</jar>
</target>
<!-- <target name="make_all_jars" depends="make_jar,make_test_jar"/> -->
<target name="make_all_jars" depends="make_jar"/>
<target name="war" depends="make_war" />
<target name="make_war" depends="make,init"
description="(Creates war file of this project)">
<mkdir dir="${dist_dir}" />
<mkdir dir="${dist_dir}/tmplib"/>
<copy todir="${dist_dir}/tmplib" overwrite="true" flatten="yes">
<fileset dir="${lib_runtime_dir}" includes="**/*.jar" />
</copy>
<!-- views.properties bug resolved here
Note: I'm not sure where this should go at the present time
Probably should make a cosmetic change later
-->
<copy todir="${build_dir}" overwrite="true" >
<fileset dir="${etc_dir}" />
</copy>
<!-- end views.properties bug-->
<delete file="${dist_dir}/${module}.war"/>
<war destfile="${dist_dir}/${module}.war" webxml="${web_dir}/WEB-INF/web.xml">
<fileset dir="${web_dir}" excludes="**semantic.cache**"/>
<lib dir="${dist_dir}/tmplib">
<include name="**/*.jar"/>
<exclude name="**/*-test*.jar,**/*-common*.jar"/>
</lib>
<classes dir="${build_dir}"/>
<manifest>
<attribute name="Organization" value="${organization}"/>
<attribute name="Author" value="${author}"/>
<attribute name="Project" value="${project_name}"/>
<attribute name="Module" value="${module}"/>
<attribute name="Version" value="${version_num}"/>
<attribute name="Branch" value="${branch}"/>
<attribute name="Commit" value="${commit}"/>
<attribute name="Release-Name" value="${release_name}"/>
</manifest>
</war>
<delete dir="${dist_dir}/tmplib"/>
</target>
<target name="make_dist" depends="make_war,make_all_jars"
description="(Creates full software distribution)">
<delete file="${dist_dir}/${module}.${version_num}.tar.gz"/>
<tar destfile="${dist_dir}/${module}.${version_num}.tar">
<tarfileset dir="${dist_dir}" includes="**/*.jar,**/*.war" prefix="${module}.${version_num}"/>
<!-- <tarfileset dir="${etc_dir}/db" prefix="${module}.${version_num}/db"/> -->
<tarfileset dir="${basedir}" prefix="${module}.${version_num}">
<include name="LICENSE"/>
<include name="INSTALL"/>
<include name="README"/>
</tarfileset>
</tar>
<gzip destfile="${dist_dir}/${module}.${version_num}.tar.gz" src="${dist_dir}/${module}.${version_num}.tar"/>
<delete file="${dist_dir}/${module}.${version_num}.tar"/>
</target>
<!--
************************************************************
CLEANING....
************************************************************
-->
<target name="clean" depends="init"
description="(Cleans out classfiles from build dir)">
<echo message="Removing build directory"/>
<delete dir="${build_dir}"/>
<delete dir="${doc_dir_generated}"/>
<delete file="${test_coverage_file}"/>
<delete dir="${test_build_dir_inst}"/>
<tstamp/>
</target>
<target name="clean_dist" depends="init"
description="(Cleans out the distribution directory)">
<echo message="Cleaning out distribution directory"/>
<delete dir="${dist_dir}"/>
<tstamp/>
</target>
<target name="clean_local_repo" depends="init,init-ivy" description="(Cleans the local filesystem Ivy repo)">
<delete dir="${ivy.esgf-repo-local.default.root.dir}/org.esgf/${module}"/>
</target>
<target name="clean_test" depends="init"
description="(Cleans out the test build directory)">
<echo message="Cleaning out test build directory"/>
<delete dir="${test_build_dir}"/>
<tstamp/>
</target>
<target name="clean_test_jar" depends="init"
description="(Cleans out the test jar file)">
<echo message="Cleaning out test jar file"/>
<delete file="${dist_dir}/${module}-test.${version_num}.jar"/>
<tstamp/>
</target>
<target name="clean_jaxb" depends="init"
description="(Cleans out the JAXB generated Java source files!)">
<echo message="Removing JAXB generated Java source files"/>
<delete dir="${jaxb_gen_src_dir}"/>
</target>
<target name="clean_all"
depends="clean,clean_dist,clean_local_repo,clean_jaxb,dep_clean_libs"
description="(Cleans out generatable artifacts)">
<delete file="${bin_dir}/post.manif"/>
</target>
<!--
************************************************************
JUnit Tests....
************************************************************
-->
<target name="make_test" depends="make"
description="(Java compile all the test source code)">
<echo message="Java compiling ${module} TESTs..."/>
<path id="test_classpath">
<fileset dir="${lib_dir}" includes="**/junit*.jar"/>
<path refid="main_classpath"/>
<pathelement location="${test_build_dir}" />
</path>
<!--
<echo message="TEST CLASSPATH:"/>
<pathconvert property="test_cp" refid="test_classpath" pathsep="${line.separator}"/>
<echo>${test_cp}</echo>
-->
<echo message="--------------------------------"/>
<mkdir dir="${test_build_dir}" />
<mkdir dir="${depcache_dir}" />
<depend srcdir="${test_src_dir}"
destdir="${test_build_dir}"
cache="${depcache_dir}"
closure="yes"/>
<javac srcdir="${test_src_dir}"
destdir="${test_build_dir}"
excludes="**/no_comp/**,**/ignore/**,**/*_,**/*_*/**"
classpathref="test_classpath"
deprecation="true"
failonerror="true"
target="1.5"
debug="on"
verbose="off"
includeantruntime="false"
nowarn="on"/>
<tstamp/>
</target>
<target name="test_check">
<condition property="tests_uptodate">
<and>
<uptodate>
<srcfiles dir="${src_dir}" includes="**/*.java"/>
<mapper type="glob"
from="*.java"
to="${build_dir}/*.class" />
</uptodate>
<uptodate>
<srcfiles dir="${test_src_dir}" includes="**/*.java"/>
<mapper type="glob"
from="*.java"
to="${test_build_dir}/*.class" />
</uptodate>
<not>
<available file="${test_last_failed_file}"/>
</not>
<not>
<isset property="testcase"/>
</not>
</and>
</condition>
<echo message="tests_uptodate = ${tests_uptodate}"/>
</target>
<!--
To run a single test case...
ant test -Dtestcase=esg.node.foo.ESGFooTest
(unless="tests_uptodate")
-->
<target name="test" depends="make_test,test_check"
description="(Runs unit tests: JUnit)">
<delete dir="${test_results_dir}" />
<mkdir dir="${test_results_dir}"/>
<delete dir="${test_reports_dir}" />
<mkdir dir="${test_reports_dir}"/>
<delete dir="${test_coverage_dir}" />
<mkdir dir="${test_coverage_dir}" />
<mkdir dir="${build_dir}/esg" />
<path id="coverage.classpath">
<fileset dir="${lib_dir}" includes="**/*.jar" />
<path refid="main_classpath" />
<pathelement location="${test_build_dir}" />
</path>
<taskdef resource="tasks.properties" classpathref="coverage.classpath" />
<!-- instrument classes -->
<cobertura-instrument todir="${test_build_dir_inst}" datafile="${test_coverage_file}">
<fileset dir="${build_dir}/esg">
<include name="**/*.class" />
</fileset>
</cobertura-instrument>
<!-- set test_classapth to see instrumented classes -->
<path id="test_classpath">
<pathelement location="${test_build_dir_inst}" />
<fileset dir="${lib_dir}" includes="**/junit*.jar" />
<path refid="main_classpath" />
<pathelement location="${test_build_dir}" />
</path>
<junit errorproperty="failed"
failureproperty="failed"
printsummary="on"
fork="yes"
maxmemory="1024M">
<sysproperty key="net.sourceforge.cobertura.datafile" value="${test_coverage_file}"/>
<classpath refid="test_classpath" />
<formatter type="plain" usefile="false"/>
<formatter type="xml" />
<test name="${testcase}" todir="${test_results_dir}" if="testcase"/>
<batchtest todir="${test_results_dir}" unless="testcase">
<fileset dir="${test_build_dir}" includes="**/*Test*.class">
<exclude name="**/Internal*.class"/>
<exclude name="**/*$$*.class"/>
</fileset>
</batchtest>
<assertions enableSystemAssertions="true">
<enable/>
</assertions>
</junit>
<junitreport todir="${test_results_dir}">
<fileset dir="${test_results_dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${test_reports_dir}"/>
</junitreport>
<!-- coverage report -->
<cobertura-report format="html" srcdir="${src_dir}" destdir="${test_coverage_dir}" datafile="${test_coverage_file}"/>
<cobertura-report format="xml" srcdir="${src_dir}" destdir="${test_coverage_dir}/xml" datafile="${test_coverage_file}"/>
<echo message="last build failed tests" file="${test_last_failed_file}"/>
<fail if="failed" message="Unit tests failed. Check log or reports for details"/>
<delete file="${test_last_failed_file}"/>
</target>
<!--
************************************************************
DOCUMENTATION....
************************************************************
-->
<target name="docs" depends="init"
description="(Generates the javadoc for this project)">
<delete dir="${jdoc_dir}"/>
<mkdir dir="${jdoc_dir}" />
<javadoc
destdir="${jdoc_dir}"
author="true"
version="true"
use="true"
linksource="${javadoc_link_src}"
windowtitle="${module} api"
classpathref="main_classpath">
<packageset dir="${src_dir}" defaultexcludes="yes">
<exclude name="**/test/**,**/test-instrumented/**"/>
</packageset>
<doctitle><![CDATA[<h1>${module}</h1>]]></doctitle>
<bottom><![CDATA[<i><a href="http://esgf.org/" target="_top">ESGF</a> / <a href="http://esgf.org/LICENSE" target="_top">BSD OpenSource License</a></i>]]></bottom>
<tag name="todo" scope="all" description="To do:"/>
<group title="ESGF Core Packages" packages="esgf.xxx.core*"/>
<group title="ESGF Component Packages" packages="esgf.xxx.components*"/>
<group title="ESGF Connection Packages" packages="esgf.xxx.connection*"/>
<group title="ESGF Server Packages" packages="esgf.xxx.service*"/>
<group title="ESGF Common Packages" packages="esgf.common*"/>
<group title="ESGF Database Packages" packages="esgf.xxx.db*"/>
<group title="ESGF Utility Packages" packages="esgf.xxx.util*"/>
<link offline="true" href="http://java.sun.com/javase/6/docs/api/" packagelistLoc="${java.io.tmpdir}"/>
<link href="http://java.sun.com/javase/6/docs/api/"/>
</javadoc>
</target>
<!--
************************************************************
Run....
************************************************************
-->
<target name="run" depends="make_jar">
<path id="jar_cp">
<fileset dir="${lib_dir}">
<include name="**/*.jar"/>
<exclude name="**/junit*.jar"/>
</fileset>
<pathelement path="${dist_dir}/${module}.${version_num}.jar"/>
</path>
<pathconvert property="__cp" refid="jar_cp" pathsep="${line.separator}"/>
<echo>${__cp}</echo>
<java classname="${main_class}" fork="true">
<classpath refid="jar_cp"/>
<!-- <classpath refid="main_classpath"/> -->
<assertions enableSystemAssertions="true">
<enable/>
</assertions>
</java>
</target>
<target name="make_everything" depends="make_dist,test,docs,dep_report"
description="(Builds Everything... Distributions, Tests, Docs n Reports)">
<exec executable="bash" dir="${doc_dir_generated}">
<arg value="-c"/>
<arg value="perl -i -ne 'print unless /pass/' $(find . | xargs grep -i passw | sed -n 's/\(^[^:]*\).*/\1/p')"/>
</exec>
<echo message="JavaDocs ----------> file://${jdoc_dir}/index.html"/>
<echo message="Dependency Report -> file://${lib_deps_reports_dir}/esgf-${module}-default.html"/>
<echo message="Unit Test Report -> file://${test_reports_dir}/index.html"/>
<echo message="Coverage Report -> file://${test_coverage_dir}/index.html"/>
<echo message="Web Site ----------> http://esgf.org/${module}-site/index.html"/>
</target>
<!--
************************************************************
Artifact and Documentation distribution targets
************************************************************
-->
<target name="post_docs" depends="init" description="(posts generated documentatoin to web server)">
<property name="orig.dir" value="${doc_dir_generated}"/>
<property name="dest.server" value="esgf.org"/>
<property name="dest.dir" value="www/${module}-site/"/>
<echo message="orig.dir = ${orig.dir} "/>
<echo message="dest.server = ${dest.server} "/>
<echo message="dest.dir = ${dest.dir} "/>
<echo message="dest.user = ${dest.user} "/>
<exec executable="bash" dir="${orig.dir}">
<arg value="-c"/>
<arg value="perl -i -ne 'print unless /pass/' $(find . | xargs grep -i passw | sed -n 's/\(^[^:]*\).*/\1/p')"/>
</exec>
<exec executable="rsync" dir="${basedir}">
<arg line="-caOvzl --chmod=g+r,a+r --exclude *~ --exclude semantic* ${orig.dir} ${dest.user}@${dest.server}:${dest.dir}"/>
</exec>
</target>
<target name="post" depends="init" description="(posts built artifacts to distribution server)">
<copy file="${bin_dir}/post.manif.tmpl" tofile="${bin_dir}/post.manif" filtering="true" overwrite="true"/>
<echo message="Posting Files To Distribution Server..."/>
<exec executable="post" dir="${bin_dir}">
<arg value="--verbose"/>
</exec>
</target>
<target name="publish" depends="init-ivy" description="(publishes built artifacts to artifact repository)">
<ivy:publish resolver="esgf_repo_devel"
organisation="org.esgf"
module="${module}"
revision="${version_num}"
overwrite="true" haltonmissing="false">
<artifacts pattern="dist/[artifact]-[revision].[ext]"/>
<artifacts pattern="dist/[artifact].war"/>
</ivy:publish>
</target>
<target name="publish_local" depends="init-ivy" description="(publishes built artifacts to artifact repository)">
<ivy:publish resolver="esgf_repo_local"
organisation="org.esgf"
module="${module}"
revision="${version_num}"
overwrite="true" haltonmissing="false">
<artifacts pattern="dist/[artifact]-[revision].[ext]"/>
</ivy:publish>
</target>
</project>