forked from btraceio/btrace
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
452 lines (431 loc) · 21.8 KB
/
build.xml
File metadata and controls
452 lines (431 loc) · 21.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
<?xml version="1.0" encoding="UTF-8"?>
<project name="BTrace" default="all" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<!-- Property Definitions -->
<property name="maven-snapshots-repository-id" value="sonatype-nexus-snapshots" />
<property name="maven-snapshots-repository-url" value="https://oss.sonatype.org/content/repositories/snapshots" />
<property name="maven-staging-repository-id" value="sonatype-nexus-staging" />
<property name="maven-staging-repository-url" value="https://oss.sonatype.org/service/local/staging/deploy/maven2" />
<property name="agent.excludes" value="**/dtrace/* **/btrace/*.class **/asm/signature/** **/asm/tree/** **/asm/util/** **/asm/xml/** **/aggregation/* **/compiler/* **/client/* **/comm/* com/sun/btrace/api/**/* com/sun/btrace/spi/**/* **/instr/** **/META-INF/*"/>
<property name="boot.excludes" value="**/dtrace/* **/agent/* **/compiler/* **/client/* **/resources/* **/runtime/* **/util/**/* **/asm/** com/sun/btrace/api/**/* com/sun/btrace/spi/**/*"/>
<property name="client.excludes" value="**/runtime/* **/agent/* **/util/TimeStamp* **/util/MethodId **/util/SamplingSupport **/util/templates/**/* **/instr/** **/META-INF/*"/>
<target name="prepare" depends="load.properties">
<mkdir dir="${classes.dir}"/>
<mkdir dir="${javadoc.dir}"/>
<mkdir dir="${tests.dir}"/>
<mkdir dir="${tests.result.dir}"/>
<available classname="org.opensolaris.os.dtrace.Consumer"
classpath="/usr/share/lib/java/dtrace.jar"
property="libdtrace.jni.available"/>
<path id="javac.classpath">
<pathelement path="${lib.dir}/btrace-asm-${asm.version}.jar" />
<pathelement path="${java.home}/../lib/tools.jar" />
<pathelement path="/usr/share/lib/java/dtrace.jar" />
</path>
<condition property="iswindows">
<os family="windows"/>
</condition>
<condition property="btracec" value="btracec">
<not>
<istrue value="${iswindows}"/>
</not>
</condition>
<condition property="btracec" value="btracec.bat">
<istrue value="${iswindows}"/>
</condition>
</target>
<target name="initialize.maven" depends="prepare">
<get
src="http://apache.petsads.us/maven/ant-tasks/2.1.3/binaries/maven-ant-tasks-2.1.3.jar"
dest="${build.dir}/maven-ant-tasks-2.1.3.jar"
verbose="true"
usetimestamp="true"/>
<path id="maven-ant-tasks.classpath" path="${build.dir}/maven-ant-tasks-2.1.3.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="antlib:org.apache.maven.artifact.ant"
classpathref="maven-ant-tasks.classpath" />
</target>
<target name="create.pom.file" if="artifact">
<copy file="btrace_template.pom" tofile="${build.dir}/pom-${artifact}.xml" overwrite="true">
<filterset>
<filter token="NAME" value="${name}"/>
<filter token="ARTIFACT_ID" value="${artifact}"/>
<filter token="VERSION" value="${release.version}${snapshot}"/>
</filterset>
</copy>
</target>
<target name="upload.snapshots.with.build" depends="initialize.maven,jar,upload.snapshots"/>
<target name="upload.staging.with.build" depends="initialize.maven,jar,upload.staging"/>
<target name="create.snapshot.poms" depends="initialize.maven">
<antcall target="create.pom.file" >
<param name="name" value="btrace-agent"/>
<param name="artifact" value="btrace-agent"/>
<param name="snapshot" value="-SNAPSHOT"/>
</antcall>
<antcall target="create.pom.file" >
<param name="name" value="btrace-boot"/>
<param name="artifact" value="btrace-boot"/>
<param name="snapshot" value="-SNAPSHOT"/>
</antcall>
<antcall target="create.pom.file" >
<param name="name" value="btrace-client"/>
<param name="artifact" value="btrace-client"/>
<param name="snapshot" value="-SNAPSHOT"/>
</antcall>
<artifact:pom id="btrace-agent" file="../build/pom-btrace-agent.xml" />
<artifact:pom id="btrace-boot" file="../build/pom-btrace-boot.xml" />
<artifact:pom id="btrace-client" file="../build/pom-btrace-client.xml" />
<artifact:install file="${agent.jar}">
<pom refid="btrace-agent"/>
</artifact:install>
<artifact:install file="${boot.jar}">
<pom refid="btrace-boot"/>
</artifact:install>
<artifact:install file="${client.jar}">
<pom refid="btrace-client"/>
</artifact:install>
</target>
<target name="create.staging.poms" depends="initialize.maven">
<antcall target="create.pom.file" >
<param name="name" value="btrace-agent"/>
<param name="artifact" value="btrace-agent"/>
<param name="snapshot" value=""/>
</antcall>
<antcall target="create.pom.file" >
<param name="name" value="btrace-boot"/>
<param name="artifact" value="btrace-boot"/>
<param name="snapshot" value=""/>
</antcall>
<antcall target="create.pom.file" >
<param name="name" value="btrace-client"/>
<param name="artifact" value="btrace-client"/>
<param name="snapshot" value=""/>
</antcall>
</target>
<target name="upload.snapshots" depends="initialize.maven,create.snapshot.poms" description="Publish btrace binaries to Maven2 snapshots repository">
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" />
<arg value="-Durl=${maven-snapshots-repository-url}" />
<arg value="-DrepositoryId=${maven-snapshots-repository-id}" />
<arg value="-DpomFile=${build.dir}/pom-btrace-agent.xml" />
<arg value="-Dfile=${agent.jar}" />
<arg value="-X"/>
</artifact:mvn>
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" />
<arg value="-Durl=${maven-snapshots-repository-url}" />
<arg value="-DrepositoryId=${maven-snapshots-repository-id}" />
<arg value="-DpomFile=${build.dir}/pom-btrace-boot.xml" />
<arg value="-Dfile=${boot.jar}" />
</artifact:mvn>
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" />
<arg value="-Durl=${maven-snapshots-repository-url}" />
<arg value="-DrepositoryId=${maven-snapshots-repository-id}" />
<arg value="-DpomFile=${build.dir}/pom-btrace-client.xml" />
<arg value="-Dfile=${client.jar}" />
</artifact:mvn>
</target>
<target name="upload.staging" depends="create.staging.poms, create.sources, create.javadocs" description="Publish btrace binaries to Maven2 staging repository">
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${maven-staging-repository-url}" />
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
<arg value="-DpomFile=${build.dir}/pom-btrace-agent.xml" />
<arg value="-Dfile=${agent.jar}" />
<arg value="-Dgpg.passphrase=${gpg.passphrase}"/>
<arg value="-Pgpg" />
</artifact:mvn>
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${maven-staging-repository-url}" />
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
<arg value="-DpomFile=${build.dir}/pom-btrace-agent.xml" />
<arg value="-Dfile=${agent-sources.jar}" />
<arg value="-Dclassifier=sources" />
<arg value="-Dgpg.passphrase=${gpg.passphrase}"/>
<arg value="-Pgpg" />
</artifact:mvn>
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${maven-staging-repository-url}" />
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
<arg value="-DpomFile=${build.dir}/pom-btrace-agent.xml" />
<arg value="-Dfile=${agent-javadoc.jar}" />
<arg value="-Dclassifier=javadoc" />
<arg value="-Dgpg.passphrase=${gpg.passphrase}"/>
<arg value="-Pgpg" />
</artifact:mvn>
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${maven-staging-repository-url}" />
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
<arg value="-DpomFile=${build.dir}/pom-btrace-boot.xml" />
<arg value="-Dfile=${boot.jar}" />
<arg value="-Dgpg.passphrase=${gpg.passphrase}"/>
<arg value="-Pgpg" />
</artifact:mvn>
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${maven-staging-repository-url}" />
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
<arg value="-DpomFile=${build.dir}/pom-btrace-boot.xml" />
<arg value="-Dfile=${boot-sources.jar}" />
<arg value="-Dclassifier=sources" />
<arg value="-Dgpg.passphrase=${gpg.passphrase}"/>
<arg value="-Pgpg" />
</artifact:mvn>
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${maven-staging-repository-url}" />
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
<arg value="-DpomFile=${build.dir}/pom-btrace-boot.xml" />
<arg value="-Dfile=${boot-javadoc.jar}" />
<arg value="-Dclassifier=javadoc" />
<arg value="-Dgpg.passphrase=${gpg.passphrase}"/>
<arg value="-Pgpg" />
</artifact:mvn>
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${maven-staging-repository-url}" />
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
<arg value="-DpomFile=${build.dir}/pom-btrace-client.xml" />
<arg value="-Dfile=${client.jar}" />
<arg value="-Dgpg.passphrase=${gpg.passphrase}"/>
<arg value="-Pgpg" />
</artifact:mvn>
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${maven-staging-repository-url}" />
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
<arg value="-DpomFile=${build.dir}/pom-btrace-client.xml" />
<arg value="-Dfile=${client-sources.jar}" />
<arg value="-Dclassifier=sources" />
<arg value="-Dgpg.passphrase=${gpg.passphrase}"/>
<arg value="-Pgpg" />
</artifact:mvn>
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${maven-staging-repository-url}" />
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
<arg value="-DpomFile=${build.dir}/pom-btrace-client.xml" />
<arg value="-Dfile=${client-javadoc.jar}" />
<arg value="-Dclassifier=javadoc" />
<arg value="-Dgpg.passphrase=${gpg.passphrase}"/>
<arg value="-Pgpg" />
</artifact:mvn>
</target>
<target name="clean" depends="load.properties">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<target name="clean-docs" depends="load.properties">
<delete dir="${javadoc.dir}"/>
</target>
<target name="compile-src" depends="prepare" description="Compiles the sources">
<javac srcdir="${share.src.dir}"
destdir="${classes.dir}"
debug="on" deprecation="on" includeantruntime="on" includejavaruntime="on"
target="1.7" source="1.7">
<classpath refid="javac.classpath" />
</javac>
</target>
<target name="compile" depends="compile-src, compile-dtrace" description="Compiles the sources, resources and javadocs">
<tstamp>
<format property="build.date" pattern="YYYYMMdd"/>
</tstamp>
<copy todir="${classes.dir}/com/sun/btrace/resources">
<fileset dir="${share.src.dir}/com/sun/btrace/resources/"/>
</copy>
<copy todir="${classes.dir}/com/sun/btrace/runtime">
<fileset file="${share.src.dir}/com/sun/btrace/runtime/jaxb.index"/>
</copy>
<copy todir="${classes.dir}/com/sun/btrace/annotations">
<fileset file="${share.src.dir}/com/sun/btrace/annotations/jaxb.index"/>
</copy>
<echo>${build.date}</echo>
<replace file="${classes.dir}/com/sun/btrace/resources/messages.properties" value="${release.version} (${build.date})" token="{btrace.version}"/>
</target>
<target name="javadoc" depends="jar,clean-docs" description="Generates javadocs">
<javadoc destdir="${javadoc.dir}">
<fileset file="${share.src.dir}/com/sun/btrace/aggregation/*.java"/>
<fileset file="${share.src.dir}/com/sun/btrace/annotations/*.java"/>
<fileset file="${share.src.dir}/com/sun/btrace/AnyType.java"/>
<fileset file="${share.src.dir}/com/sun/btrace/BTraceUtils.java"/>
<fileset file="${share.src.dir}/com/sun/btrace/Profiler.java"/>
<fileset file="${share.src.dir}/com/sun/btrace/api/*.java"/>
<fileset file="${share.src.dir}/com/sun/btrace/spi/*.java"/>
</javadoc>
</target>
<target name="check-junit" depends="prepare">
<available file="${junit.jar}" property="junit.jar.available"/>
<fail message="${junit.jar} is not available. Please, make sure the file exists or set the junit.jar property accordingly.">
<condition>
<not>
<istrue value="${junit.jar.available}"/>
</not>
</condition>
</fail>
</target>
<target name="prepare-tests" depends="compile-tests, build-traces"/>
<target name="compile-tests" depends="check-junit, compile-src" description="Compiles the tests">
<javac srcdir="${test.src.dir}" destdir="${tests.dir}" debug="on" deprecation="on">
<classpath refid="javac.classpath"/>
<classpath>
<pathelement location="${tests.dir}"/>
<pathelement location="${classes.dir}"/>
<pathelement path="${junit.jar}"/>
<fileset dir="${lib.dir}" includes="**/*.jar"/>
<fileset dir="${test.lib.dir}" includes="**/*.jar"/>
</classpath>
<exclude name="traces/**"/>
</javac>
<copy todir="${tests.dir}/traces">
<fileset dir="${test.src.dir}/traces">
<include name="**/*.java"/>
<include name="**/*.xml"/>
</fileset>
</copy>
</target>
<target name="build-traces" depends="jar, compile-tests">
<echo>executing ${bin.dir}/${btracec} -cp ${build.dir}/test -d ${tests.dir} ${traces.dir}/*.java</echo>
<apply executable="${bin.dir}/${btracec}" verbose="true" failonerror="true">
<fileset dir="${traces.dir}" includes="**/*.java"/>
<arg value="-cp ${build.dir}/test"/>
<arg value="-d ${tests.dir}"/>
</apply>
<echo>copying source traces</echo>
<copy todir="${tests.dir}" >
<fileset dir="${traces.dir}" includes="**/*.java"/>
<globmapper from="*.btrace" to="*.java"/>
</copy>
</target>
<target name="compile-dtrace" if="libdtrace.jni.available" depends="prepare">
<javac srcdir="${solaris.src.dir}"
destdir="${classes.dir}"
debug="on" deprecation="on">
<classpath refid="javac.classpath"/>
</javac>
</target>
<target name="create.sources" depends="prepare" description="Creates source archives for maven artifacts">
<jar jarfile="${agent-sources.jar}"
basedir="${share.src.dir}"
excludes="${agent.excludes}"/>
<jar jarfile="${boot-sources.jar}"
basedir="${share.src.dir}"
excludes="${boot.excludes}"/>
<jar jarfile="${client-sources.jar}"
basedir="${share.src.dir}"
excludes="${client.excludes}"/>
</target>
<target name="create.javadocs" depends="prepare" description="Creates javadoc archives for maven artifacts">
<javadoc destdir="${build.dir}/agent-javadoc" classpath="${classes.dir}" use="true">
<fileset dir="${share.src.dir}" excludes="${agent.excludes} **/*.index **/*.properties"/>
</javadoc>
<javadoc destdir="${build.dir}/boot-javadoc" classpath="${classes.dir}" use="true">
<fileset dir="${share.src.dir}" excludes="${boot.excludes} **/*.index **/*.properties **/*.mf"/>
</javadoc>
<javadoc destdir="${build.dir}/client-javadoc" classpath="${classes.dir}" use="true">
<fileset dir="${share.src.dir}" excludes="${client.excludes} **/*.index **/*.properties"/>
</javadoc>
<jar jarfile="${agent-javadoc.jar}"
basedir="${build.dir}/agent-javadoc"/>
<jar jarfile="${boot-javadoc.jar}"
basedir="${build.dir}/boot-javadoc"/>
<jar jarfile="${client-javadoc.jar}"
basedir="${build.dir}/client-javadoc"/>
</target>
<target name="jar" depends="compile" description="Creates deployment bundles">
<unjar src="${lib.dir}/btrace-asm-${asm.version}.jar" dest="${classes.dir}"/>
<jar jarfile="${agent.jar}"
basedir="${classes.dir}"
manifest="${share.src.dir}/META-INF/agent-manifest.mf"
excludes="${agent.excludes}"/>
<jar jarfile="${boot.jar}"
basedir="${classes.dir}"
excludes="${boot.excludes}"/>
<jar jarfile="${client.jar}"
basedir="${classes.dir}"
manifest="${share.src.dir}/META-INF/client-manifest.mf"
excludes="${client.excludes}"/>
</target>
<target name="load.properties">
<echo message="Loading build properties file"/>
<property file="build.properties"/>
<property file="private.properties"/>
</target>
<target name="dist" depends="jar, test-dist">
<delete dir="${dist.dir}"/>
<mkdir dir="${dist.dir}"/>
<mkdir dir="${dist.dir}/build"/>
<mkdir dir="${dist.dir}/bin"/>
<mkdir dir="${dist.dir}/samples"/>
<mkdir dir="${dist.dir}/docs"/>
<copy todir="${dist.dir}/build">
<fileset file="${build.dir}/*.jar"/>
</copy>
<copy todir="${dist.dir}/bin">
<fileset file="${bin.dir}/*"/>
</copy>
<copy todir="${dist.dir}/samples">
<fileset file="${samples.dir}/*"/>
</copy>
<copy todir="${dist.dir}/docs">
<fileset file="${docs.dir}/usersguide.html"/>
</copy>
<copy todir="${dist.dir}/docs/javadoc">
<fileset dir="${docs.dir}/javadoc"/>
</copy>
<copy todir="${dist.dir}">
<fileset file="${basedir}/../*.txt"/>
<fileset file="${basedir}/../COPYRIGHT"/>
</copy>
<tar basedir="${dist.dir}" destfile="${dist.dir}/btrace-bin.tar.gz"
compression="gzip" excludes="*.zip,*.gz"/>
<zip basedir="${dist.dir}" destfile="${dist.dir}/btrace-bin.zip"
excludes="*.zip,*.gz"/>
<antcall target="dist-debian"/>
</target>
<target name="dist-debian" depends="jar">
<mkdir dir="${dist.dir}/debian"/>
<copy todir="${dist.dir}/debian" overwrite="true">
<fileset dir="${project.dir}/packaging/debian" includes="**/*"/>
<filterset>
<filter token="VERSION" value="${release.version}-${build.date}"/>
</filterset>
</copy>
<chmod file="${dist.dir}/debian/btrace/DEBIAN/postinst" perm="0555"/>
<copy todir="${dist.dir}/debian/btrace/usr/lib/btrace" overwrite="true">
<fileset file="${build.dir}/btrace-*.jar"/>
</copy>
<exec failonerror="false" osfamily="unix" dir="${dist.dir}/debian" executable="dpkg">
<arg value="--build"/>
<arg value="btrace"/>
</exec>
<move file="${dist.dir}/debian/btrace.deb" todir="${dist.dir}"/>
<delete dir="${dist.dir}/debian"/>
</target>
<target name="test" depends="check-junit, compile, compile-tests">
<junit fork="yes" printsummary="withOutAndErr" showoutput="true" errorProperty="test.failed" failureProperty="test.failed" filtertrace="false">
<formatter type="xml"/>
<formatter usefile="false" type="brief" />
<classpath>
<pathelement location="${tests.dir}"/>
<pathelement location="${classes.dir}"/>
<pathelement path="${java.class.path}"/>
<pathelement path="${junit.jar}"/>
<fileset dir="${lib.dir}" includes="**/*.jar"/>
<fileset dir="${test.lib.dir}" includes="**/*.jar"/>
</classpath>
<batchtest haltonfailure="true" todir="${tests.result.dir}">
<fileset dir="${test.src.dir}">
<include name="**/*.java"/>
<exclude name="resources/**"/>
<exclude name="traces/**"/>
<exclude name="support/**"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="test-dist" depends="build-traces, test"/>
<target name="all" depends="jar, javadoc" description="Builds sources and deployment jars"/>
</project>