forked from btraceio/btrace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
504 lines (417 loc) · 13.5 KB
/
build.gradle
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
import javax.tools.ToolProvider
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.12"
}
}
plugins {
id 'java'
id 'maven'
id 'maven-publish'
id "nebula.ospackage" version "4.3.0"
id "com.jfrog.bintray" version "1.7"
id "jacoco"
}
def currentJvm = org.gradle.internal.jvm.Jvm.current()
// don't enable errorprone for JDK 7 - it does not work
if (!currentJvm.toString().startsWith("1.7")) {
apply plugin: 'net.ltgt.errorprone'
dependencies.create('com.google.errorprone:error_prone_core:2.0.5')
}
group 'com.sun.tools.btrace'
version = '1.3.11'
description = 'BTrace - a safe, dynamic tracing tool for the Java platform'
sourceCompatibility = 7
targetCompatibility = 7
allprojects {
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
repositories {
jcenter()
mavenLocal()
mavenCentral()
}
}
// Support for releasing to BinTray; see https://github.com/bintray/gradle-bintray-plugin
// Add 'gradle.properties' file containing the following properties:
// * bintray.user
// * bintray.key
// * gpg.passphrase
bintray {
user = project.hasProperty("bintray.user") ? project.property("bintray.user") : System.getenv('BINTRAY_USER')
key = project.hasProperty("bintray.key") ? project.property("bintray.key") : System.getenv('BINTRAY_API_KEY')
publications = ['agent', 'client', 'boot']
dryRun = System.properties['bintrayUpload'] != null ? !(Boolean.getBoolean('bintrayUpload')) : true
publish = true
pkg {
repo = 'maven'
name = 'btrace'
desc = 'BTrace'
userOrg = 'btraceio'
websiteUrl = 'https://github.com/btraceio/btrace'
issueTrackerUrl = 'https://github.com/btraceio/btrace/issues'
vcsUrl = 'https://github.com/btraceio/btrace.git'
licenses = ['GPL-2.0+CE']
labels = []
publicDownloadNumbers = true
version {
name = project.version //Bintray logical version name
released = new java.util.Date()
vcsTag = 'v' + project.version
//Optional configuration for GPG signing
gpg {
sign = project.hasProperty("gpg.passphrase") //Determines whether to GPG sign the files. The default is false
passphrase = sign ? project.property("gpg.passphrase") : "" //Optional. The passphrase for GPG signing'
}
}
}
}
def pomDetails = {
resolveStrategy = Closure.DELEGATE_FIRST
url 'https://github.com/btraceio/btrace'
scm {
url 'https://github.com/btraceio/btrace'
connection 'scm:git:https://github.com/btraceio/btrace.git'
developerConnection 'scm:git:https://github.com/btraceio/btrace.git'
}
licenses {
license {
name 'GNU General Public License, version 2, with the Classpath Exception'
url 'http://openjdk.java.net/legal/gplv2+ce.html'
}
}
developers {
developer {
id 'yardus'
name 'Jaroslav Bachorik'
email '[email protected]'
}
}
}
def env = System.getenv()
def javaHome = env['JAVA_HOME']
def props = System.getProperties()
def osFamily = props['os.family']
def osName = props['os.name']
def asmVersion = '5.2'
def jcToolsVersion = '2.1.1'
def junitVersion = '4.6'
def agentExcludes = ['**/dtrace/*', '**/btrace/*.class', '**/asm/signature/**', \
'**/asm/util/**', '**/asm/xml/**', '**/aggregation/**', \
'**/compiler/*', '**/client/**', '**/comm/*', \
'com/sun/btrace/api/**', 'com/sun/btrace/spi/**', \
'com/sun/btrace/instr/**', '**/org/jctools/**', \
'**/org/jctools/queues/atomic/**',
'**/org/jctools/queues/spec/**', '**/META-INF/*']
def bootExcludes = ['**/dtrace/**', '**/agent/**', '**/compiler/**', '**/client/**', \
'**/resources/**', '**/runtime/**', 'com/sun/btrace/util/**', \
'**/asm/**', 'com/sun/btrace/api/**', 'com/sun/btrace/spi/**',
'**/org/jctools/queues/atomic/**',
'**/org/jctools/queues/spec/**', '**/META-INF/**']
def clientExcludes = ['**/agent/**', \
'**/util/TimeStamp*', '**/util/MethodId', \
'**/util/SamplingSupport', '**/util/templates/**', \
'**/instr/**', '**/META-INF/*']
def excludes = ['agent': agentExcludes, 'boot': bootExcludes, 'client': clientExcludes]
sourceSets {
main {
java {
srcDir 'src/share/classes'
def dtrace = file('/usr/share/lib/java/dtrace.jar')
if (dtrace.exists()) {
def dtraceJar = zipTree('/usr/share/lib/java/dtrace.jar')
if (!dtraceJar.matching { include '**/org/opensolaris/os/dtrace/Consumer.class' }.isEmpty()) {
srcDir 'src/solaris'
}
}
}
resources {
srcDir 'src/share/classes'
}
}
test {
java {
srcDir 'src/test/java'
}
resources {
srcDir 'src/test/resources'
}
}
}
processResources {
from 'src/share/classes'
destinationDir compileJava.destinationDir
include '**/com/sun/btrace/resources/**'
include '**/com/sun/btrace/runtime/jaxb.index'
include '**/com/sun/btrace/annotations/jaxb.index'
def buildDate = (new Date()).format('YYYYMMdd')
filter{ it.replaceAll('\\{btrace.version\\}', "$version ($buildDate)") }
includeEmptyDirs = false
}
compileTestJava {
exclude 'traces'
}
processTestResources {
from 'src/test'
destinationDir compileTestJava.destinationDir
include 'traces/**/*.java'
include 'traces/**/*.xml'
include 'resources/classdata/**/*.clazz'
include 'resources/classdata/**/*.class'
include 'resources/classdata/**/*.btrc'
}
test {
testLogging {
events "failed"
exceptionFormat "short"
}
}
task unjar(type: Copy) {
group 'Build'
description 'Explode the pre-built asm jar.'
from([
zipTree("lib/btrace-asm-${asmVersion}.jar"),
zipTree("lib/btrace-jctools-core-${jcToolsVersion}.jar")
])
into compileJava.destinationDir
}
['agent', 'boot', 'client'].each { name ->
tasks.create(name: "${name}Jar", type: Jar) {
group 'Build'
description "Build the btrace-${name} jar."
inputs.files unjar.outputs
appendix name
from sourceSets.main.output
exclude excludes["${name}"]
destinationDir buildDir
// unfortunately there's a hard-coded reference to "btrace-${name}.jar" in the code - so we have to strip the version
archiveName "$baseName-$appendix.$extension"
if (['agent', 'client'].contains(name)) {
manifest {
// alternatively we could "inline" the ${name}-manfifest's content
from file("src/share/classes/META-INF/${name}-manifest.mf")
}
}
}
tasks.create(name: "${name}SourcesJar", type: Jar) {
group 'Documentation'
description "Build the btrace-${name} sources jar."
appendix "${name}"
classifier 'sources'
from sourceSets.main.allSource
exclude excludes["${name}"]
}
tasks.create(name: "${name}Javadoc", type: Javadoc) {
group 'Documentation'
description "Generates Javadoc API documentation for the btrace-${name}."
title = "btrace-${name}"
source = sourceSets.main.allJava
destinationDir = file("${project.docsDir}/${name}/javadoc")
classpath = files(compileJava.destinationDir) + configurations.compile.asFileTree
exclude excludes["${name}"]
options.addStringOption('Xdoclint:all,-missing', '-quiet')
failOnError false
}
tasks.create(name: "${name}JavadocJar", type: Jar) {
group 'Documentation'
description "Build the btrace-${name} javadoc jar."
appendix name
classifier 'javadoc'
from tasks["${name}Javadoc"].getOutputs()
}
}
javadoc {
classpath = files(compileJava.destinationDir) + configurations.compile.asFileTree
options.addStringOption('Xdoclint:all,-missing', '-quiet')
failOnError false
}
task buildTraces(type: Exec) {
group 'Build'
inputs.files clientJar.outputs
inputs.files testClasses.outputs
inputs.dir "src/test/traces"
outputs.dir "${buildDir}/classes/traces"
workingDir "$projectDir"
environment('BTRACE_HOME', "$projectDir")
def btracec = (osFamily == 'windows') ? 'btracec.bat' : 'btracec'
executable "bin/${btracec}"
args "-cp ${buildDir}/classes/java/test"
args "-d ${buildDir}/classes/"
args fileTree(dir: "src/test/traces", include: '**/*.java', exclude: 'verifier/**/*.java')
}
task buildDTrace(type:Exec) {
group 'Build'
description 'Build the native library for DTrace integration'
onlyIf {osName == 'SunOS'}
inputs.dir 'src/solaris/native'
inputs.files bootJar.outputs
outputs.dir "${buildDir}/i386"
workingDir 'make'
commandLine 'make'
}
def distContent = copySpec {
into('bin') {
from 'bin'
}
into('build') {
from "$buildDir"
include '*.jar'
include 'i386/*.so'
}
into ('docs') {
from 'docs'
include 'javadoc/**'
include 'usersguide.html'
}
into ('samples') {
from 'samples'
}
into('.') {
from '.'
include '*.md'
include '*.txt'
include 'COPYRIGHT'
include 'LICENSE'
}
}
task createBinDistZip(type: Zip) {
group 'Build'
description 'Build the binary distribution zip-file.'
inputs.files agentJar.outputs
inputs.files bootJar.outputs
inputs.files clientJar.outputs
inputs.files buildDTrace.outputs
appendix = 'bin'
with distContent
}
task createBinDistTgz(type: Tar) {
group 'Build'
description 'Build the binary distribution tgz-file.'
inputs.files agentJar.outputs
inputs.files bootJar.outputs
inputs.files clientJar.outputs
inputs.files buildDTrace.outputs
compression = Compression.GZIP
appendix = 'bin'
with distContent
}
ospackage {
maintainer = 'Jaroslav Bachorik'
if (project.version.endsWith('-SNAPSHOT')) {
version = project.version - '-SNAPSHOT'
release = (new Date()).format('YYYYMMdd.HHmmss')
}
postInstall file('packaging/debian/btrace/DEBIAN/postinst')
requires('openjdk-7-jdk').or('openjdk-8-jdk')
from(buildDir) {
into '/usr/lib/btrace'
include 'btrace-*.jar'
}
from('packaging/debian/btrace/usr/bin') {
into '/usr/bin'
}
}
buildDeb {
inputs.files agentJar.outputs
inputs.files bootJar.outputs
inputs.files clientJar.outputs
}
buildRpm {
inputs.files agentJar.outputs
inputs.files bootJar.outputs
inputs.files clientJar.outputs
}
task buildDistributions {
dependsOn createBinDistZip, createBinDistTgz
dependsOn buildDeb, buildRpm
}
test {
dependsOn cleanTest
inputs.files buildTraces.outputs
inputs.files buildDTrace.outputs
testLogging.showStandardStreams = true
}
dependencies {
compile files("lib/btrace-asm-${asmVersion}.jar",
"lib/btrace-jctools-core-${jcToolsVersion}.jar",
"${javaHome}/lib/tools.jar", // ATTENTION: build.xml uses "${javaHome}/../lib/tools.jar"
files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs()),
"/usr/share/lib/java/dtrace.jar")
testCompile files("test-lib/asm-all-${asmVersion}.jar",
"test-lib/junit-${junitVersion}.jar")
testRuntime files("%buildDir/btrace-agent.jar") {
builtBy 'agentJar'
}
testRuntime files("%buildDir/btrace-boot.jar") {
builtBy 'bootJar'
}
testRuntime files("$buildDir/btrace-client.jar") {
builtBy 'clientJar'
}
}
publishing {
publications {
agent(MavenPublication) {
artifactId 'btrace-agent'
artifact agentJar
artifact agentSourcesJar {
classifier "source"
}
artifact agentJavadocJar {
classifier "javadoc"
}
pom.withXml {
asNode().children().last() + pomDetails
}
}
client(MavenPublication) {
artifactId 'btrace-client'
artifact clientJar
artifact clientSourcesJar {
classifier "sources"
}
artifact clientJavadocJar {
classifier "javadoc"
}
pom.withXml {
asNode().children().last() + pomDetails
}
}
boot(MavenPublication) {
artifactId 'btrace-boot'
artifact bootJar
artifact bootSourcesJar {
classifier "sources"
}
artifact bootJavadocJar {
classifier "javadoc"
}
pom.withXml {
asNode().children().last() + pomDetails
}
}
}
/* ---- configure the repository URL . . .
repositories {
maven {
if (version endsWith('-SNAPSHOT') {
url 'https://oss.sonatype.org/content/repositories/snapshots'
} else {
// signing is missing!
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
}
}
}
*/
}
jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}
check.dependsOn jacocoTestReport