forked from open-telemetry/opentelemetry-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
451 lines (385 loc) · 16.8 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
plugins {
id "com.github.sherter.google-java-format" apply false
id "com.jfrog.artifactory" apply false
id "com.jfrog.bintray" version "1.8.4" apply false // Need *specific* version.
id "net.ltgt.errorprone" apply false
id "ru.vyarus.animalsniffer" apply false
id "io.morethan.jmhreport" apply false
}
ext {
opentelemetryProjects = subprojects - project(":opentelemetry-bom")
}
subprojects {
group = "io.opentelemetry"
version = "0.9.0-SNAPSHOT" // CURRENT_OPEN_TELEMETRY_VERSION
plugins.withId("maven-publish") {
// Always include the artifactory/bintray plugins to do the deployment.
pluginManager.apply "com.jfrog.artifactory"
pluginManager.apply "com.jfrog.bintray"
publishing {
publications {
mavenPublication(MavenPublication) {
version version
groupId group
plugins.withId("java-platform") {
from(components["javaPlatform"])
}
plugins.withId("java-library") {
from(components["java"])
}
versionMapping {
allVariants {
fromResolutionResult()
}
}
pom {
name = 'OpenTelemetry Java'
packaging = 'jar'
url = 'https://github.com/open-telemetry/opentelemetry-java'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'opentelemetry'
name = 'OpenTelemetry Gitter'
url = 'https://gitter.im/open-telemetry/community'
}
}
scm {
connection = 'scm:git:[email protected]:open-telemetry/opentelemetry-java.git'
developerConnection = 'scm:git:[email protected]:open-telemetry/opentelemetry-java.git'
url = '[email protected]:open-telemetry/opentelemetry-java.git'
}
afterEvaluate {
// description is not available until evaluated.
description = project.description
}
}
}
}
}
// Snapshot publishing.
artifactory {
contextUrl = 'https://oss.jfrog.org'
publish {
repository {
repoKey = 'oss-snapshot-local'
username = System.getenv("BINTRAY_USER")
password = System.getenv("BINTRAY_KEY")
}
defaults {
publications('mavenPublication')
publishArtifacts = true
publishPom = true
}
}
resolve {
repoKey = 'libs-release'
}
}
// Release artifacts publishing.
bintray {
user = System.getenv("BINTRAY_USER")
key = System.getenv("BINTRAY_KEY")
publications = ['mavenPublication']
publish = true
pkg {
repo = 'maven'
name = 'opentelemetry-java'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/open-telemetry/opentelemetry-java.git'
userOrg = 'open-telemetry'
githubRepo = 'open-telemetry/opentelemetry-java'
version {
name = project.version
gpg {
sign = true
}
mavenCentralSync {
user = System.getenv("SONATYPE_USER")
password = System.getenv("SONATYPE_KEY")
}
}
}
}
}
}
configure(opentelemetryProjects) {
apply plugin: 'checkstyle'
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'idea'
apply plugin: 'signing'
apply plugin: 'jacoco'
apply plugin: 'com.github.sherter.google-java-format'
apply plugin: 'net.ltgt.errorprone'
repositories {
mavenCentral()
jcenter()
mavenLocal()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
java {
withJavadocJar()
withSourcesJar()
}
tasks.withType(JavaCompile) {
it.options.compilerArgs += [
"-Xlint:all",
// We suppress the "try" warning because it disallows managing an auto-closeable with
// try-with-resources without referencing the auto-closeable within the try block.
"-Xlint:-try",
// We suppress the "processing" warning as suggested in
// https://groups.google.com/forum/#!topic/bazel-discuss/_R3A9TJSoPM
"-Xlint:-processing",
// We suppress the "options" warning because it prevents compilation on modern JDKs
"-Xlint:-options",
]
it.options.errorprone.disableWarningsInGeneratedCode = true
it.options.errorprone.allDisabledChecksAsWarnings = true
// Doesn't currently use Var annotations.
it.options.errorprone.disable("Var") // "-Xep:Var:OFF"
// ImmutableRefactoring suggests using com.google.errorprone.annotations.Immutable,
// but currently uses javax.annotation.concurrent.Immutable
it.options.errorprone.disable("ImmutableRefactoring") // "-Xep:ImmutableRefactoring:OFF"
// AutoValueImmutableFields suggests returning Guava types from API methods
it.options.errorprone.disable("AutoValueImmutableFields")
// "-Xep:AutoValueImmutableFields:OFF"
it.options.encoding = "UTF-8"
// Ignore warnings for protobuf and jmh generated files.
it.options.errorprone.excludedPaths = ".*generated.*"
// "-XepExcludedPaths:.*/build/generated/source/proto/.*"
it.options.errorprone.disable("Java7ApiChecker")
it.options.errorprone.disable("AndroidJdkLibsChecker")
//apparently disabling android doesn't disable this
it.options.errorprone.disable("StaticOrDefaultInterfaceMethod")
//until we have everything converted, we need these
it.options.errorprone.disable("JdkObsolete")
it.options.errorprone.disable("UnnecessaryAnonymousClass")
it.options.compilerArgs += ["-Werror"]
}
compileTestJava {
// serialVersionUID is basically guaranteed to be useless in tests
options.compilerArgs += ["-Xlint:-serial"]
// Disable Java7 checks in test sources
// options.errorprone.disable("Java7ApiChecker")
// Disable AndroidJdkLibs checks in test sources
// options.errorprone.disable("AndroidJdkLibsChecker")
}
jar.manifest {
attributes('Implementation-Title': name,
'Implementation-Version': version,
'Built-By': System.getProperty('user.name'),
'Built-JDK': System.getProperty('java.version'),
'Source-Compatibility': sourceCompatibility,
'Target-Compatibility': targetCompatibility)
}
ext {
autoValueVersion = '1.7.4'
errorProneVersion = '2.4.0'
errorProneJavacVersion = '9+181-r4173-1'
findBugsJsr305Version = '3.0.2'
grpcVersion = '1.30.2'
guavaVersion = '28.2-android'
jmhVersion = '1.19'
junitVersion = '5.6.2'
mockitoVersion = '3.3.3'
opentracingVersion = '0.33.0'
prometheusVersion = '0.8.1'
protobufVersion = '3.11.4'
protocVersion = '3.11.4'
zipkinReporterVersion = '2.12.2'
zipkinVersion = '2.18.3'
boms = [
grpc : "io.grpc:grpc-bom:${grpcVersion}",
guava : "com.google.guava:guava-bom:${guavaVersion}",
junit : "org.junit:junit-bom:${junitVersion}",
protobuf : "com.google.protobuf:protobuf-bom:${protobufVersion}",
zipkin_reporter: "io.zipkin.reporter2:zipkin-reporter-bom:${zipkinReporterVersion}"
]
libraries = [
auto_value : "com.google.auto.value:auto-value:${autoValueVersion}",
auto_value_annotation : "com.google.auto.value:auto-value-annotations:${autoValueVersion}",
disruptor : "com.lmax:disruptor:3.4.2",
errorprone_annotation : "com.google.errorprone:error_prone_annotations:${errorProneVersion}",
errorprone_core : "com.google.errorprone:error_prone_core:${errorProneVersion}",
errorprone_javac : "com.google.errorprone:javac:${errorProneJavacVersion}",
grpc_api : "io.grpc:grpc-api",
grpc_context : "io.grpc:grpc-context",
grpc_protobuf : "io.grpc:grpc-protobuf",
grpc_stub : "io.grpc:grpc-stub",
guava : "com.google.guava:guava",
javax_annotations : "javax.annotation:javax.annotation-api:1.3.2",
jmh_core : "org.openjdk.jmh:jmh-core:${jmhVersion}",
jmh_bytecode : "org.openjdk.jmh:jmh-generator-bytecode:${jmhVersion}",
jsr305 : "com.google.code.findbugs:jsr305:${findBugsJsr305Version}",
prometheus_client : "io.prometheus:simpleclient:${prometheusVersion}",
prometheus_client_common: "io.prometheus:simpleclient_common:${prometheusVersion}",
protobuf : "com.google.protobuf:protobuf-java",
protobuf_util : "com.google.protobuf:protobuf-java-util",
zipkin_reporter : "io.zipkin.reporter2:zipkin-reporter",
zipkin_okhttp : "io.zipkin.reporter2:zipkin-sender-okhttp3",
// Compatibility layer
opentracing : "io.opentracing:opentracing-api:${opentracingVersion}",
// Test dependencies.
assertj : "org.assertj:assertj-core:3.16.1",
guava_testlib : "com.google.guava:guava-testlib",
junit : 'junit:junit:4.12',
junit_pioneer : 'org.junit-pioneer:junit-pioneer:0.7.0',
junit_jupiter_api : 'org.junit.jupiter:junit-jupiter-api',
junit_jupiter_engine : 'org.junit.jupiter:junit-jupiter-engine',
junit_vintage_engine : 'org.junit.vintage:junit-vintage-engine',
mockito : "org.mockito:mockito-core:${mockitoVersion}",
mockito_junit_jupiter : "org.mockito:mockito-junit-jupiter:${mockitoVersion}",
system_rules : 'com.github.stefanbirkner:system-rules:1.19.0', // env and system properties
slf4jsimple : 'org.slf4j:slf4j-simple:1.7.25', // Compatibility layer
awaitility : 'org.awaitility:awaitility:3.0.0', // Compatibility layer
testcontainers : 'org.testcontainers:junit-jupiter:1.13.0',
rest_assured : 'io.rest-assured:rest-assured:4.2.0',
jaeger_client : 'io.jaegertracing:jaeger-client:1.2.0', // Jaeger Client
zipkin_junit : "io.zipkin.zipkin2:zipkin-junit:${zipkinVersion}", // Zipkin JUnit rule
archunit : 'com.tngtech.archunit:archunit-junit4:0.13.1' //Architectural constraints
]
}
checkstyle {
configFile = file("$rootDir/buildscripts/checkstyle.xml")
toolVersion = "8.12"
ignoreFailures = false
configProperties["rootDir"] = rootDir
}
jacoco { toolVersion = "0.8.5" }
googleJavaFormat {
toolVersion = '1.7'
}
configurations {
compile {
// Detect Maven Enforcer's dependencyConvergence failures. We only
// care for artifacts used as libraries by others.
// TODO: Enable failOnVersionConflict()
resolutionStrategy.preferProjectModules()
}
}
dependencies {
configurations.all {
if (it.name.endsWith('Classpath')) {
add(it.name, enforcedPlatform(boms.grpc))
add(it.name, enforcedPlatform(boms.guava))
add(it.name, enforcedPlatform(boms.junit))
add(it.name, enforcedPlatform(boms.protobuf))
add(it.name, enforcedPlatform(boms.zipkin_reporter))
}
}
compileOnly libraries.auto_value_annotation,
libraries.errorprone_annotation,
libraries.jsr305
testImplementation libraries.junit_jupiter_api,
libraries.mockito,
libraries.mockito_junit_jupiter,
libraries.assertj,
libraries.guava_testlib
testRuntimeOnly libraries.junit_jupiter_engine,
libraries.junit_vintage_engine
// The ErrorProne plugin defaults to the latest, which would break our
// build if error prone releases a new version with a new check
errorprone libraries.errorprone_core
if (!JavaVersion.current().isJava9Compatible()) {
errorproneJavac libraries.errorprone_javac
}
if (JavaVersion.current().isJava9Compatible()) {
// Workaround for @javax.annotation.Generated
// see: https://github.com/grpc/grpc-java/issues/3633
compileOnly libraries.javax_annotations
}
}
test {
systemProperties project.properties.subMap(["enable.docker.tests"])
useJUnitPlatform()
}
javadoc.options {
source = "8"
encoding = "UTF-8"
links 'https://docs.oracle.com/javase/8/docs/api/'
addBooleanOption('Xdoclint:all,-missing', true)
}
afterEvaluate { // Allow subproject to add more source sets.
tasks.googleJavaFormat {
source = sourceSets*.allJava
include '**/*.java'
}
tasks.verifyGoogleJavaFormat {
source = sourceSets*.allJava
include '**/*.java'
}
jar {
inputs.property("moduleName", moduleName)
manifest {
attributes('Automatic-Module-Name': moduleName)
}
}
}
signing {
required false
sign configurations.archives
}
// At a test failure, log the stack trace to the console so that we don't
// have to open the HTML in a browser.
test {
testLogging {
exceptionFormat = 'full'
showExceptions = true
showCauses = true
showStackTraces = true
}
maxHeapSize = '1500m'
}
plugins.withId("ru.vyarus.animalsniffer") {
animalsnifferTest {
enabled = false
}
// If JMH enabled ignore animalsniffer.
plugins.withId("me.champeau.gradle.jmh") {
animalsnifferJmh {
enabled = false
}
}
}
plugins.withId("me.champeau.gradle.jmh") {
// Always include the jmhreport plugin and run it after jmh task.
pluginManager.apply "io.morethan.jmhreport"
dependencies {
jmh libraries.jmh_core,
libraries.jmh_bytecode
}
// invoke jmh on a single benchmark class like so:
// ./gradlew -PjmhIncludeSingleClass=StatsTraceContextBenchmark clean :grpc-core:jmh
jmh {
failOnError = true
resultFormat = 'JSON'
// Otherwise an error will happen:
// Could not expand ZIP 'byte-buddy-agent-1.9.7.jar'.
includeTests = false
profilers = ["gc"]
if (project.hasProperty('jmhIncludeSingleClass')) {
include = [
project.property('jmhIncludeSingleClass')
]
}
}
jmhReport {
jmhResultPath = project.file("${project.buildDir}/reports/jmh/results.json")
jmhReportOutput = project.file("${project.buildDir}/reports/jmh")
}
// Always run jmhReport after jmh task.
tasks.jmh.finalizedBy tasks.jmhReport
}
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
gradleVersion = '6.5.1'
}