forked from ESGF/esg-publisher
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
780 lines (675 loc) · 31.3 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
778
779
780
<!--
/***************************************************************************
* *
* Organization: Lawrence Livermore National Lab (LLNL) *
* Directorate: Computation *
* Department: Computing Applications and Research *
* Division: S&T Global Security *
* Matrix: Atmospheric, Earth and Energy Division *
* Program: PCMDI *
* Project: Earth Systems Grid (ESG) Data Node Software Stack *
* First Author: Gavin M. Bell ([email protected]) *
* *
****************************************************************************
* *
* Copyright (c) 2009, Lawrence Livermore National Security, LLC. *
* Produced at the Lawrence Livermore National Laboratory *
* Written by: Gavin M. Bell ([email protected]) *
* LLNL-CODE-420962 *
* *
* All rights reserved. This file is part of the: *
* Earth System Grid (ESG) Data Node Software Stack, Version 1.0 *
* *
* For details, see http://esgf.org/ *
* Please also read this link *
* http://esgf.org/LICENSE *
* *
* * Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* conditions are met: *
* *
* * Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* * Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* Neither the name of the LLNS/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this *
* software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE *
* LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR *
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF *
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, *
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT *
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *
* SUCH DAMAGE. *
* *
***************************************************************************/
/**
Description:
This is the ant build file for the esg-publisher 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/.esg-publisher.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="esg-publisher" default="make" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="module" value="esg-publisher"/>
<property name="organization" value="Earth Systems Grid Federation"/>
<property name="project_name" value="ESG-Publisher"/>
<property name="author" value="Gavin M. Bell"/>
<!--
************************************************************
Global Initialization and Preparation....
************************************************************
-->
<property file="${user.home}/.${module}.ant.properties"/>
<echo message="user property file ${user.home}/.${module}.ant.properties"/>
<property file="${basedir}/etc/${module}.ant.properties"/>
<echo message="user property file ${basedir}/etc/${module}.ant.properties"/>
<property name="ivy_retrieve_type" value="jar, bundle"/>
<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>
<property name="filter" value="false"/>
<!-- **static defines** -->
<property name="version_num" value="0.0.0.0"/>
<filter token="version_num" value="${version_num}"/>
<property name="release_name" value="no_name"/>
<filter token="release_name" value="${release_name}"/>
<property name="log_dir" value="/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="build_dir" value="${basedir}/build"/>
<property name="dist_dir" value="${basedir}/dist"/>
<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="esg.node.publisher_fe.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="esg.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="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.1.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}"/>
<ivy:resolve type="${ivy_retrieve_type}"/>
<ivy:retrieve sync="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="main_classpath"/>
</taskdef>
<echo message="MAIN CLASSPATH:"/>
<pathconvert property="_cp" refid="main_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>
<target name="publish" depends="init-ivy" description="Posts build artifact(s) to repository">
<ivy:publish resolver="default-chain"
organisation="esgf"
module="${module}"
pubrevision="${version_num}"
revision="${version_num}"
update="true"
overwrite="true">
<artifacts pattern="${dist_dir}/[artifact].[revision].[ext]"/>
<artifacts pattern="${dist_dir}/[artifact]-[revision].[ext]"/>
</ivy:publish>
</target>
<!--
************************************************************
Generation and Compilation....
************************************************************
-->
<target name="gen_jaxb" depends="deps"
description="(Generates Java Objects from XML schema)">
<mkdir dir="${jaxb_gen_src_dir}"/>
<xjc package="${jaxb_gen_package}"
destdir="${src_dir}"
removeOldOutput="yes"
readonly="yes">
<classpath refid="main_classpath"/>
<schema dir="${jaxb_xsd_dir}" includes="*.xsd"/>
<produces dir="${jaxb_gen_src_dir}" includes="*.java" />
</xjc>
</target>
<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"
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"/>
</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="esg/**,**/*.properties"
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="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="Release-Name" value="${release_name}"/>
<section name="esg/">
<attribute name="Sealed" value="false"/>
</section>
</manifest>
</jar>
</target>
<target name="make_common_jar" depends="make" description="(Creates common jar file)">
<echo message="JAR - ${build_dir} ->> ${dist_dir}/${module}-common.${version_num}.jar"/>
<delete>
<fileset dir="." includes="${dist_dir}/${module}-common*.jar"/>
</delete>
<mkdir dir="${dist_dir}" />
<jar destfile="${dist_dir}/${module}-common.${version_num}.jar">
<fileset dir="${build_dir}"
includes="esg/publisher/common/**"/>
<manifest>
<attribute name="Organization" value="${organization}"/>
<attribute name="Author" value="${author}"/>
<attribute name="Project" value="${project_name} ${module} common"/>
<attribute name="Module" value="${module}"/>
<attribute name="Version" value="${version_num}"/>
<attribute name="Release-Name" value="${release_name}"/>
<section name="esg/publisher/common/">
<attribute name="Sealed" value="false"/>
</section>
</manifest>
</jar>
</target>
<target name="make_fe_jar" depends="make"
description="(Creates the jar file distribution for client Front End GUI)">
<echo message="JAR - ${build_dir} ->> ${dist_dir}/${module}-fe.${version_num}.jar"/>
<delete>
<fileset dir="." includes="${dist_dir}/${module}-fe.${version_num}.jar"/>
</delete>
<mkdir dir="${dist_dir}" />
<jar destfile="${dist_dir}/${module}-fe.${version_num}.jar">
<fileset dir="${build_dir}"
includes="esg/node/publisher_fe/**,esg/publisher/common/**,**/*.properties"
excludes="**/test/**,**test-instrumented/**,**/node.properties/**"/>
<manifest>
<attribute name="Organization" value="${organization}"/>
<attribute name="Author" value="${author}"/>
<attribute name="Project" value="${project_name}"/>
<attribute name="Module" value="${module} fe"/>
<attribute name="Version" value="${version_num}"/>
<attribute name="Release-Name" value="${release_name}"/>
<attribute name="Main-Class" value="${main_class}"/>
<section name="esg/node/publisher_fe/">
<attribute name="Sealed" value="false"/>
</section>
</manifest>
</jar>
</target>
<target name="make_connector_jar" depends="make"
description="(Creates the jar file distribution for node connector component to publisher service)">
<echo message="JAR - ${build_dir} ->> ${dist_dir}/${module}-connector.${version_num}.jar"/>
<delete>
<fileset dir="." includes="${dist_dir}/${module}-connector.${version_num}.jar"/>
</delete>
<mkdir dir="${dist_dir}" />
<jar destfile="${dist_dir}/${module}-connector.${version_num}.jar">
<fileset dir="${build_dir}"
includes="esg/node/publisher/connector/**,esg/publisher/common/**,**/*.properties"
excludes="**/test/**,**/test-instrumented/**,**/${module}.properties/**"/>
<manifest>
<attribute name="Organization" value="${organization}"/>
<attribute name="Author" value="${author}"/>
<attribute name="Project" value="${project_name} ${module} connector"/>
<attribute name="Module" value="${module}"/>
<attribute name="Version" value="${version_num}"/>
<attribute name="Release-Name" value="${release_name}"/>
<section name="esg/node/publisher/connector/">
<attribute name="Sealed" value="false"/>
</section>
</manifest>
</jar>
</target>
<target name="make_all_jars" depends="make_jar,make_test_jar,make_common_jar,make_fe_jar,make_connector_jar"/>
<target name="make_dist" depends="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="${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_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_jaxb,dep_clean_libs"
description="(Cleans out generatable artifacts)"/>
<!--
************************************************************
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"
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.publisher.connector.ESGPublisherTest
(unless="tests_uptodate")
-->
<target name="test" depends="make_test"
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}" />
<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/**"/>
</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="ESG Publisher Client Front End Packages" packages="esg.node.publisher_fe*"/>
<group title="ESG Node Integration Packages" packages="esg.node.publisher*"/>
<group title="Connection Packages" packages="esg.node.publisher.connection*"/>
<group title="Common Packages" packages="esg.node.publisher.common*"/>
<group title="Utility Packages" packages="esg.node.publisher.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 /passw/' $(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>
<target name="post" depends="init">
<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="rsync" dir="${basedir}">
<arg line="-caOvzl --chmod=g+r,a+r --exclude *~ --exclude semantic* ${orig.dir} ${dest.user}@${dest.server}:${dest.dir}"/>
</exec>
</target>
<!--
************************************************************
Python Targets....(calls targets defined in ${basedir}/src/python/build.xml
************************************************************
-->
<target name="make_python">
<ant dir="${basedir}/src/python" antfile="build.xml" target="gen"/>
</target>
<target name="clean_python">
<ant dir="${basedir}/src/python" antfile="build.xml" target="clean"/>
</target>
</project>