summaryrefslogtreecommitdiff
path: root/build.xml
blob: 0c98e245d10f1e6ba9a9f1bab5988ace8273498c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
<?xml version="1.0"?>
<!-- ============= [build file for ANT v1.5.x] ====================== -->
<!DOCTYPE project
[
    <!ENTITY dependencies SYSTEM "dependencies.xml" >
]>

<project name="emma" default="build" basedir="." >
  <!-- $Id: build.xml,v 1.2.2.3 2005/06/13 00:20:55 vlad_r Exp $ --> 
  <property name="app.short.name" value="${ant.project.name}" />
  <property name="app.project.start.date" value="2001/02/01" />

  <!-- TODO: build log --> 

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

  <!-- pull in the OS environment variables; an OS env variable VAR can be used as ${env.VAR}: -->
  <property environment="env" />

  <!-- ============================================================== -->
  <!-- build branch properties and local customization overrides: -->

  <!-- first, load the official build settings file: -->
  <property file="build.properties" />
  
  <!-- next, load the CVS-versioned release/branch properties file: -->
  <property file="release.properties" />

  <!-- next, load an optional global properties file: -->
  <property file="${env.ANT_BLDENV}/ant.properties" />

  <!-- ============================================================== -->
  <!-- global compiler settings: -->

  <property name="build.debug" value="on" /> <!-- default for a release build is "on" -->
  <property name="build.deprecation" value="off" />
  <property name="build.compiler" value="modern" />
  <property name="build.sysclasspath" value="ignore" />
  <property name="build.target" value="1.2" /> <!-- all .class files are stamped as compatible with 1.2 JVMs: -->

  <!-- ============================================================== -->
  <!-- main/default build target: -->

  <target name="build" depends="dist"
          description="-> full build [without 'clean']"
  />

  <!-- helper build subtargets: -->

  <target name="build.core.compile" depends="core.compile"
          description="-> re-compiles updated core sources [no 'clean']"
  />
  <target name="build.core.package" depends="core.package"
          description="-> re-packages core classes [no 'clean']"
  />

  <!-- build modifier targets: -->

  <target name="official"
          description="-> switches 'build' into official, CVS-aware mode" >
    <property name="build.is.official" value="yes" />
  </target>

  <target name="release"
          description="-> [RELEASE]" >
    <property name="build.is.on.a.branch" value="yes" />
    <property name="app.build.release.tag" value="" /> <!-- no tag means official release -->
    <property name="file.release.prefix" value="" />
    <property name="cvs.ready.label.prefix" value="RELEASE" />
  </target>

  <target name="stable"
          description="-> [STABLE]" >
    <property name="app.build.release.tag" value=" (stable)" />
    <property name="file.release.prefix" value="-stable" />
    <property name="cvs.ready.label.prefix" value="STABLE" />
  </target>

  <!-- ============================================================== -->
  <!-- init targets: -->
  <!-- ============================================================== -->

  <!-- static (checked-in) build structure: -->
  <property file="module.dirs.properties" />

  <!-- work (created by the build) build structure: -->
  <property file="work.dirs.properties" />

  <target name="init.work.dirs" >
    <mkdir dir="${out.dir}" />
    <mkdir dir="${dist.dir}" />
    <mkdir dir="${release.dir}" />
    <mkdir dir="${temp.dir}" />

    <mkdir dir="${tools.classes.out.dir}" />

    <mkdir dir="${core.classes.out.dir}" />
    <mkdir dir="${core.srcgen.out.dir}" />
    <mkdir dir="${core.res.out.dir}" />

    <mkdir dir="${ant.classes.out.dir}" />
  </target>

  <target name="init" depends="init.work.dirs">
    <!-- NOTE: the official build machine sets these explicitly,
         these unofficial defaults are provided for private builds only: -->
    <property name="build.target.j2se.14.home" value="${java.home}" />
    <property name="build.target.j2se.12.home" value="${build.target.j2se.14.home}" />
    <property name="build.target.j2se.13.home" value="${build.target.j2se.14.home}" />

    <property name="build.target.ant.15.home" value="${env.ANT_HOME}" />
    <property name="build.target.ant.14.home" value="${build.target.ant.15.home}" />

    
    <!-- verify that we have J2SE 1.4+: -->
    <available property="j2se.is.14+" classname="java.lang.CharSequence" />
    <fail unless="j2se.is.14+">location [${build.target.j2se.14.home}] does not specify J2SE 1.4+</fail>

    <available file="${temp.dir}/.ready.build.stamp" type="file" property="build.is.dirty" value="yes" />

    <!-- include dependencies.xml (a dynamic include by design): -->
    &dependencies;

    <echo message="ANT version: ${ant.version}" />
    <echo message="JDK version: ${ant.java.version}" />
    <echo message="build debug flag: ${build.debug}" />
  </target>

  <!-- ============================================================== -->
  <!-- support targets: -->
  <!-- ============================================================== -->

  <target name="clean" depends="clean.out, clean.dist" description="-> complete clean (output + distribution)" />

  <target name="clean.out" description="-> output clean" >
    <delete dir="${out.dir}" />
  </target>

  <target name="clean.dist" description="-> distribution clean" >
    <delete dir="${dist.dir}"/>
    <delete dir="${release.dir}"/>
  </target>


  <target name="timestamp" depends="init, -timestamp.1, -timestamp.2, -timestamp.3, -timestamp.4, -timestamp.5">
  </target>

  <target name="-timestamp.1" depends="init" unless="build.is.dirty" >
    <java classname="com.vladium.util.version.VersionStampTool"
          classpathref="lib.internal.classpath"
          output="${temp.dir}/.ready.build.stamp"
          append="no"
    >
        <arg value="-start" />
        <arg value="${app.project.start.date}" />
        <arg value="-format" />
        <arg value="~F~" />
    </java>
    <java classname="com.vladium.util.version.VersionStampTool"
          classpathref="lib.internal.classpath"
          output="${temp.dir}/timestamp.properties"
          append="no"
    >
        <arg value="-start" />
        <arg value="${app.project.start.date}" />
        <arg value="-fend" />
        <arg value="${temp.dir}/.ready.build.stamp" />
        <arg value="-format" />
        <arg value="app.build.id=${app.build.id.format}\napp.build.date=${app.build.date.format}" />
    </java>
    <!-- TODO: this is ugly and breaks private builds (constant appending is bad any way): -->
    <!-- <echo message="file.release.prefix=${file.release.prefix}" file="${temp.dir}/timestamp.properties" append="yes" /> -->
  </target>

  <target name="-timestamp.2" depends="init" >
    <property file="${temp.dir}/timestamp.properties" />

    <!-- private/Eclipse build defaults: -->
    <property name="app.build.release.tag" value=" (unsupported private build)" />
    <property name="app.bug.report.link" value="this private build is unsupported" />
    <property name="file.release.prefix" value="-private" />

    <property name="file.release.label" value="${app.major.version}.${app.minor.version}.${app.build.id}" />
    <echo message="build id: ${file.release.label}${app.build.release.tag}" />
  </target>

  <target name="-timestamp.2a" depends="init" if="build.is.on.a.branch" >
    <property name="cvs.branch.label" value="BRANCH_${app.major.version}_${app.minor.version}" />
  </target>

  <target name="-timestamp.3" depends="init, -timestamp.2a" if="build.is.official" >
    <property name="cvs.ready.label" value="${cvs.ready.label.prefix}_${app.major.version}_${app.minor.version}_${app.build.id}" />
    <property name="cvs.branch.label" value="HEAD" /> <!-- default to a trunk/stable build -->
    <echo message="CVS branch label: ${cvs.branch.label}" />
    <echo message="release version (CVS ready label): ${cvs.ready.label}" />
  </target>

  <target name="-timestamp.4" depends="init, build.cvs.ready" if="build.is.official" >
  </target>

  <target name="-timestamp.5" depends="init" unless="build.is.dirty" >
    <copy overwrite="yes" todir="${core.srcgen.out.dir}" >
      <fileset dir="${core.data.dir}" includes="**/*.java" />
      <filterset>
        <filter token="APP_MAJOR_VERSION" value='*/ ${app.major.version}; // ' />
        <filter token="APP_MINOR_VERSION" value='*/ ${app.minor.version}; // ' />
        <filter token="APP_BUILD_ID" value='*/ ${app.build.id}; // ' />
        <filter token="APP_BUILD_RELEASE_TAG" value='*/ "${app.build.release.tag}"; // ' />
        <filter token="APP_BUILD_DATE" value='*/ "${app.build.date}"; // ' />
        <filter token="APP_BUG_REPORT_LINK" value='*/ "${app.bug.report.link}"; // ' />
        <filter token="APP_HOME_SITE_LINK" value='*/ "${app.home.site.link}"; // ' />
      </filterset>
    </copy>
    <copy overwrite="yes" file="${core.data.dir}/MANIFEST.MF" todir="${temp.dir}" >
      <filterset>
        <filter token="JDK_ID" value="JDK_${ant.java.version}" />
        <filter token="BUILD_USER_NAME" value="${user.name} on ${os.name}:${os.version}:${os.arch}" />
        
        <filter token="APP_NAME" value="${app.short.name}" />
        <filter token="APP_MAJOR_VERSION" value="${app.major.version}" />
        <filter token="APP_MINOR_VERSION" value="${app.minor.version}" />
        <filter token="APP_BUILD_ID" value="${app.build.id}" />
        <filter token="APP_BUILD_RELEASE_TAG" value="${app.build.release.tag}" />
        <filter token="APP_BUILD_DATE" value="${app.build.date}" />
        <filter token="APP_BUG_REPORT_LINK" value="${app.bug.report.link}" />
        <filter token="APP_HOME_SITE_LINK" value="${app.home.site.link}" />
      </filterset>
    </copy>
  </target>

  <target name="-pre-compile" depends="init, timestamp" >
  </target>

  <!-- ============================================================== -->
  <!-- compilation targets: -->
  <!-- ============================================================== -->

  <target name="compile" depends="init, core.compile, ant.compile, tools.compile" />

  <!-- ========================== -->
  <!-- core module: -->

  <target name="core.bootstrap.compile" depends="init, -pre-compile" >
    <javac destdir="${core.classes.out.dir}"
           debug="${build.debug}"
           deprecation="${build.deprecation}"
           target="${build.target}"
           bootclasspathref="boot.j2se.12.classpath"
           extdirs="${ext.j2se.12.classpath}"
           classpathref="core.classpath"
    >
      <!-- include IAppVersion.java: -->
      <src path="${core.srcgen.out.dir}" />

      <!-- classes used by core.src.java12.dir sources: -->
      <src path="${core.src.java12.dir}" />
      <include name="**/util/Property.java" />
      <include name="**/IAppConstants.java" />
    </javac>
  </target>

  <target name="core.java14.compile" depends="init, core.bootstrap.compile" >
    <javac destdir="${core.classes.out.dir}"
           debug="${build.debug}"
           deprecation="${build.deprecation}"
           target="${build.target}"
           bootclasspathref="boot.j2se.14.classpath"
           extdirs="${ext.j2se.14.classpath}"
           classpathref="core.classpath"
    >
      <src path="${core.src.java14.dir}" />
    </javac>
  </target>

  <target name="core.java13.compile" depends="init, core.java14.compile" >
    <javac destdir="${core.classes.out.dir}"
           debug="${build.debug}"
           deprecation="${build.deprecation}"
           target="${build.target}"
           bootclasspathref="boot.j2se.13.classpath"
           extdirs="${ext.j2se.13.classpath}"
           classpathref="core.classpath"
    >
      <src path="${core.src.java13.dir}" />
    </javac>
  </target>

  <!-- the bulk of core compilation: -->
  <target name="core.compile" depends="init, core.java13.compile" >
    <javac destdir="${core.classes.out.dir}"
           debug="${build.debug}"
           deprecation="${build.deprecation}"
           target="${build.target}"
           bootclasspathref="boot.j2se.12.classpath"
           extdirs="${ext.j2se.12.classpath}"
           classpathref="core.classpath"
    >
      <src path="${core.src.java12.dir}" />
      <exclude name="**/util/Property.java" />
      <exclude name="**/IAppConstants.java" />
    </javac>
  </target>

  <!-- ========================== -->
  <!-- tools module: -->

  <target name="tools.compile" depends="init, core.compile" >
    <javac destdir="${tools.classes.out.dir}"
           debug="${build.debug}"	
           deprecation="${build.deprecation}"
           target="${build.target}"
           bootclasspathref="boot.j2se.14.classpath"
           extdirs="${ext.j2se.14.classpath}"
           classpathref="tools.classpath"
    >
      <src path="${tools.src.dir}" />
    </javac>
  </target>

  <!-- ========================== -->
  <!-- ant module: -->

  <target name="ant.15.compile" depends="init, core.compile" >
    <javac destdir="${ant.classes.out.dir}"
           debug="${build.debug}"
           deprecation="${build.deprecation}"
           target="${build.target}"
           bootclasspathref="boot.j2se.12.classpath"
           extdirs="${ext.j2se.12.classpath}"
           classpathref="ant.15.classpath"
    >
      <src path="${ant.src.ant15.dir}" />
    </javac>
  </target>

  <!-- the bulk of ant compilation: -->
  <target name="ant.compile" depends="init, core.compile, ant.15.compile" >
    <javac destdir="${ant.classes.out.dir}"
           debug="${build.debug}"
           deprecation="${build.deprecation}"
           target="${build.target}"
           bootclasspathref="boot.j2se.12.classpath"
           extdirs="${ext.j2se.12.classpath}"
           classpathref="ant.14.classpath"
    >
      <src path="${ant.src.ant14.dir}" />
    </javac>
  </target>


  <!-- ============================================================== -->
  <!-- packaging targets: -->
  <!-- ============================================================== -->

  <target name="package" depends="init, core.package, ant.package" />

  <!-- ========================== -->
  <!-- run tools: -->
  
  <target name="rtclosure.gen" depends="init, compile" >
    <property name="rtclosure.resource" value="com/vladium/emma/rt/RTExitHook.closure" />
    <property name="rtclosure.classpath" refid="core.classpath" />

    <java classname="com.vladium.tools.ClassDep"
          classpathref="tools.classpath"
    >
      <arg value="${rtclosure.classpath}" />
      <arg value="${core.res.out.dir}/${rtclosure.resource}" />
      <arg value="com.vladium.emma.rt.RTExitHook" />
      <arg value="com.vladium.emma.data.CoverageData" />
    </java>
  </target>

  <!-- ========================== -->
  <!-- core module: -->

  <target name="core.package"  depends="init, core.compile, rtclosure.gen" >
    <jar jarfile="${out.dir}/${app.short.name}.jar"
         manifest="${temp.dir}/MANIFEST.MF"
         compress="true"
         index="false"
     >
      <!-- classes: -->
      <fileset dir="${core.classes.out.dir}" includes="**/*.class" />
      <!-- classloader resources: -->
      <fileset dir="${core.res.dir}" excludes="**/*.exclude" />
      <fileset dir="${core.res.out.dir}" excludes="**/*.exclude" />
      <manifest>
        <attribute name="Main-Class" value="${app.short.name}run" />
      </manifest>
    </jar>
  </target>

  <!-- ========================== -->
  <!-- ant module: -->

  <target name="ant.package"  depends="init, ant.compile" >
    <jar jarfile="${out.dir}/${app.short.name}_ant.jar"
         manifest="${temp.dir}/MANIFEST.MF"
         compress="true"
         index="false"
     >
      <!-- classes: -->
      <fileset dir="${ant.classes.out.dir}" includes="**/*.class" />
      <!-- classloader resources: -->
      <fileset dir="${ant.res.dir}" excludes="**/*.exclude" />
      <manifest>
        <attribute name="Main-Class" value="com.vladium.${app.short.name}.ANTMain" />
      </manifest>
    </jar>
  </target>

  <!-- ============================================================== -->
  <!-- distribution targets: -->
  <!-- ============================================================== -->

  <target name="dist" depends="init, core.dist, ant.dist" />

  <!-- ========================== -->
  <!-- core module: -->
  <target name="core.dist" depends="init, core.package" >
    <copy file="${out.dir}/${app.short.name}.jar" todir="${dist.dir}" />
  </target>

  <!-- ========================== -->
  <!-- ant module: -->
  <target name="ant.dist" depends="init, ant.package" >
    <copy file="${out.dir}/${app.short.name}_ant.jar" todir="${dist.dir}" />
  </target>

  <!-- ============================================================== -->
  <!-- file release targets: -->
  <!-- ============================================================== -->

  <target name="publish.release" depends="init, release, publish.property.check, release.lib, release.full, release.src" >
  </target>

  <target name="publish.stable" depends="init, stable, publish.property.check, release.lib" >
    <fail unless="file.release.label">need ${file.release.label}</fail>
  </target>
	
  <target name="publish.property.check" depends="init" >
    <fail unless="file.release.label">property ${file.release.label} must be set</fail>
    <fail unless="docs.dist.dir">property ${docs.dist.dir} must be set</fail>
    <property name="publish.ok" value="true" />
  </target> 


  <target name="release.lib" depends="init" if="publish.ok" >
    <!-- lib distribution: -->
    <zip destfile="${release.dir}/${app.short.name}${file.release.prefix}-${file.release.label}-lib.zip"
         basedir="${dist.dir}"
         includes="*.jar"
    />
  </target>

  <target name="release.src" depends="init" if="publish.ok" >
    <!-- source files: --> 
    <zip destfile="${release.dir}/${app.short.name}-${file.release.label}-src.zip" >
      <zipfileset prefix="${app.short.name}-${file.release.label}"
                  dir="${basedir}"
                  includes="${tools}/**, ${core}/**, ${ant}/**, ${lib}/**"
                  excludes="*/CVS/*"
      />
      <!-- license, build script and instructions, etc: --> 
      <zipfileset prefix="${app.short.name}-${file.release.label}"
                  dir="${basedir}"
                  includes="*.txt, *.xml, *.html, *.properties"
                  excludes="build.properties"
      />
    </zip>
  </target>

  <target name="release.full" depends="init" if="publish.ok" >
    <zip destfile="${release.dir}/${app.short.name}-${file.release.label}.zip" >
      <!-- license: -->
      <zipfileset prefix="${app.short.name}-${file.release.label}"
                  dir="${basedir}/"
                  includes="cpl*.html"
      />
      <!-- examples and related instructions: -->
      <zipfileset prefix="${app.short.name}-${file.release.label}"
                  dir="${basedir}/install/data"
      />
      <!-- lib distribution: -->
      <zipfileset prefix="${app.short.name}-${file.release.label}/lib"
                  dir="${dist.dir}"
                  includes="*.jar"
      />
      <!-- doc distribution: -->
      <zipfileset prefix="${app.short.name}-${file.release.label}/docs"
                  dir="${docs.dist.dir}/docs"
      />
    </zip>
  </target>


  <!-- ============================================================== -->
  <!-- CVS targets: -->
  <!-- ============================================================== -->

  <target name="build.cvs.ready" if="cvs.ready.label">
    <cvs failonerror="yes" output="${out.dir}/cvs.txt" error="${out.dir}/cvs.error.txt"
         command="-t rtag -r ${cvs.branch.label} -F -a ${cvs.ready.label} ${app.short.name}" />
  </target>

  <target name="build.cvs.unready" if="cvs.ready.label">
    <cvs failonerror="yes" output="${out.dir}/cvs.txt" error="${out.dir}/cvs.error.txt"
         command="-t rtag -r ${cvs.branch.label} -d -a ${cvs.ready.label} ${app.short.name}" />
  </target>

</project>
<!-- ========= END OF FILE ========================================== -->