-
Notifications
You must be signed in to change notification settings - Fork 38
/
build.gradle
328 lines (302 loc) · 12.2 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
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import nebula.plugin.release.git.opinion.Strategies
plugins {
id "com.diffplug.spotless"
id 'nebula.release'
}
// Required with spotless v6+
// See https://github.com/diffplug/spotless/issues/984 for details
spotless {
predeclareDepsFromBuildscript()
}
// Need to predeclare every configuration used with spotless
spotlessPredeclare {
java {
googleJavaFormat("1.10.0")
}
groovyGradle {
greclipse()
}
}
// Format the root build too.
spotless {
groovyGradle {
target '*.gradle' // default target of groovyGradle
greclipse()
licenseHeaderFile rootProject.file('buildscripts/spotless.license.gradle'), '(import|pluginManagement)'
}
yaml {
target "*.yaml"
licenseHeaderFile rootProject.file('buildscripts/spotless.license.yaml'), '([a-zA-Z]*:)'
}
format 'dockerfile', {
target '*Dockerfile'
licenseHeaderFile rootProject.file('buildscripts/spotless.license.dockerfile'), '(\\s+|FROM)'
}
}
// Configure release mechanism.
// Nebula plugin will not configure if .git doesn't exist, let's allow building on it by stubbing it
// out. This supports building from the zip archive downloaded from GitHub.
def releaseTask
if (file('.git').exists()) {
release {
defaultVersionStrategy = Strategies.getSNAPSHOT()
}
nebulaRelease {
addReleaseBranchPattern(/v\d+\.\d+\.x/)
}
releaseTask = tasks.named("release")
releaseTask.configure {
mustRunAfter("snapshotSetup", "finalSetup")
}
} else {
releaseTask = tasks.register('release')
}
ext.isReleaseVersion = !version.toString().endsWith("-SNAPSHOT")
subprojects {
apply plugin: 'jacoco'
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'nebula.release'
group = "com.google.cloud.opentelemetry"
// Note: Version now comes from nebula plugin
repositories {
mavenCentral()
mavenLocal()
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/snapshot" }
}
// Set up java codestyle checking and correction.
plugins.withId("java") {
plugins.apply('com.diffplug.spotless')
// Configure our default module name for maven publishing
archivesBaseName = "${project.name}"
}
// Support for some higher language versions can only be achieved using Toolchains.
// Compatibility matrix at https://docs.gradle.org/current/userguide/compatibility.html#java
// See https://docs.gradle.org/current/userguide/toolchains.html#toolchains
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
// This ensures bytecode compatibility with Java 8 by ensuring that symbols not
// available in Java 8 are not used in the source code.
// This is equivalent of setting --release flag in Java compiler introduced in Java 9.
// Note that the toolchain used is Java 11 - which means Java 11 is required
// to build this project.
compileJava {
it.options.release = 8
}
// Include license check and auto-format support.
spotless {
java {
googleJavaFormat("1.10.0")
licenseHeaderFile rootProject.file('buildscripts/spotless.license.java'), '(package|import|class|// Includes work from:)'
}
groovyGradle {
target '*.gradle' // default target of groovyGradle
greclipse()
licenseHeaderFile rootProject.file('buildscripts/spotless.license.gradle'), '(import|plugins|description)'
}
yaml {
target "*.yaml"
licenseHeaderFile rootProject.file('buildscripts/spotless.license.yaml'), '([a-zA-Z]*:)'
}
format 'shell', {
target '*.sh'
licenseHeaderFile (rootProject.file('buildscripts/spotless.license.shell'), "([a-zA-Z])")
.skipLinesMatching("#!.+?\$")
}
}
// Make sure test failures include exception error messages for correction.
test {
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
exceptionFormat = 'full'
}
}
ext {
assertjVersion = '3.22.0'
autoServiceVersion = '1.1.1'
autoValueVersion = '1.11.0'
slf4jVersion = '2.0.16'
googleAuthVersion = '1.27.0'
googleCloudVersion = '2.44.1'
googleTraceVersion = '2.51.0'
googleCloudBomVersion = '26.48.0'
cloudMonitoringVersion = '3.52.0'
openTelemetryBomVersion = '1.42.1'
openTelemetryVersion = '1.42.1'
openTelemetryInstrumentationVersion = '2.8.0'
openTelemetrySemconvVersion = '1.27.0'
openTelemetryContribVersion = '1.39.0'
junitVersion = '4.13'
junit5Version = '5.10.0'
mockitoVersion = '3.5.10'
pubSubVersion = '1.133.0'
testContainersVersion = '1.15.1'
wiremockVersion = '2.35.0'
springWebVersion = '2.4.5'
springOpenFeignVersion = '3.0.0'
springOtelVersion = '1.0.0-M8'
cloudEventsCoreVersion = '2.5.0'
cloudFunctionsFrameworkApiVersion = '1.1.0'
agentLibraries = [
agent: "io.opentelemetry.javaagent:opentelemetry-javaagent:${openTelemetryInstrumentationVersion}",
]
libraries = [
auto_service_annotations : "com.google.auto.service:auto-service-annotations:${autoServiceVersion}",
auto_service : "com.google.auto.service:auto-service:${autoServiceVersion}",
auto_value_annotations : "com.google.auto.value:auto-value-annotations:${autoValueVersion}",
auto_value : "com.google.auto.value:auto-value:${autoValueVersion}",
cloudevents_core : "io.cloudevents:cloudevents-core:${cloudEventsCoreVersion}",
google_auth : "com.google.auth:google-auth-library-oauth2-http:${googleAuthVersion}",
google_cloud_core : "com.google.cloud:google-cloud-core:${googleCloudVersion}",
google_cloud_trace : "com.google.cloud:google-cloud-trace:${googleTraceVersion}",
google_cloud_trace_grpc : "com.google.api.grpc:grpc-google-cloud-trace-v2:${googleTraceVersion}",
google_cloud_monitoring : "com.google.cloud:google-cloud-monitoring:${cloudMonitoringVersion}",
google_cloud_monitoring_grpc : "com.google.cloud:grpc-google-cloud-monitoring-v3:${cloudMonitoringVersion}",
google_cloud_pubsub : "com.google.cloud:google-cloud-pubsub:${pubSubVersion}",
google_cloud_functions_framework : "com.google.cloud.functions:functions-framework-api:${cloudFunctionsFrameworkApiVersion}",
google_cloud_bom : "com.google.cloud:libraries-bom:${googleCloudBomVersion}",
slf4j : "org.slf4j:slf4j-api:${slf4jVersion}",
opentelemetry_api : "io.opentelemetry:opentelemetry-api:${openTelemetryVersion}",
opentelemetry_bom : "io.opentelemetry:opentelemetry-bom:${openTelemetryBomVersion}",
opentelemetry_context : "io.opentelemetry:opentelemetry-context:${openTelemetryVersion}",
opentelemetry_sdk : "io.opentelemetry:opentelemetry-sdk:${openTelemetryVersion}",
opentelemetry_sdk_common : "io.opentelemetry:opentelemetry-sdk-common:${openTelemetryVersion}",
opentelemetry_semconv : "io.opentelemetry.semconv:opentelemetry-semconv:${openTelemetrySemconvVersion}-alpha",
opentelemetry_sdk_metrics : "io.opentelemetry:opentelemetry-sdk-metrics:${openTelemetryVersion}",
opentelemetry_sdk_autoconf : "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:${openTelemetryVersion}",
opentelemetry_autoconfigure_spi : "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:${openTelemetryVersion}",
opentelemetry_agent_extension : "io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api:${openTelemetryInstrumentationVersion}-alpha",
opentelemetry_otlp_exporter : "io.opentelemetry:opentelemetry-exporter-otlp:${openTelemetryVersion}",
opentelemetry_logging_exporter : "io.opentelemetry:opentelemetry-exporter-logging:${openTelemetryVersion}",
opentelemetry_gcp_resources : "io.opentelemetry.contrib:opentelemetry-gcp-resources:${openTelemetryContribVersion}-alpha",
spring_boot_starter_web : "org.springframework.boot:spring-boot-starter-web:${springWebVersion}",
spring_cloud_starter_openfeign : "org.springframework.cloud:spring-cloud-starter-openfeign:${springOpenFeignVersion}",
spring_cloud_sleuth_otel_autoconf: "org.springframework.cloud:spring-cloud-sleuth-otel-autoconfigure:${springOtelVersion}",
]
testLibraries = [
assertj : "org.assertj:assertj-core:${assertjVersion}",
junit : "junit:junit:${junitVersion}",
junit5 : "org.junit.jupiter:junit-jupiter-api:${junit5Version}",
junit5_runtime : "org.junit.jupiter:junit-jupiter-engine:${junit5Version}",
junit5_params : "org.junit.jupiter:junit-jupiter-params:${junit5Version}",
mockito : "org.mockito:mockito-inline:${mockitoVersion}",
slf4j_simple: "org.slf4j:slf4j-simple:${slf4jVersion}",
opentelemetry_sdk_testing: "io.opentelemetry:opentelemetry-sdk-testing:${openTelemetryVersion}",
test_containers: "org.testcontainers:testcontainers:${testContainersVersion}",
wiremock : "com.github.tomakehurst:wiremock-jre8:${wiremockVersion}",
]
}
task javadocJar(type: Jar) {
archiveClassifier.set('javadoc')
from javadoc
}
task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
test {
systemProperty 'mock.server.path', System.getProperty('mock.server.path')
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
}
artifacts {
archives javadocJar, sourcesJar
}
java {
withJavadocJar()
withSourcesJar()
}
releaseTask.configure {
finalizedBy(tasks.named('publish'))
}
if (findProperty("release.enabled") == "true") {
publishing {
publications {
maven(MavenPublication) {
if (findProperty("shadowed") != "true") {
from components.java
}
groupId = 'com.google.cloud.opentelemetry'
afterEvaluate {
artifactId = archivesBaseName
if (findProperty("release.qualifier") != null) {
String[] versionParts = version.split('-')
versionParts[0] = "${versionParts[0]}-${findProperty("release.qualifier")}"
version = versionParts.join("-")
}
}
pom {
name = 'OpenTelemetry Operations Java'
url = 'https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'com.google.cloud.opentelemetry'
name = 'OpenTelemetry Operations Contributors'
email = 'opentelemetry-team@google.com'
organization = 'Google Inc'
organizationUrl = 'https://cloud.google.com/products/operations'
}
}
scm {
connection = 'scm:git:https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
developerConnection = 'scm:git:https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
url = 'https://github.com/GoogleCloudPlatform/opentelemetry-operations-java'
}
afterEvaluate {
// description is not available until evaluated.
description = project.description
}
}
}
}
repositories {
maven {
def ossrhRelease = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def ossrhSnapshot = "https://oss.sonatype.org/content/repositories/snapshots/"
url = isReleaseVersion ? ossrhRelease : ossrhSnapshot
credentials {
username = rootProject.hasProperty('ossrhUsername') ? rootProject.ossrhUsername : "Unknown user"
password = rootProject.hasProperty('ossrhPassword') ? rootProject.ossrhPassword : "Unknown password"
}
}
}
}
signing {
required false
// Allow using the GPG agent on linux instead of passwords in a .properties file.
if (rootProject.hasProperty('signingUseGpgCmd')) {
useGpgCmd()
}
sign publishing.publications.maven
}
}
}