forked from census-instrumentation/opencensus-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
420 lines (378 loc) · 16.9 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
buildscript {
repositories {
mavenCentral()
mavenLocal()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.2'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.13'
classpath "net.ltgt.gradle:gradle-apt-plugin:0.10"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
classpath "gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.6"
}
}
// Display the version report using: ./gradlew dependencyUpdates
// Also see https://github.com/ben-manes/gradle-versions-plugin.
apply plugin: 'com.github.ben-manes.versions'
// Don't use the Checker Framework by default, since it interferes with Error Prone.
def useCheckerFramework = rootProject.hasProperty('checkerFramework')
def useErrorProne = !useCheckerFramework
subprojects {
apply plugin: "checkstyle"
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: "signing"
apply plugin: "jacoco"
// The plugin only has an effect if a signature is specified
apply plugin: 'ru.vyarus.animalsniffer'
apply plugin: 'findbugs'
apply plugin: 'net.ltgt.apt'
// Plugins that require java8
if (JavaVersion.current().isJava8Compatible()) {
if (useErrorProne) {
apply plugin: "net.ltgt.errorprone"
}
apply plugin: 'com.github.sherter.google-java-format'
}
group = "io.opencensus"
version = "0.13.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION
sourceCompatibility = 1.6
targetCompatibility = 1.6
repositories {
mavenCentral()
mavenLocal()
}
if (useCheckerFramework) {
configurations {
checkerFrameworkJavac {
description = 'a customization of the Open JDK javac compiler with additional support for type annotations'
}
checkerFrameworkAnnotatedJDK {
description = 'a copy of JDK classes with Checker Framework type qualifiers inserted'
}
}
}
[compileJava, compileTestJava].each() {
// 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.
// We suppress the "processing" warning as suggested in
// https://groups.google.com/forum/#!topic/bazel-discuss/_R3A9TJSoPM
it.options.compilerArgs += ["-Xlint:all", "-Xlint:-try", "-Xlint:-processing"]
if (useErrorProne) {
if (JavaVersion.current().isJava8Compatible()) {
it.options.compilerArgs += ["-XepDisableWarningsInGeneratedCode"]
// TODO(bdrutu): Read files directly instead of reading from properties.
if (rootProject.hasProperty("errorProneWarnings")) {
it.options.compilerArgs += rootProject.properties["errorProneWarnings"].split(',').collect {
it as String
}
}
if (rootProject.hasProperty("errorProneExperimentalErrors")) {
it.options.compilerArgs += rootProject.properties["errorProneExperimentalErrors"].split(',').collect {
it as String
}
}
if (rootProject.hasProperty("errorProneExperimentalWarnings")) {
it.options.compilerArgs += rootProject.properties["errorProneExperimentalWarnings"].split(',').collect {
it as String
}
}
if (rootProject.hasProperty("errorProneExperimentalSuggestions")) {
it.options.compilerArgs += rootProject.properties["errorProneExperimentalSuggestions"].split(',').collect {
it as String
}
}
}
}
if (useCheckerFramework) {
it.options.compilerArgs += [
'-processor',
'com.google.auto.value.processor.AutoValueProcessor,org.checkerframework.checker.nullness.NullnessChecker',
"-Astubs=$rootDir/checker-framework/stubs"
]
}
it.options.encoding = "UTF-8"
if (!JavaVersion.current().isJava9()) {
// TODO(sebright): Enable -Werror for Java 9 once we upgrade AutoValue (issue #1017).
it.options.compilerArgs += ["-Werror"]
}
if (JavaVersion.current().isJava7()) {
// Suppress all deprecation warnings with Java 7, since there are some bugs in its handling of
// @SuppressWarnings. See
// https://stackoverflow.com/questions/26921774/how-to-avoid-deprecation-warnings-when-suppresswarningsdeprecation-doesnt
it.options.compilerArgs += ["-Xlint:-deprecation"]
// TODO(bdrutu): Enable for Java 7 when fix the issue with configuring bootstrap class.
// [options] bootstrap class path not set in conjunction with -source 1.6
it.options.compilerArgs += ["-Xlint:-options"]
}
if (JavaVersion.current().isJava9()) {
// TODO(sebright): Currently, building with Java 9 produces the following "options" warnings:
//
// :opencensus-api:compileJavawarning: [options] bootstrap class path not set in conjunction with -source 1.6
// warning: [options] source value 1.6 is obsolete and will be removed in a future release
// warning: [options] target value 1.6 is obsolete and will be removed in a future release
it.options.compilerArgs += ["-Xlint:-options"]
}
}
compileTestJava {
// serialVersionUID is basically guaranteed to be useless in tests
options.compilerArgs += ["-Xlint:-serial"]
// It undeprecates DoubleSubject.isEqualTo(Double).
options.compilerArgs += ["-Xlint:-deprecation"]
}
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)
}
javadoc.options {
encoding = 'UTF-8'
links 'https://docs.oracle.com/javase/8/docs/api/'
}
ext {
autoValueVersion = '1.4'
findBugsVersion = '3.0.1'
errorProneVersion = '2.2.0'
grpcVersion = '1.10.0'
guavaVersion = '20.0'
googleAuthVersion = '0.9.0'
googleCloudVersion = '0.34.0-beta'
signalfxVersion = '0.0.39'
prometheusVersion = '0.2.0'
zipkinReporterVersion = '2.3.2'
jaegerReporterVersion = '0.24.0'
libraries = [
auto_value: "com.google.auto.value:auto-value:${autoValueVersion}",
auto_service: 'com.google.auto.service:auto-service:1.0-rc3',
byte_buddy: 'net.bytebuddy:byte-buddy:1.7.11',
config: 'com.typesafe:config:1.2.1',
disruptor: 'com.lmax:disruptor:3.4.1',
errorprone: "com.google.errorprone:error_prone_annotations:${errorProneVersion}",
findbugs_annotations: "com.google.code.findbugs:annotations:${findBugsVersion}",
google_auth: "com.google.auth:google-auth-library-credentials:${googleAuthVersion}",
google_cloud_trace: "com.google.cloud:google-cloud-trace:${googleCloudVersion}",
zipkin_reporter: "io.zipkin.reporter2:zipkin-reporter:${zipkinReporterVersion}",
zipkin_urlconnection: "io.zipkin.reporter2:zipkin-sender-urlconnection:${zipkinReporterVersion}",
jaeger_reporter: "com.uber.jaeger:jaeger-core:${jaegerReporterVersion}",
google_cloud_monitoring: "com.google.cloud:google-cloud-monitoring:${googleCloudVersion}",
grpc_context: "io.grpc:grpc-context:${grpcVersion}",
grpc_core: "io.grpc:grpc-core:${grpcVersion}",
guava: "com.google.guava:guava:${guavaVersion}",
jsr305: "com.google.code.findbugs:jsr305:${findBugsVersion}",
signalfx_java: "com.signalfx.public:signalfx-java:${signalfxVersion}",
prometheus_simpleclient: "io.prometheus:simpleclient:${prometheusVersion}",
// Test dependencies.
guava_testlib: "com.google.guava:guava-testlib:${guavaVersion}",
junit: 'junit:junit:4.12',
mockito: 'org.mockito:mockito-core:1.9.5',
truth: 'com.google.truth:truth:0.30',
]
}
configurations {
compile {
// Detect Maven Enforcer's dependencyConvergence failures. We only
// care for artifacts used as libraries by others.
if (!(project.name in ['benchmarks', 'opencensus-all',
'opencensus-exporter-stats-stackdriver',
'opencensus-exporter-trace-stackdriver'])) {
resolutionStrategy.failOnVersionConflict()
}
}
}
dependencies {
if (useCheckerFramework) {
ext.checkerFrameworkVersion = '2.3.2'
ext.jdkVersion = 'jdk8'
checkerFrameworkAnnotatedJDK "org.checkerframework:${jdkVersion}:${checkerFrameworkVersion}"
checkerFrameworkJavac "org.checkerframework:compiler:${checkerFrameworkVersion}"
compileOnly "org.checkerframework:checker:${checkerFrameworkVersion}"
compile "org.checkerframework:checker-qual:${checkerFrameworkVersion}"
compileOnly libraries.auto_value
}
compileOnly libraries.errorprone,
libraries.jsr305
testCompile libraries.guava_testlib,
libraries.junit,
libraries.mockito,
libraries.truth
if (useErrorProne && JavaVersion.current().isJava8Compatible()) {
// The ErrorProne plugin defaults to the latest, which would break our
// build if error prone releases a new version with a new check
errorprone "com.google.errorprone:error_prone_core:${errorProneVersion}"
}
}
findbugs {
toolVersion = findBugsVersion
ignoreFailures = false // bug free or it doesn't ship!
effort = 'max'
reportLevel = 'low' // low = sensitive to even minor mistakes
omitVisitors = [] // bugs that we want to ignore
excludeFilter = file("$rootDir/findbugs-exclude.xml")
}
// Generate html report for findbugs.
findbugsMain {
reports {
xml.enabled = false
html.enabled = true
}
}
checkstyle {
configFile = file("$rootDir/buildscripts/checkstyle.xml")
toolVersion = "8.0"
ignoreFailures = false
if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
}
configProperties["rootDir"] = rootDir
}
// Disable checkstyle if no java8.
checkstyleMain.enabled = JavaVersion.current().isJava8Compatible()
checkstyleTest.enabled = JavaVersion.current().isJava8Compatible()
// Google formatter works only on java8.
if (JavaVersion.current().isJava8Compatible()) {
googleJavaFormat {
toolVersion '1.5'
}
afterEvaluate { // Allow subproject to add more source sets.
tasks.googleJavaFormat {
source = sourceSets*.allJava
include '**/*.java'
}
tasks.verifyGoogleJavaFormat {
source = sourceSets*.allJava
include '**/*.java'
}
}
}
signing {
required false
sign configurations.archives
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives javadocJar, sourcesJar
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
def configureAuth = {
if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
authentication(userName:rootProject.ossrhUsername, password: rootProject.ossrhPassword)
}
}
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/", configureAuth)
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/", configureAuth)
pom.project {
name "OpenCensus"
packaging 'jar'
description project.description
url 'https://github.com/census-instrumentation/opencensus-java'
scm {
connection 'scm:svn:https://github.com/census-instrumentation/opencensus-java'
developerConnection 'scm:git:git@github.com/census-instrumentation/opencensus-java'
url 'https://github.com/census-instrumentation/opencensus-java'
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'io.opencensus'
name 'OpenCensus Contributors'
email 'census-developers@googlegroups.com'
url 'opencensus.io'
// https://issues.gradle.org/browse/GRADLE-2719
organization = 'OpenCensus Authors'
organizationUrl 'https://www.opencensus.io'
}
}
}
}
}
}
// Upload the following artifacts only:
uploadArchives.onlyIf {
name in ['opencensus-api',
'opencensus-contrib-agent',
'opencensus-contrib-grpc-metrics',
'opencensus-contrib-grpc-util',
'opencensus-contrib-http-util',
'opencensus-contrib-zpages',
'opencensus-exporter-stats-prometheus',
'opencensus-exporter-stats-signalfx',
'opencensus-exporter-stats-stackdriver',
'opencensus-exporter-trace-instana',
'opencensus-exporter-trace-logging',
'opencensus-exporter-trace-stackdriver',
'opencensus-exporter-trace-zipkin',
'opencensus-exporter-trace-jaeger',
'opencensus-impl-core',
'opencensus-impl-lite',
'opencensus-impl',
'opencensus-testing']
}
// 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'
}
if (useCheckerFramework) {
allprojects {
tasks.withType(JavaCompile).all { JavaCompile compile ->
compile.doFirst {
compile.options.compilerArgs += [
'-Xmaxerrs', '10000',
"-Xbootclasspath/p:${configurations.checkerFrameworkAnnotatedJDK.asPath}",
"-AskipDefs=\\.AutoValue_"
]
options.fork = true
options.forkOptions.jvmArgs += ["-Xbootclasspath/p:${configurations.checkerFrameworkJavac.asPath}"]
}
}
}
}
// For projects that depend on gRPC during test execution, make sure to
// also configure ALPN if running on a platform (e.g. FreeBSD) that is not
// supported by io.netty:netty-tcnative-boringssl-static:jar. Also see:
// https://github.com/grpc/grpc-java/blob/master/SECURITY.md#tls-with-jdk-jetty-alpnnpn
if (project.name in ['opencensus-exporter-stats-stackdriver',
'opencensus-exporter-trace-stackdriver']) {
def os = org.gradle.internal.os.OperatingSystem.current()
if (!os.isLinux() && !os.isWindows() && !os.isMacOsX()) {
configurations {
alpn
}
dependencies {
alpn 'org.mortbay.jetty.alpn:jetty-alpn-agent:2.0.7'
}
test {
jvmArgs "-javaagent:${configurations.alpn.asPath}"
}
}
}
}