-
Notifications
You must be signed in to change notification settings - Fork 48
/
build.xml
489 lines (424 loc) · 18.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
<project name="public-tools" default="zip-nojre">
<property name="min.ant.version" value="1.9.0" />
<antversion property="this.ant.version" atleast="${min.ant.version}" />
<fail message="The required minimum version of ant is ${min.ant.version}, you have ${ant.version}" unless="this.ant.version" />
<dirname property="public.tools.basedir" file="${ant.file.public-tools}"/>
<property name="tools.src.dir" location="${public.tools.basedir}/src"/>
<property name="tools.src.lib.dir" location="${public.tools.basedir}/lib"/>
<property name="tools.test.dir" location="${public.tools.basedir}/test"/>
<property name="tools.test.lib.dir" location="${public.tools.basedir}/testLib"/>
<property name="buildtools.dir" location="${public.tools.basedir}/buildLib"/> <!-- Libraries supporting the build process itself -->
<property name="dist.dir" location="${public.tools.basedir}/dist"/>
<property name="build.dir" location="${public.tools.basedir}/build"/>
<property name="build.src" location="${build.dir}/src"/>
<property name="build.test" location="${build.dir}/test"/>
<property name="build.junit" location="${build.dir}/junit"/>
<property name="build.text" location="${build.dir}/text"/>
<property name="build.executable" location="${build.dir}/executable"/>
<property name="build.misc" location="${build.dir}/misc"/>
<property name="build.sysclasspath" value="ignore"/>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${buildtools.dir}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<property name="product" value="RTG Tools" />
<property name="product.version" value="3.12.1" />
<property name="product.repo" value="RealTimeGenomics/rtg-tools" />
<property name="resources" value="tools" />
<property name="main.class" value="com.rtg.RtgTools" />
<property name="regression.update" value=""/> <!-- Empty means don't update nano-regression results -->
<!-- This must currently be built from the RTG fork of htsjdk -->
<property name="htsjdk.jar" value="sam-rtg-2.23.0.1.jar"/>
<!-- Define resource collections for compilation, running, etc -->
<!-- These jars are needed at run time -->
<fileset id="tools.runtime.libs" dir="${tools.src.lib.dir}">
<include name="${htsjdk.jar}" />
<include name="gzipfix.jar" />
<include name="RPlot.jar" />
<include name="velocity-1.7.jar" />
<include name="velocity-tools-generic.jar" />
<include name="commons-collections-3.2.1.jar" />
<include name="commons-lang-2.4.jar" />
<include name="commons-compress-1.4.1.jar" />
<include name="snappy-java-1.1.4.jar" />
<include name="json-simple-1.1.1.jar" />
<include name="js-20.2.0.jar" />
<include name="js-scriptengine-20.2.0.jar" />
<include name="graal-sdk-20.2.0.jar" />
<include name="regex-20.2.0.jar" />
<include name="truffle-api-20.2.0.jar" />
<include name="icu4j-67.1.jar" />
</fileset>
<path id="tools.runtime.classpath">
<pathelement path="${build.src}" />
<pathelement path="${tools.src.dir}" />
<resources refid="runtime.libs" />
</path>
<union id="tools.runtime.test.classpath">
<resources refid="runtime.classpath"/>
<path>
<pathelement path="${build.test}" />
<pathelement path="${tools.test.dir}" />
<resources refid="runtime.test.libs" />
</path>
</union>
<union id="tools.jar-src">
<fileset dir="${build.misc}">
<include name="com/rtg/**" />
</fileset>
<fileset dir="${build.src}" />
<fileset dir="${tools.src.dir}">
<include name="com/**/*.properties"/>
<include name="com/rtg/simulation/variants/*.txt"/>
<include name="com/rtg/reference/resources/**/*"/>
<include name="com/rtg/report/resources/*"/>
<include name="com/rtg/vcf/resources/*"/>
<include name="com/rtg/mode/BLOSUM45" />
<include name="com/rtg/mode/BLOSUM62" />
<include name="com/rtg/mode/BLOSUM80" />
<include name="com/rtg/graph/**/*.png"/>
</fileset>
<zipfileset src="${tools.src.lib.dir}/${htsjdk.jar}" excludes="META-INF/**"/>
<zipfileset src="${tools.src.lib.dir}/velocity-1.7.jar" excludes="META-INF/**" />
<zipfileset src="${tools.src.lib.dir}/velocity-tools-generic.jar" excludes="META-INF/**" />
<zipfileset src="${tools.src.lib.dir}/commons-collections-3.2.1.jar" excludes="META-INF/**" />
<zipfileset src="${tools.src.lib.dir}/commons-lang-2.4.jar" excludes="META-INF/**" />
<zipfileset src="${tools.src.lib.dir}/commons-compress-1.4.1.jar" excludes="META-INF/**" />
<zipfileset src="${tools.src.lib.dir}/snappy-java-1.1.4.jar" excludes="META-INF/**" includes="**/*.class" />
<zipfileset src="${tools.src.lib.dir}/json-simple-1.1.1.jar" excludes="META-INF/**" />
<zipfileset src="${tools.src.lib.dir}/RPlot.jar" excludes="META-INF/**"/>
<zipfileset src="${tools.src.lib.dir}/gzipfix.jar">
<include name="com/rtg/util/gzip/WorkingGzipInputStream.class" />
</zipfileset>
</union>
<union id="tools.jar-test">
<resources refid="jar-src"/>
<fileset dir="${build.test}">
<include name="**/*.class"/>
</fileset>
<fileset dir="${tools.test.dir}">
<include name="com/**/*.txt"/>
<include name="com/**/*.properties"/>
<include name="com/rtg/**/resources/**/*"/>
<include name="com/rtg/mode/BLOSUM*" />
<include name="com/rtg/util/testFile"/>
<include name="com/rtg/util/cli/spell.*"/>
</fileset>
<zipfileset src="${tools.test.lib.dir}/spelling.jar"/>
<zipfileset src="${tools.test.lib.dir}/junit.jar" excludes="META-INF/**"/>
<zipfileset src="${tools.test.lib.dir}/hamcrest-core-1.3.jar" excludes="META-INF/**"/>
</union>
<!-- These jars are only needed at compile time -->
<fileset id="compiletime.libs" dir="${tools.src.lib.dir}">
<include name="jumble-annotations.jar" />
<include name="findbugs-annotations.jar" />
<include name="findbugs-jsr305.jar" />
</fileset>
<union id="runtime.libs">
<resources refid="tools.runtime.libs"/>
</union>
<!-- These jars are needed at test run time -->
<fileset id="runtime.test.libs" dir="${tools.test.lib.dir}" includes="*.jar"/>
<path id="src.path">
<pathelement path="${tools.src.dir}" />
</path>
<path id="test.path">
<pathelement path="${tools.test.dir}" />
</path>
<union id="runtime.classpath">
<resources refid="tools.runtime.classpath"/>
</union>
<union id="runtime.test.classpath">
<resources refid="tools.runtime.test.classpath"/>
</union>
<union id="jar-src">
<resources refid="tools.jar-src"/>
</union>
<union id="jar-test">
<resources refid="jar-src"/>
<resources refid="tools.jar-test"/>
</union>
<fileset id="common-resources" dir="${public.tools.basedir}/installer/resources/common"/>
<union id="tools-resources">
<fileset refid="common-resources" />
<fileset dir="${public.tools.basedir}/installer/resources/tools"/>
</union>
<!-- Targets -->
<target name="clean">
<delete dir="${dist.dir}"/>
<delete dir="${build.dir}"/>
</target>
<target name="init">
<mkdir dir="${dist.dir}"/>
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.src}"/>
<mkdir dir="${build.test}"/>
<mkdir dir="${build.text}"/>
<mkdir dir="${build.executable}"/>
<mkdir dir="${build.junit}"/>
<mkdir dir="${build.misc}"/>
</target>
<property name="vcs.info.cmd" value="git"/>
<property name="vcs.info.args" value="rev-list --abbrev-commit -n 1 HEAD"/>
<target name="rtg-vcs-info" depends="init" unless="rtg.vcs.commit.revision">
<exec executable="${vcs.info.cmd}" outputproperty="vcs.cmd.out" resultproperty="vcs.cmd.rc" dir="${public.tools.basedir}">
<arg line="${vcs.info.args}"/>
</exec>
<condition property="rtg.vcs.commit.revision"
value="unknown"
else="${vcs.cmd.out}">
<isfailure code="${vcs.cmd.rc}"/>
</condition>
<echo message="Current build revision is ${rtg.vcs.commit.revision}"/>
</target>
<target name="compile-src" depends="init" description="Compiles all code in src.">
<property name="src.path" refid="src.path" />
<javac destdir="${build.src}" debug="true"
sourcepath="" srcdir="${src.path}">
<compilerarg value="-Xlint" />
<compilerarg value="-Xlint:-serial" />
<compilerarg value="-proc:none" />
<classpath>
<resources refid="runtime.libs"/>
<resources refid="compiletime.libs"/>
</classpath>
</javac>
</target>
<target name="compile-test" depends="compile-src" description="Compiles all code in test.">
<property name="test.path" refid="test.path" />
<javac destdir="${build.test}" debug="true"
sourcepath="" srcdir="${test.path}">
<compilerarg value="-Xlint" />
<compilerarg value="-Xlint:-serial" />
<compilerarg value="-proc:none" />
<classpath>
<pathelement path="${build.src}"/>
<resources refid="runtime.libs"/>
<resources refid="compiletime.libs"/>
<resources refid="runtime.test.libs" />
</classpath>
</javac>
</target>
<target name="compile" depends="compile-test" description="Compile all Java source code."/>
<!--
This definition puts a property value into a file, but only if it
is different to the value that is already there, in order to
prevent the triggering of expensive targets multiple times.
-->
<macrodef name="set-version-file">
<attribute name="file"/>
<attribute name="value"/>
<attribute name="strict" default="false"/>
<sequential>
<local name="old-value"/>
<loadfile property="old-value" srcFile="@{file}" failonerror="false" quiet="true"/>
<fail message="Need to clean first. (last='${old-value}' current='@{value}')">
<condition>
<and>
<istrue value="@{strict}"/>
<available file="@{file}"/>
<not>
<equals arg1="${old-value}" arg2="@{value}"/>
</not>
</and>
</condition>
</fail>
<if>
<not>
<equals arg1="${old-value}" arg2="@{value}"/>
</not>
<then>
<echo message="Setting @{file} to @{value}"/>
<echo file="@{file}" message="@{value}"/>
</then>
</if>
</sequential>
</macrodef>
<target name="set-rtg-build-version" depends="init,rtg-vcs-info">
<tstamp> <format property="build.time" pattern="yyyy-MM-dd" /></tstamp>
<set-version-file file="${build.src}/com/rtg/build.version" value="${rtg.vcs.commit.revision}"/>
<set-version-file file="${build.src}/com/rtg/build.time" value="${build.time}"/>
</target>
<target name="set-rtg-build-product">
<set-version-file file="${build.misc}/com/rtg/product.version" value="${product.version}"/>
<set-version-file file="${build.misc}/com/rtg/product.name" value="${product}" strict="true"/>
<set-version-file file="${build.misc}/com/rtg/product.repo" value="${product.repo}"/>
</target>
<macrodef name="rtg-jar">
<attribute name="main"/>
<attribute name="file"/>
<attribute name="refid"/>
<sequential>
<jar destfile="@{file}" duplicate="fail">
<manifest>
<attribute name="Main-Class" value="@{main}"/>
<attribute name="Implementation-Title" value="RTG"/>
<attribute name="Implementation-Vendor" value="Real Time Genomics"/>
<attribute name="Class-Path" value="."/>
</manifest>
<resources refid="@{refid}"/>
</jar>
</sequential>
</macrodef>
<target name="rtg-tools.jar" depends="compile-src,set-rtg-build-version,set-rtg-build-product" description="Tools jar.">
<rtg-jar main="com.rtg.RtgTools" file="${build.dir}/rtg-tools.jar" refid="jar-src"/>
</target>
<target name="rtg-all.jar" depends="compile,set-rtg-build-version,set-rtg-build-product" description="Create jar including tests.">
<rtg-jar main="RtgTestEntry" file="${build.dir}/rtg-all.jar" refid="jar-test"/>
</target>
<target name="javadoc" depends="compile-src" description="Build javadocs">
<javadoc sourcepath="${src.path}" destdir="${build.dir}/javadocs" source="1.8"
Author="true" Version="true" Package="true"
useexternalfile="true" additionalparam="-quiet" docfilessubdirs="true">
<tag name="has" enabled="false"/>
<tag name="assoc" enabled="false"/>
<tag name="depend" enabled="false"/>
<tag name="composed" enabled="false"/>
<tag name="minOccurs" enabled="false"/>
<tag name="maxOccurs" enabled="false"/>
<tag name="nillable" enabled="false"/>
<tag name="nillableContainer" enabled="false"/>
<tag name="minOccursContainer" enabled="false"/>
<tag name="length" enabled="false"/>
<tag name="minLength" enabled="false"/>
<tag name="maxLength" enabled="false"/>
<tag name="enumeration" enabled="false"/>
<tag name="pattern" enabled="false"/>
<tag name="minExclusive" enabled="false"/>
<tag name="maxExclusive" enabled="false"/>
<tag name="minInclusive" enabled="false"/>
<tag name="maxInclusive" enabled="false"/>
<classpath>
<resources refid="runtime.libs" />
<resources refid="compiletime.libs" />
</classpath>
</javadoc>
</target>
<scriptdef language="javascript" name="lowercase">
<attribute name="value" />
<attribute name="name" />
project.setProperty(attributes.get("name"), attributes.get("value").toLowerCase());
</scriptdef>
<target name="zip-init" depends="rtg-vcs-info"> <!-- set up properties -->
<tstamp> <format property="build.tstamp" pattern="yyyyMMddHHmm" /></tstamp>
<propertyregex property="almostproductfilename" input="${product}" regexp="\s+" global="true" replace="-" />
<property name="almostproductfilename" value="${product}" />
<lowercase name="productfilename" value="${almostproductfilename}" />
<condition property="zipversion"
value="${productfilename}-${product.version}"
else="${productfilename}-${product.version}-${rtg.vcs.commit.revision}">
<istrue value="${release.build}"/>
</condition>
<property name="zipfile.base" location="${build.dir}/${zipversion}-base.zip" />
<property name="zipfile.nojre" location="${dist.dir}/${zipversion}-nojre.zip" />
<property name="zipfile" value="${zipfile.nojre}" /> <!-- Default when running smoketest -->
<property name="rtg-jar-for-zip" value="rtg-${resources}.jar"/>
</target>
<target name="zip-jars">
<antcall>
<target name="${rtg-jar-for-zip}"/>
</antcall>
</target>
<resources id="tools.zip.text">
<file file="${public.tools.basedir}/installer/README.txt"/>
<file file="${public.tools.basedir}/installer/ReleaseNotes.txt"/>
</resources>
<union id="zip.text">
<resources refid="tools.zip.text"/>
<file file="${public.tools.basedir}/LICENSE.txt"/>
</union>
<target name="zip-text">
<copy todir="${build.text}">
<resources refid="zip.text"/>
<filterchain>
<replaceregex pattern="RTG.VERSION" replace="${product}" />
<fixcrlf eol="crlf" />
</filterchain>
</copy>
</target>
<target name="zip-exes">
<union id="executable-resources">
<fileset dir="${public.tools.basedir}/installer" includes="rtg"/>
<restrict>
<resources refid="${resources}-resources"/>
<rsel:name xmlns:rsel="antlib:org.apache.tools.ant.types.resources.selectors" name="**/*.sh"/>
</restrict>
</union>
<union id="non-executable-resources">
<fileset dir="${public.tools.basedir}/installer" includes="rtg.bat"/>
<restrict>
<resources refid="${resources}-resources"/>
<rsel:not xmlns:rsel="antlib:org.apache.tools.ant.types.resources.selectors">
<rsel:name name="**/*.sh"/>
</rsel:not>
</restrict>
</union>
<copy todir="${build.executable}">
<resources refid="executable-resources"/>
</copy>
</target>
<target name="zip-base" depends="zip-init,zip-jars,zip-text,zip-exes">
<zip destfile="${zipfile.base}" duplicate="fail">
<mappedresources>
<resources refid="non-executable-resources"/>
<globmapper from="*" to="${zipversion}/*"/>
</mappedresources>
<zipfileset prefix="${zipversion}" dir="${build.text}" includes="*.txt" />
<zipfileset prefix="${zipversion}" dir="${build.executable}" filemode="755"/>
<zipfileset fullpath="${zipversion}/RTG.jar" dir="${build.dir}" includes="${rtg-jar-for-zip}"/>
<zipfileset fullpath="${zipversion}/third-party/gzipfix.jar" dir="${tools.src.lib.dir}" includes="gzipfix.jar" />
</zip>
</target>
<target name="zip-nojre" depends="zip-base" description="Create the distributable zip file without JRE.">
<copy file="${zipfile.base}" tofile="${zipfile.nojre}"/>
</target>
<!--
Targets that exist to make things bearable for developers running
stuff from Windows command-line.
-->
<property name="run.args" value=""/>
<target name="run" depends="compile-src" description="Run any class. -Drun.class=xxx -Drun.args=xxx">
<java classname="${run.class}" fork="true">
<arg line="${run.args}" />
<classpath>
<resources refid="runtime.classpath" />
</classpath>
</java>
</target>
<target name="runrtg" description="Run RTG. -Drun.args=xxx">
<antcall target="run">
<param name="run.class" value="${main.class}"/>
</antcall>
</target>
<property name="test.jvm.args" value="" />
<property name="junit.jar" value="${tools.test.lib.dir}/junit.jar"/>
<property name="junit.runner" value="RtgTestEntry" />
<target name="runtest" depends="compile-src,compile-test" description="Run a unit test class. -Dtest.class=xxx">
<fail unless="test.class" message="test.class property must be set"/>
<property name="regression.root" refid="test.path" />
<java classname="${junit.runner}" fork="true" failonerror="true" dir="${build.junit}">
<arg line="${test.class}" />
<jvmarg value="-server" />
<jvmarg value="-ea" />
<jvmarg value="-Duser.language=US" />
<jvmarg value="-Duser.country=US" />
<jvmarg value="-Djava.awt.headless=true" />
<jvmarg value="-Drtg.developer=true" />
<jvmarg value="-Djunit.printFailures=true" />
<jvmarg value="-Dregression.root=${regression.root}" />
<jvmarg value="-Dregression.update=${regression.update}" />
<jvmarg value="-javaagent:${buildtools.dir}/handlechecker.jar" />
<jvmarg line="${test.jvm.args}" />
<classpath>
<pathelement path="${junit.jar}"/>
<resources refid="runtime.test.classpath" />
</classpath>
</java>
</target>
<target name="runalltests" description="Run all unit tests">
<antcall target="runtest">
<param name="test.class" value="AllTests"/>
</antcall>
</target>
</project>