forked from btraceio/btrace
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
389 lines (331 loc) · 11.9 KB
/
Copy pathbuild.gradle
File metadata and controls
389 lines (331 loc) · 11.9 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
plugins {
id 'maven-publish'
id "com.github.johnrengelman.shadow" version "7.1.2"
id "nebula.ospackage" version "9.1.0"
id "java"
id "io.sdkman.vendors" version "3.0.0"
id "signing"
}
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.internal.os.OperatingSystem
repositories {
mavenCentral()
}
def distBase = "${project.buildDir}/resources/main"
def distTarget = "${distBase}/v${project.version}"
def libsDir = new File("${distTarget}/libs")
configurations {
artifact.extendsFrom implementation
}
dependencies {
implementation project(':btrace-agent')
implementation project(':btrace-client')
implementation project(':btrace-compiler')
}
jar {
onlyIf { false }
}
sourcesJar {
onlyIf { false }
}
sourceSets {
main {
output.resourcesDir = file("${distTarget}")
}
}
artifacts {
archives file("${distTarget}/libs/btrace-agent.jar")
}
task agentJar(type: ShadowJar) {
group 'Build'
baseName = 'btrace-agent'
version = null
classifier = null
destinationDir = libsDir
manifest {
attributes(
"Premain-Class": "shadedbtrace.org.openjdk.btrace.agent.Main",
"Agent-Class": "shadedbtrace.org.openjdk.btrace.agent.Main",
"Can-Redefine-Classes": true,
"Can-Retransform-Classes": true,
"Boot-Class-Path": "btrace-boot.jar"
)
}
include {
if (it.directory) {
return true
}
if (it.path.endsWith('.jar')) {
return true
}
return it.path.startsWith('org/openjdk/btrace/agent/') ||
it.path.startsWith('org/openjdk/btrace/instr/') ||
// include the messages resource bundle and class in the agent jar (bootstrap can't load resources)
it.path == 'org/openjdk/btrace/core/Messages.class' ||
it.path == 'org/openjdk/btrace/core/messages.properties'
}
configurations = [project.configurations.artifact]
relocate 'org.jctools', 'org.openjdk.btrace.libs.org.jctools'
relocate 'org.objectweb.asm', 'org.openjdk.btrace.libs.org.objectweb.asm'
}
task bootJar(type: ShadowJar) {
group 'Build'
baseName = 'btrace-boot'
version = null
classifier = null
destinationDir = libsDir
include {
if (it.directory) {
return true
}
if (it.path.endsWith('.jar')) {
return true
}
if (it.path.startsWith('org/openjdk/btrace/core/')) {
if (it.path == 'org/openjdk/btrace/core/Messages.class' || it.path == 'org/openjdk/btrace/core/messages.properties') {
// messages resource bundle&class are hoisted to agent and client jars
return false
}
return true
}
if (it.path.startsWith('org/jctools/')) {
if (it.path.startsWith('org/jctools/map/')) {
return false
}
return true
}
if (it.path.startsWith('org/objectweb/asm/')) {
if (it.path.startsWith('org/objectweb/asm/commons/') ||
it.path.startsWith('org/objectweb/asm/util/') ||
it.path.startsWith('org/objectweb/asm/xml/')) {
return false
}
return true
}
return it.path.startsWith('org/openjdk/btrace/runtime/') ||
it.path.startsWith('org/openjdk/btrace/services/') ||
it.path.startsWith('org/openjdk/btrace/statsd/')
}
configurations = [project.configurations.artifact]
relocate 'org.jctools', 'org.openjdk.btrace.libs.org.jctools'
relocate 'org.objectweb.asm', 'org.openjdk.btrace.libs.org.objectweb.asm'
}
task clientJar(type: ShadowJar) {
group 'Build'
baseName = 'btrace-client'
version = null
classifier = null
destinationDir = libsDir
exclude 'afu/**'
exclude 'javax/**'
exclude 'com/**'
exclude 'sun/**'
exclude 'org/relaxng/**'
exclude 'org/checkerframework/**'
exclude 'org/codehaus/**'
exclude 'org/jctools/maps/**'
exclude 'org/jctools/util/**'
exclude 'META-INF/services/com.sun.*'
exclude 'META-INF/services/javax.annotation.*'
exclude 'org/objectweb/asm/xml/**'
exclude 'org/openjdk/btrace/agent/**'
configurations = [project.configurations.artifact]
relocate 'org.jctools', 'org.openjdk.btrace.libs.org.jctools'
relocate 'org.objectweb.asm', 'org.openjdk.btrace.libs.org.objectweb.asm'
}
task fixPermissions(type: Exec) {
onlyIf {
!OperatingSystem.current().isWindows()
}
commandLine 'chmod', '500', "${distTarget}/bin/btrace"
commandLine 'chmod', '500', "${distTarget}/bin/btracec"
commandLine 'chmod', '500', "${distTarget}/bin/btracer"
}
task copyDtraceLib(type: Copy) {
from "${projectDir}/../btrace-dtrace/build/dtrace/libs"
into "${distTarget}/libs/"
}
task buildZip(type: Zip) {
from "${distTarget}"
include "**/*"
archiveName "btrace-v${project.version}-bin.zip"
destinationDir(file("$project.buildDir/distributions"))
}
task buildSdkmanZip(type: Zip) {
from "${distBase}"
include "**/*"
archiveName "btrace-v${project.version}-sdkman-bin.zip"
destinationDir(file("$project.buildDir/distributions"))
}
task buildTgz(type: Tar) {
archiveName "btrace-v${project.version}-bin.tar.gz"
into ('/'){
from "${distTarget}"
include '**/*'
}
destinationDir file("$project.buildDir/distributions")
extension 'tar.gz'
compression = Compression.GZIP
}
ospackage {
packageName = 'btrace'
release = 1
os = LINUX
into '/opt/btrace'
from("${distTarget}/bin") {
into 'bin'
fileMode 0550
}
from("${distTarget}/libs") {
into 'libs'
}
from("${distTarget}/docs") {
into 'docs'
}
from("${distTarget}/samples") {
into 'samples'
}
link('/usr/local/bin/btrace', '/opt/btrace/bin/btrace')
link('/usr/local/bin/btracer', '/opt/btrace/bin/btracer')
link('/usr/local/bin/btracec', '/opt/btrace/bin/btracec')
}
buildDeb {
requires('openjdk-8-jdk')
}
copyDtraceLib.dependsOn project(':btrace-dtrace').build
shadowJar.dependsOn agentJar, bootJar, clientJar, copyDtraceLib
buildTgz.dependsOn agentJar, bootJar, clientJar, fixPermissions, copyDtraceLib, processResources
buildZip.dependsOn agentJar, bootJar, clientJar, fixPermissions, copyDtraceLib, processResources
buildSdkmanZip.dependsOn agentJar, bootJar, clientJar, fixPermissions, copyDtraceLib, processResources
buildDeb.dependsOn agentJar, bootJar, clientJar, fixPermissions, copyDtraceLib, processResources
buildRpm.dependsOn agentJar, bootJar, clientJar, fixPermissions, copyDtraceLib, processResources
build.dependsOn buildSdkmanZip, buildZip, buildTgz, buildDeb, buildRpm
test {
doLast {
project(':btrace-instr').tasks.test.execute()
}
}
['agent', 'boot', 'client'].each { name ->
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.artifact.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()
}
}
sdkman {
consumerKey = project.hasProperty("sdkman.key") ? project.property("sdkman.key") : System.getenv('SDKMAN_API_KEY')
consumerToken = project.hasProperty("sdkman.token") ? project.property("sdkman.token") : System.getenv('SDKMAN_API_TOKEN')
candidate = "btrace"
version = "${project.version}"
url = "https://github.com/btraceio/btrace/releases/download/v${project.version}/btrace-v${project.version}-sdkman-bin.zip"
hashtag = "btrace"
}
["sdkReleaseVersion", "sdkAnnounceVersion"].forEach {
tasks[it].onlyIf {
!project.version.toString().endsWith("-SNAPSHOT")
}
}
publishing {
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = project.hasProperty("sonatype.user") ? project.property("sonatype.user") : System.getenv('BTRACE_SONATYPE_USER')
password = project.hasProperty("sonatype.password") ? project.property("sonatype.password") : System.getenv('BTRACE_SONATYPE_PWD')
}
}
}
publications {
agent(MavenPublication) {
artifactId 'btrace-agent'
groupId 'io.btrace'
artifact agentJar
artifact agentSourcesJar {
classifier "sources"
}
artifact agentJavadocJar {
classifier "javadoc"
}
pom.withXml {
addPomDetails(asNode(), 'btrace-agent')
}
}
client(MavenPublication) {
artifactId 'btrace-client'
groupId 'io.btrace'
artifact clientJar
artifact clientSourcesJar {
classifier "sources"
}
artifact clientJavadocJar {
classifier "javadoc"
}
pom.withXml {
addPomDetails(asNode(), 'btrace-client')
}
}
boot(MavenPublication) {
artifactId 'btrace-boot'
groupId 'io.btrace'
artifact bootJar
artifact bootSourcesJar {
classifier "sources"
}
artifact bootJavadocJar {
classifier "javadoc"
}
pom.withXml {
addPomDetails(asNode(), 'btrace-boot')
}
}
}
}
def addPomDetails(node, name) {
node.appendNode('name', name)
node.appendNode('url', 'https://github.com/btraceio/btrace')
node.appendNode('description', 'BTrace: A safe, dynamic tracing tool for the Java platform')
def scmNode = node.appendNode('scm')
scmNode.appendNode('url', 'https://github.com/btraceio/btrace')
scmNode.appendNode('connection', 'scm:git:https://github.com/btraceio/btrace.git')
scmNode.appendNode('developerConnection', 'scm:git:https://github.com/btraceio/btrace.git')
def licenseNode = node.appendNode('licenses').appendNode('license')
licenseNode.appendNode('name', 'GNU General Public License, version 2, with the Classpath Exception')
licenseNode.appendNode('url', 'http://openjdk.java.net/legal/gplv2+ce.html')
def developerNode = node.appendNode('developers').appendNode('developer')
developerNode.appendNode('id', 'jbachorik')
developerNode.appendNode('name', 'Jaroslav Bachorik')
developerNode.appendNode('email', 'j.bachorik@btrace.io')
}
signing {
def signingKey = project.hasProperty('gpg.signing.key') ? project.property('gpg.signing.key') : System.getenv("GPG_SIGNING_KEY")
def signingPwd = project.hasProperty('gpg.signing.pwd') ? project.property('gpg.signing.pwd') : System.getenv("GPG_SIGNING_PWD")
if (signingKey != null && signingPwd != null) {
useInMemoryPgpKeys(signingKey, signingPwd)
}
sign publishing.publications.agent
sign publishing.publications.boot
sign publishing.publications.client
}