forked from jugne/stratigraphic-ranges
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
530 lines (430 loc) · 20.6 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
<project default="build" basedir=".">
<!-- Git code to pull from https://stackoverflow.com/questions/27442136/how-to-do-git-pull-through-build-xml-ant-task-->
<macrodef name = "git">
<attribute name = "command" />
<attribute name = "dir" default = "" />
<element name = "args" optional = "true" />
<sequential>
<echo message = "git @{command}" />
<exec executable = "git" dir = "@{dir}">
<arg value = "@{command}" />
<args/>
</exec>
</sequential>
</macrodef>
<macrodef name = "git-clone-pull">
<attribute name = "repository" />
<attribute name = "dest" />
<sequential>
<git command = "clone">
<args>
<arg value = "@{repository}" />
<arg value = "@{dest}" />
</args>
</git>
<git command = "pull" dir = "@{dest}" />
</sequential>
</macrodef>
<!-- Source, JUnit test code and jar library locations. -->
<property name="src" location="src"/>
<property name="test" location="test"/>
<property name="lib" location="lib"/>
<!-- Location to check for local copy of beast2 repository -->
<property name="beastDir" location="../beast2"/>
<property name="BeastFXDir" location="../BeastFX"/>
<!-- Location to check for local copy of BEASTLabs repository -->
<property name="beastLabsDir" location="../BEASTLabs"/>
<!-- Location to check for local copy of BEASTLabs repository -->
<property name="saDir" location="../sampled-ancestors"/>
<!-- Location to check for local copy of BDSKY repository-->
<property name="skyDir" location="../bdsky"/>
<!-- BEAST 2 currently uses Java 17 -->
<property name="sourceVersion" value="17"/>
<property name="targetVersion" value="17"/>
<!-- Directories necessary for all BEAST 2 packages -->
<property name="doc" location="doc"/>
<property name="examples" location="examples"/>
<property name="fxtemplates" location="fxtemplates"/>
<!-- BEAST branch and version to build against
(only different for version tags because of
a Github peculiarity) -->
<property name="beast-branch" value="master"/>
<property name="beast-version" value="master"/>
<!-- Names of temporary build/test directories -->
<property name="build" location="build"/>
<property name="build-lib" location="build-lib"/>
<property name="build-test" location="build-test"/>
<property name="test-reports" location="test-reports"/>
<property name="dist" location="dist"/>
<property name="pack" location="${dist}/package"/>
<!-- Prepare for compilation -->
<target name="init">
<available file="version.xml" property="versionAvailable"/>
<fail unless="versionAvailable">
** Required file version.xml does not exist. **
If this is a new project, run "ant skeleton" from
the command line to create the files required for
your BEAST 2 package.
</fail>
<!-- Read package name and version from xml file -->
<xmlproperty file="version.xml" prefix="fromVersionFile" />
<property name="projName" value="${fromVersionFile.package(name)}" />
<property name="projVersion" value="${fromVersionFile.package(version)}" />
<mkdir dir="${build}"/>
<mkdir dir="${build-lib}"/>
<mkdir dir="${dist}"/>
<copy todir="${build-lib}" failonerror="false">
<fileset dir="${lib}" includes="*.jar"/>
</copy>
</target>
<!-- Get beast -->
<target name="find-beast" depends="init">
<available file="${beastDir}" property="localBeastAvailable"/>
</target>
<target name="build-remote-beast" depends="find-beast" unless="localBeastAvailable">
<echo>No local copy of the beast2 source found at ${beastDir}.</echo>
<echo>Compiling against version ${beast-version} from GitHub.</echo>
<property name="build-beast" location="build-beast"/>
<mkdir dir="${build-beast}"/>
<get src="https://github.com/CompEvol/beast2/archive/${beast-branch}.zip" dest="${build-beast}/beast.zip"/>
<unzip src="${build-beast}/beast.zip" dest="${build-beast}"/>
<mkdir dir="${build-beast}/beast2-${beast-version}/build"/>
<javac target="${targetVersion}" source="${sourceVersion}"
srcdir="${build-beast}/beast2-${beast-version}/src"
destdir="${build-beast}/beast2-${beast-version}/build" includeantruntime="false">
<classpath>
<fileset dir="${build-beast}/beast2-${beast-version}/lib" includes="*.jar"/>
</classpath>
</javac>
<jar jarfile="${build-lib}/beast2.jar" basedir="${build-beast}/beast2-${beast-version}/build" />
<copy todir="${build-lib}">
<fileset dir="${build-beast}/beast2-${beast-version}/lib" includes="*.jar"/>
</copy>
<delete dir="${build-beast}" />
</target>
<target name="build-local-beast" depends="find-beast" if="localBeastAvailable">
<echo>Compiling against beast2 source found at ${beastDir}.</echo>
<property name="build-beast" location="build-beast"/>
<mkdir dir="${build-beast}"/>
<javac target="${targetVersion}" source="${sourceVersion}"
srcdir="${beastDir}/src"
destdir="${build-beast}" includeantruntime="false">
<classpath>
<fileset dir="${beastDir}/lib" includes="*.jar"/>
</classpath>
</javac>
<javac target="${targetVersion}" source="${sourceVersion}"
srcdir="${beastDir}/test"
destdir="${build-beast}" includeantruntime="false">
<classpath>
<fileset dir="${beastDir}/lib" includes="*.jar"/>
<fileset dir="${beastDir}/lib/junit" includes="*.jar"/>
</classpath>
</javac>
<javac target="${targetVersion}" source="${sourceVersion}"
srcdir="${BeastFXDir}/src"
destdir="${build-beast}" includeantruntime="false">
<classpath>
<fileset dir="${beastDir}/lib" includes="*.jar"/>
<fileset dir="${beastDir}/lib/junit" includes="*.jar"/>
<fileset dir="${BeastFXDir}/locallib" includes="*.jar"/>
</classpath>
</javac>
<jar jarfile="${build-lib}/beast2.jar" basedir="${build-beast}" />
<copy todir="${build-lib}">
<fileset dir="${beastDir}/lib" includes="*.jar"/>
</copy>
<delete dir="${build-beast}" />
</target>
<target name="build-beast" depends="build-local-beast,build-remote-beast"/>
<!-- Get BEASTLabs -->
<target name="find-beastlabs" depends="init">
<available file="${beastLabsDir}" property="localBeastLabsAvailable"/>
</target>
<target name="build-remote-beastlabs" depends="find-beastlabs" unless="localBeastLabsAvailable">
<echo>No local copy of the BEASTLabs source found at ${beastLabsDir}.</echo>
<echo>Compiling against version ${beast-version} from GitHub.</echo>
<property name="build-beastlabs" location="build-beastlabs"/>
<mkdir dir="${build-beastlabs}"/>
<!-- <echo>Clone BeastFX.</echo>
<git-clone-pull repository="https://github.com/CompEvol/BeastFX.git" dest="BeastFX"/> -->
<get src="https://github.com/beast2-dev/BEASTLabs/archive/master.zip" dest="${build-beastlabs}/beastlabs.zip"/>
<unzip src="${build-beastlabs}/beastlabs.zip" dest="${build-beastlabs}"/>
<mkdir dir="${build-beastlabs}/BEASTLabs-master/build"/>
<javac target="${targetVersion}" source="${sourceVersion}"
srcdir="${build-beastlabs}/BEASTLabs-master/src"
destdir="${build-beastlabs}/BEASTLabs-master/build" includeantruntime="false">
<classpath>
<fileset dir="${build-beastlabs}/BEASTLabs-master/lib" includes="*.jar"/>
<fileset dir="${build-lib}" includes="*.jar"/>
</classpath>
</javac>
<jar jarfile="${build-lib}/beastlabs.jar" basedir="${build-beastlabs}/BEASTLabs-master/build" />
<copy todir="${build-lib}">
<fileset dir="${build-beastlabs}/BEASTLabs-master/lib" includes="*.jar"/>
</copy>
<delete dir="${build-beastlabs}" />
</target>
<target name="build-local-beastlabs" depends="find-beastlabs" if="localBeastLabsAvailable">
<echo>Compiling against local BEASTLabs source found at ${beastLabsDir}.</echo>
<property name="build-beastlabs" location="build-beastlabs"/>
<mkdir dir="${build-beastlabs}"/>
<javac target="${targetVersion}" source="${sourceVersion}"
srcdir="${beastLabsDir}/src"
destdir="${build-beastlabs}" includeantruntime="false">
<include name="beastlabs/**/**" />
<classpath>
<fileset dir="${beastLabsDir}/lib" includes="*.jar"/>
<fileset dir="${build-lib}" includes="*.jar"/>
</classpath>
</javac>
<jar jarfile="${build-lib}/beastlabs.jar" basedir="${build-beastlabs}" />
<copy todir="${build-lib}">
<fileset dir="${beastLabsDir}/lib" includes="*.jar"/>
</copy>
<delete dir="${build-beastlabs}" />
</target>
<target name="build-beastlabs" depends="build-local-beastlabs,build-remote-beastlabs"/>
<target name="find-sky" depends="init">
<available file="${skyDir}" property="localSkyAvailable"/>
</target>
<target name="build-remote-sky" depends="find-sky" unless="localSkyAvailable">
<echo>No local copy of the sampled ancestors source found at ${saDir}.</echo>
<echo>Compiling against version ${beast-version} from GitHub.</echo>
<property name="build-sky" location="build-sky"/>
<mkdir dir="${build-sky}"/>
<git-clone-pull repository="https://github.com/BEAST2-Dev/bdsky.git" dest="${build-sky}"/>
<mkdir dir="${build-sky}/bdsky/build"/>
<javac target="${targetVersion}" source="${sourceVersion}"
srcdir="${build-sa}/bdsky/src"
destdir="${build-sky}/bdsky/build" includeantruntime="false">
<classpath>
<fileset dir="${build-sky}/sa/lib" includes="*.jar"/>
<fileset dir="${build-lib}" includes="*.jar"/>
</classpath>
</javac>
<jar jarfile="${build-lib}/bdsky.jar" basedir="${build-sky}/bdsky/build" />
<copy todir="${build-lib}">
<fileset dir="${build-sky}/sky/lib" includes="*.jar"/>
</copy>
<delete dir="${build-sky}" />
</target>
<target name="build-local-sky" depends="find-sky" if="localSkyAvailable">
<echo>Compiling against local skyline source found at ${skyDir}.</echo>
<property name="build-sky" location="build-sky"/>
<mkdir dir="${build-sky}"/>
<javac target="${targetVersion}" source="${sourceVersion}"
srcdir="${skyDir}/src"
destdir="${build-sky}" includeantruntime="false">
<include name="bdsky/**/**" />
<classpath>
<fileset dir="${build-lib}" includes="*.jar"/>
</classpath>
</javac>
<jar jarfile="${build-lib}/bdsky.jar" basedir="${build-sky}" />
<delete dir="${build-sky}" />
</target>
<target name="find-sa" depends="init">
<available file="${saDir}" property="localSaAvailable"/>
</target>
<target name="build-remote-sa" depends="find-sa" unless="localSaAvailable">
<echo>No local copy of the sampled ancestors source found at ${saDir}.</echo>
<echo>Compiling against version ${beast-version} from GitHub.</echo>
<property name="build-sa" location="build-sa"/>
<mkdir dir="${build-sa}"/>
<get src="https://github.com/CompEvol/sampled-ancestors/releases/download/v2.1.0/SA.v2.1.0.zip" dest="${build-sa}/sa.zip"/>
<unzip src="${build-sa}/sa.zip" dest="${build-sa}"/>
<mkdir dir="${build-sa}/sa/build"/>
<javac target="${targetVersion}" source="${sourceVersion}"
srcdir="${build-sa}/sa/src"
destdir="${build-sa}/sa/build" includeantruntime="false">
<classpath>
<fileset dir="${build-sa}/sa/lib" includes="*.jar"/>
<fileset dir="${build-lib}" includes="*.jar"/>
</classpath>
</javac>
<jar jarfile="${build-lib}/sa.jar" basedir="${build-sa}/sa/build" />
<copy todir="${build-lib}">
<fileset dir="${build-sa}/sa/lib" includes="*.jar"/>
</copy>
<delete dir="${build-sa}" />
</target>
<target name="build-local-sa" depends="find-sa" if="localSaAvailable">
<echo>Compiling against local SA source found at ${saDir}.</echo>
<property name="build-sa" location="build-sa"/>
<mkdir dir="${build-sa}"/>
<javac target="${targetVersion}" source="${sourceVersion}"
srcdir="${saDir}/src"
destdir="${build-sa}" includeantruntime="false">
<include name="sa/**/**" />
<classpath>
<fileset dir="${build-lib}" includes="*.jar"/>
</classpath>
</javac>
<jar jarfile="${build-lib}/sa.jar" basedir="${build-sa}" />
<delete dir="${build-sa}" />
</target>
<target name="build-sky" depends="build-local-sky,build-remote-sky"/>
<target name="build-sa" depends="build-local-sa,build-remote-sa"/>
<!-- Compile -->
<target name="compile" depends="build-beast,build-beastlabs,build-sa,build-sky">
<javac target="${targetVersion}" source="${sourceVersion}" srcdir="${src}" destdir="${build}" includeantruntime="false">
<classpath>
<pathelement path=""/>
<fileset dir="${build-lib}" includes="*.jar"/>
</classpath>
</javac>
</target>
<target name="copy-resources" depends="compile">
<copy todir="${build}">
<fileset dir="${src}"
includes="**/*.png" />
</copy>
</target>
<!-- Prepare for unit test compilation -->
<target name="init-test" depends="init">
<mkdir dir="${build-test}"/>
<mkdir dir="${test-reports}"/>
</target>
<!-- Compile unit tests -->
<target name="compile-test" depends="init-test,compile,copy-resources">
<javac target="${targetVersion}" source="${sourceVersion}" srcdir="${test}" destdir="${build-test}" includeantruntime="false">
<classpath>
<pathelement path="${build}" />
<fileset dir="${build-lib}" includes="*.jar"/>
</classpath>
</javac>
</target>
<!-- Run unit tests -->
<target name="test" depends="compile-test">
<junit printsummary="yes" failureproperty="testFailed" showoutput="true">
<classpath>
<pathelement path="${build}" />
<pathelement path="${build-test}" />
<fileset dir="${build-lib}" includes="*.jar"/>
</classpath>
<batchtest fork="yes" todir="${test-reports}">
<fileset dir="${test}">
<include name="**/*Test.java"/>
</fileset>
<formatter type="plain"/>
<!--formatter type="plain" usefile="false"/--> <!-- to screen -->
</batchtest>
</junit>
<fail if="testFailed" status="1" message="Unit test failed."/>
</target>
<!-- Create BEAST 2 package -->
<target name="build" depends="compile,copy-resources">
<property name="fullName" value="${projName}.v${projVersion}"/>
<mkdir dir="${pack}"/>
<mkdir dir="${pack}/examples"/>
<mkdir dir="${pack}/fxtemplates"/>
<mkdir dir="${pack}/lib"/>
<mkdir dir="${pack}/doc"/>
<jar jarfile="${pack}/${fullName}.src.jar" basedir="${src}" />
<mkdir dir="${lib}" />
<copy todir="${pack}/lib">
<fileset dir="${lib}" includes="*.jar" />
</copy>
<jar jarfile="${pack}/lib/${fullName}.jar" basedir="${build}" />
<copy file="README.md" tofile="${pack}/README" />
<copy todir="${pack}">
<fileset dir="${lib}" includes="LICENSE*" />
</copy>
<mkdir dir="${examples}" />
<copy todir="${pack}/examples">
<fileset dir="${examples}" includes="**/*" />
</copy>
<mkdir dir="${fxtemplates}" />
<copy todir="${pack}/fxtemplates">
<fileset dir="${fxtemplates}" includes="*.xml" />
</copy>
<mkdir dir="${doc}" />
<copy todir="${pack}/doc">
<fileset dir="${doc}" includes="*.tex,*.doc,*.lyx,*.txt"/>
</copy>
<copy file="version.xml" todir="${pack}" />
<zip destfile="${dist}/${fullName}.zip" basedir="${pack}" />
<delete dir="${pack}"/>
<echo/>
<echo/>
<echo>** Package ${dist}/${fullName}.zip created successfuly! **</echo>
</target>
<!-- Revert to pristine state. -->
<target name="clean">
<delete dir="${build}" />
<delete dir="${build-lib}" />
<delete dir="${dist}" />
<delete dir="${build-test}" />
<delete dir="${test-reports}" />
</target>
<!-- Create skeleton package layout in current directory -->
<target name="skeleton">
<fail>
<condition>
<or>
<resourcecount when="gt" count="1">
<fileset dir="${basedir}"/>
</resourcecount>
<resourcecount when="gt" count="1">
<dirset dir="${basedir}"/>
</resourcecount>
</or>
</condition>
** This directory contains files besides the build script. **
You should run "ant skeleton" in a directory containing only the build script.
</fail>
<echo>===============================</echo>
<echo>Create skeleton BEAST 2 package</echo>
<echo>===============================</echo>
<echo/>
<echo>First, we need some information...</echo>
<echo/>
<basename property="defaultProjName" file="${basedir}"/>
<input addproperty="projName" defaultvalue="${defaultProjName}">Enter package name</input>
<input addproperty="license" defaultvalue="gpl3" validargs="gpl3,lgpl3,lgpl2.1,apache2">Select open source software license</input>
<input addproperty="projVersion" defaultvalue="1.0.0">Enter package version</input>
<input addproperty="beastVersionReq" defaultvalue="2.1.0">Enter minimum required BEAST 2 version</input>
<echo>Assembling files and directory structure...</echo>
<echo file="version.xml"><addon name="${projName}" version="${projVersion}">
<depends on="beast2" atleast="${beastVersionReq}"/>
<!-- Add other dependencies as necessary. -->
</addon>
</echo>
<echo file="README.md" message="README for my package.${line.separator}"/>
<condition property="licenseURL" value="https://www.gnu.org/licenses/gpl-3.0.txt">
<equals arg1="${license}" arg2="gpl3"/>
</condition>
<condition property="licenseURL" value="https://www.gnu.org/licenses/lgpl-3.0.txt">
<equals arg1="${license}" arg2="lgpl3"/>
</condition>
<condition property="licenseURL" value="https://www.gnu.org/licenses/lgpl-2.1.txt">
<equals arg1="${license}" arg2="lgpl2.1"/>
</condition>
<condition property="licenseURL" value="http://www.apache.org/licenses/LICENSE-2.0.txt">
<equals arg1="${license}" arg2="apache2"/>
</condition>
<get src="${licenseURL}" dest="COPYING"/>
<mkdir dir="${src}"/>
<mkdir dir="${test}"/>
<mkdir dir="${lib}"/>
<mkdir dir="${examples}"/>
<mkdir dir="${fxtemplates}"/>
<mkdir dir="${doc}"/>
<echo/>
<echo>Done.</echo>
<echo/>
<echo>The directory structure is as follows:</echo>
<echo>${src} - your java source goes here</echo>
<echo>${test} - your junit tests go here (You _are_ going to write, those, aren't you!)</echo>
<echo>${doc} - your documentation goes here</echo>
<echo>${examples} - your example XML scripts go here</echo>
<echo>${fxtemplates} - your BEAUti fxtemplates go here</echo>
<echo/>
<echo>To build your package, just type "ant" at the command line.</echo>
<echo/>
<echo>To run unit tests, type "ant test".</echo>
<echo/>
<echo>That's it! Happy coding!</echo>
</target>
</project>