-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.xml
More file actions
530 lines (455 loc) · 17.8 KB
/
build.xml
File metadata and controls
530 lines (455 loc) · 17.8 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
<!--
FILE: build.xml
AUTHOR: Peter Hollemans
DATE: 2004/03/16
CoastWatch Software Library and Utilities
Copyright (c) 2004 National Oceanic and Atmospheric Administration
All rights reserved.
Developed by: CoastWatch / OceanWatch
Center for Satellite Applications and Research
http://coastwatch.noaa.gov
For conditions of distribution and use, see the accompanying
license.txt file.
-->
<project name="cwutils" default="jar">
<!-- Setup global properties -->
<!-- *********************** -->
<property file="build.number" prefix="current"/>
<property file="cwutils.properties"/>
<property file="${password.file}"/>
<!-- Define tasks -->
<!-- ************ -->
<!-- This is for the install task that builds packages. -->
<taskdef
name="install4j"
classname="com.install4j.Install4JTask"
classpath="${install4j.dir}/bin/ant.jar"/>
<!-- These are the contrib tasks. -->
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<!-- Define Java compile classpath -->
<!-- ***************************** -->
<path id="cp">
<!-- The main libraries used by the code. -->
<fileset dir="lib/java" includes="**/*.jar,**/*.zip"/>
<pathelement location="${install4j.dir}/resource/i4jruntime.jar"/>
</path>
<!-- Add to default excludes -->
<!-- *********************** -->
<defaultexcludes add="**/.xvpics,**/.xvpics/**"/>
<!-- Define main compile targets -->
<!-- *************************** -->
<!-- Check if jar is current vs sources/resources -->
<uptodate property="jar.uptodate" targetfile="lib/java/cwutils.jar">
<srcfiles dir="src" includes="**/*.java"/>
<srcfiles dir="resources" includes="**/*"/>
</uptodate>
<target name="compile" description="Compiles main Java classes">
<depend srcdir="src" destdir="classes"/>
<mkdir dir="classes"/>
<javac srcdir="src" destdir="classes" classpathref="cp"
debug="on" deprecation="on" includeantruntime="false">
<compilerarg line="${javac.args}"/>
<!-- <compilerarg value="-Xlint:unchecked"/> -->
</javac>
</target>
<target name="write-version" unless="jar.uptodate">
<tstamp>
<format property="current.time" pattern="yyyyMMdd_HHmmss"/>
</tstamp>
<echo file="resources/version.properties"
message="cwutils.version=${version.full} ${current.time}${line.separator}"/>
</target>
<target name="jar" depends="compile,write-version" unless="jar.uptodate"
description="Builds cwutils jar and bumps build number">
<buildnumber/>
<jar destfile="lib/java/cwutils.jar">
<fileset dir="classes"/>
<fileset dir="resources"/>
</jar>
<echo>Built jar with version ${version.full} ${current.time}</echo>
<echo>Build number bumped to ${build.number} for next build</echo>
</target>
<!-- No-op when up-to-date -->
<target name="classes" depends="jar">
<echo message="Jar is up to date; skipping rebuild" if="jar.uptodate"/>
</target>
<!-- Define source and API targets -->
<!-- ***************************** -->
<target name="source"
description="Creates Java and C source code ZIP file">
<zip destfile="src.zip">
<zipfileset dir="src" prefix="src"/>
</zip>
</target>
<target name="api" depends="compile"
description="Creates Java API documentation">
<delete dir="doc/api"/>
<javadoc
sourcepath="src"
destdir="doc/api"
classpathref="cp"
overview="src/overview.html"
windowtitle="CoastWatch Utilities v${version}"
doctitle="CoastWatch Software Library and Utilities v${version} API Specification"
header="CoastWatch Utils v${version}"
link="https://docs.oracle.com/en/java/javase/11/docs/api">
<bottom><![CDATA[<script>if (typeof useModuleDirectories !== 'undefined') { useModuleDirectories = false; }</script>]]></bottom>
<arg line="--allow-script-in-comments"/>
<packageset dir="src"/>
<arg line="-Xmaxwarns 10"/>
</javadoc>
</target>
<target name="guide-version">
<echo
file="doc/users_guide/version.tex"
message="\newcommand{\version}{${version}}"/>
</target>
<target name="doc" depends="api,guide-version"
description="Creates Java API documentation, tool manual pages, and user's guide in doc/">
<delete dir="doc/tools"/>
<delete dir="doc/man"/>
<exec executable="${basedir}/scripts/make_docs.sh" dir="doc" failonerror="true">
<arg line="${version}"/>
</exec>
</target>
<target name="guide" depends="guide-version"
description="Creates user's guide in doc/users_guide/">
<exec executable="pdflatex" dir="doc/users_guide">
<arg line="cwutils_users_guide.tex"/>
</exec>
</target>
<target name="test-man" depends="doc"
description="Builds and copies the CW utilities man pages into the install directory">
<copy todir="${install.dir}/doc/man">
<fileset dir="doc/man"/>
</copy>
</target>
<target name="copy-man"
description="Copies the CW utilities man pages into the install directory">
<copy todir="${install.dir}/doc/man">
<fileset dir="doc/man"/>
</copy>
</target>
<target name="copy-help"
description="Copies the CW utilities in-application help pages into the install directory">
<copy todir="${install.dir}/doc/help">
<fileset dir="doc/help"/>
</copy>
</target>
<target name="api-zip"
description="Creates Java API ZIP file in doc/">
<zip destfile="doc/api.zip">
<zipfileset dir="doc/api" prefix="api"/>
</zip>
</target>
<target name="all"
description="Combines jar, doc, source, and api-zip targets"
depends="jar,doc,source,api-zip"/>
<!-- Define package targets -->
<!-- ********************** -->
<property name="builds.default" value="linux64,linux64.novm,windows64,macosx64"/>
<property name="builds.all" value="linux64,linux64.novm,linux64.deb,windows64,macosx64"/>
<property name="build.id.linux64" value="288"/>
<property name="build.id.linux64.novm" value="710"/>
<property name="build.id.linux64.deb" value="1680"/>
<property name="build.id.windows64" value="278"/>
<property name="build.id.windows64.zip" value="1656"/>
<property name="build.id.macosx64" value="276"/>
<property name="build.id.macosx64.tgz" value="528"/>
<target name="packages-help" description="Lists packages available to build">
<echo>Default build set: ${builds.default}</echo>
<echo>All packages: ${builds.all}</echo>
</target>
<target name="mac"
description="Creates the macOS X .dmg package">
<antcall target="packages">
<param name="builds" value="macosx64"/>
</antcall>
</target>
<target name="windows"
description="Creates the Windows .exe package">
<antcall target="packages">
<param name="builds" value="windows64"/>
</antcall>
</target>
<target name="linux"
description="Creates the Linux .tar.gz package">
<antcall target="packages">
<param name="builds" value="linux64"/>
</antcall>
</target>
<target name="packages" depends="all"
description="Creates package files specified by ${builds}, or default set if no builds specified (-Dtag=true tags the build in git, -Dsign=true signs the packages)">
<!-- Check builds -->
<if>
<not><isset property="builds"/></not>
<then>
<property name="builds" value="${builds.default}"/>
</then>
</if>
<!-- Convert build names to build IDs -->
<echo message="Building packages for ${builds}"/>
<var name="build.ids" value=""/>
<for list="${builds}" param="build.name">
<sequential>
<!-- Set current build ID to append -->
<var name="build.id.current" value="${build.id.@{build.name}}"/>
<if>
<!-- Check build ID is known -->
<not><matches pattern="^[0-9]*$" string="${build.id.current}"/></not>
<then>
<echo message="No build ID found for @{build.name}, ignoring ..."/>
</then>
<!-- Add build ID to list -->
<else>
<if>
<not><equals arg1="${build.ids}" arg2=""/></not>
<then>
<var name="build.ids" value="${build.ids},"/>
</then>
</if>
<var name="build.ids" value="${build.ids}${build.id.current}"/>
</else>
</if>
<!-- Add build ID to list -->
</sequential>
</for>
<!-- Check if -Dsign=true was specified at the command line -->
<if>
<equals arg1="${sign}" arg2="true"/>
<then>
<property name="disable.signing" value="false"/>
<echo message="Package signing and Apple notarization is ENABLED"/>
</then>
<else>
<property name="disable.signing" value="true"/>
<echo message="Package signing and Apple notarization is DISABLED"/>
</else>
</if>
<!-- Call install4j task -->
<install4j
projectfile="cwutils.install4j"
release="${version.full}"
buildids="${build.ids}"
disableSigning="${disable.signing}"
disableNotarization="${disable.signing}"
macKeystorePassword="${mac.keystore.password}"
winKeystorePassword="${win.keystore.password}"
verbose="true">
<vmParameter value="-Xmx1024m"/>
<variable name="macKeystoreFile" value="${mac.keystore.file}"/>
<variable name="appleIssuerId" value="${install4j.apple.issuer.id}"/>
<variable name="appleKeyId" value="${install4j.apple.key.id}"/>
<variable name="applePrivateKey" value="${install4j.apple.private.key}"/>
</install4j>
<!-- Tag the package version -->
<if>
<equals arg1="${tag}" arg2="true"/>
<then>
<echo message="Tagging package with version ${version.full} under git"/>
<exec executable="git">
<arg line="tag ${version.full}"/>
</exec>
</then>
</if>
</target>
<target name="upload"
description="Uploads the latest packages to the Terrenus server">
<exec executable="${pkg.dir}/send.sh" dir="${pkg.dir}"/>
<!-- <exec executable="${pkg.dir}/check.sh" dir="${pkg.dir}"/> -->
</target>
<!-- Define cleanup targets -->
<!-- ********************** -->
<target name="clean"
description="Cleans up compiled Java classes, source ZIP, and documentation">
<delete dir="classes"/>
<delete dir="doc/api"/>
<delete verbose="true" quiet="true" includeemptydirs="true">
<fileset file="lib/java/cwutils.jar"/>
<fileset file="src.zip"/>
<fileset dir="doc/tools"/>
<fileset dir="doc/man"/>
<fileset dir="doc/html"/>
<fileset dir="doc">
<include name="api.zip"/>
<include name="cwutils_ug_*.pdf"/>
</fileset>
<fileset dir="doc/users_guide" excludes="*.tex,*.bib,figures/*,icons/*"/>
<fileset file="doc/users_guide/manual_pages.tex"/>
<fileset dir="data/noaa/coastwatch/tools/test">
<include name="test-*"/>
</fileset>
</delete>
</target>
<target name="clean-packages"
description="Deletes all packages">
<delete verbose="true" quiet="true">
<fileset dir="${pkg.dir}" includes="cwutils*.*"/>
<fileset file="${pkg.dir}/output.txt"/>
<fileset file="${pkg.dir}/md5sums"/>
<fileset file="${pkg.dir}/updates.xml"/>
</delete>
</target>
<target name="clean-doc"
description="Deletes all documentation">
<delete dir="doc/api"/>
<delete verbose="true" quiet="true" includeemptydirs="true">
<fileset dir="doc/tools"/>
<fileset dir="doc/man"/>
<fileset dir="doc">
<include name="api.zip"/>
<include name="cwutils_ug_*.pdf"/>
</fileset>
<fileset dir="doc/users_guide" excludes="*.tex,*.bib,figures/*,icons/*"/>
<fileset file="doc/users_guide/manual_pages.tex"/>
</delete>
</target>
<!-- Define test targets -->
<!-- ******************* -->
<target name="test-jar" depends="jar"
description="Copies the CW utilities jar file into the install directory for direct in-situ testing">
<copy file="lib/java/cwutils.jar" todir="${install.dir}/lib/java"/>
</target>
<path id="test.class.path">
<fileset dir="lib/java" includes="**/*.jar,**/*.zip"/>
<pathelement location="data"/>
<pathelement location="extensions"/>
<pathelement location="doc/help"/>
<pathelement location="${java.home}/lib/plugin.jar"/>
<pathelement location="${install4j.dir}/resource/i4jruntime.jar"/>
</path>
<!-- LAF arguments from the command line -Dlaf value -->
<property name="laf" value="${default.laf}"/>
<condition property="laf.args" value="-Dswing.defaultlaf=com.formdev.flatlaf.FlatLightLaf">
<equals arg1="${laf}" arg2="flat"/>
</condition>
<condition property="laf.args" value="-Dswing.defaultlaf=com.formdev.flatlaf.FlatDarkLaf">
<equals arg1="${laf}" arg2="flat-dark"/>
</condition>
<condition property="laf.args" value="-Dapple.laf.useScreenMenuBar=true">
<equals arg1="${laf}" arg2="mac"/>
</condition>
<condition property="laf.args" value="-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dapple.awt.showGrowBox=false">
<equals arg1="${laf}" arg2="gtk"/>
</condition>
<condition property="laf.args" value="-Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel -Dswing.metalTheme=steel -Dapple.awt.showGrowBox=false">
<equals arg1="${laf}" arg2="metal"/>
</condition>
<condition property="laf.args" value="-Dswing.defaultlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel -Dapple.awt.showGrowBox=false">
<equals arg1="${laf}" arg2="nimbus"/>
</condition>
<condition property="laf.args" value="-Dswing.defaultlaf=com.sun.java.swing.plaf.motif.MotifLookAndFeel -Dapple.awt.showGrowBox=false">
<equals arg1="${laf}" arg2="motif"/>
</condition>
<if>
<not><isset property="laf.args"/></not>
<then>
<echo>Look and feel "${laf}" has no known configuration</echo>
<fail message="Aborting"/>
</then>
</if>
<property name="laf.args" value=""/>
<target name="test" depends="jar"
description="Tests the Java class ${class} by calling its main() method with arguments ${args}">
<property name="args" value=""/>
<echo>Testing with:</echo>
<echo> Class = ${class}</echo>
<echo> Look and feel ${laf} args = ${laf.args}</echo>
<echo> VM args = ${vm.args}</echo>
<echo> Test debug args = ${test.debug.args}</echo>
<echo> Command line args = ${args}</echo>
<java
classname="${class}"
classpathref="test.class.path"
fork="true">
<env key="${ld.var}" value="${basedir}/lib/native/${os.libs}"/>
<jvmarg line="${laf.args} ${vm.args} ${test.debug.args} -Djna.library.path='${basedir}/lib/native/${os.libs}' -ea:noaa.coastwatch..."/>
<arg line="${args}"/>
</java>
</target>
<target name="test-cdat"
description="Tests CDAT by calling its main() method with no arguments">
<antcall target="test">
<param name="class" value="noaa.coastwatch.tools.cdat"/>
<param name="args" value=""/>
</antcall>
</target>
<target name="test-cwmaster"
description="Tests cwmaster by calling its main() method with no arguments">
<antcall target="test">
<param name="class" value="noaa.coastwatch.tools.cwmaster"/>
<param name="args" value=""/>
</antcall>
</target>
<target name="test-info"
description="Tests the cwinfo tool by calling its main() method with arguments ${args}">
<antcall target="test">
<param name="class" value="noaa.coastwatch.tools.cwinfo"/>
</antcall>
</target>
<target name="test-tool"
description="Tests a CoastWatch tool named ${tool} by calling its main() method with arguments ${args}">
<antcall target="test">
<param name="class" value="noaa.coastwatch.tools.${tool}"/>
</antcall>
</target>
<target name="test-suite"
description="Runs the CoastWatch test suite by calling cwtoolstest">
<antcall target="test">
<param name="class" value="noaa.coastwatch.tools.cwtoolstest"/>
<param name="args" value=""/>
</antcall>
</target>
<target name="test-con"
description="Tests the Java GUI class ${contain} using the noaa.coastwatch.gui.TestContainer class">
<antcall target="test">
<param name="class" value="noaa.coastwatch.gui.TestContainer"/>
<param name="args" value="${contain}"/>
</antcall>
</target>
<target name="test-unit"
description="Runs the CoastWatch unit tests by running noaa.coastwatch.test.TestRunner">
<if>
<not><isset property="unit.tests"/></not>
<then>
<exec executable="scripts/find_testable.sh" outputproperty="unit.tests"/>
</then>
</if>
<antcall target="test">
<param name="class" value="noaa.coastwatch.test.TestRunner"/>
<param name="args" value="${unit.tests}"/>
</antcall>
</target>
<!-- Define branch targets -->
<!-- ********************* -->
<!--
Some other useful git commands:
git rm - removes a file from repository
git status - shows the status of adds/deletes/modifications
git tag - list tags performed
git tag -a LABEL - add a tag with label
git log - -pretty=oneline - simple log of commits
git push origin - push the new commits to the remote server
git log tag..master - print the log between tag and current
git push - -tags - push the tags to the remote
Web: https://github.com/phollemans/cwutils/compare/tag...master
-->
<target name="branch-list"
description="Lists the development branches">
<exec executable="git">
<arg line="branch -a"/>
</exec>
</target>
<target name="branch-delete"
description="Deletes the branch specified by ${branch}">
<exec executable="git">
<arg line="branch -d ${branch}"/>
</exec>
</target>
<target name="branch-log"
description="Shows a history of latest commits to the active branch">
<exec executable="git">
<arg line="log -n 10 --name-status"/>
</exec>
</target>
</project>