-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.gradle.kts
127 lines (106 loc) · 2.89 KB
/
build.gradle.kts
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
import com.google.protobuf.gradle.*
import de.undercouch.gradle.tasks.download.Download
import nebula.plugin.release.git.base.TagStrategy
import nebula.plugin.release.git.semver.NearestVersionLocator
import java.time.Duration
plugins {
id("com.google.protobuf")
id("de.undercouch.download")
id("io.github.gradle-nexus.publish-plugin")
id("nebula.release")
id("otel.java-conventions")
id("otel.publish-conventions")
}
release {
defaultVersionStrategy = nebula.plugin.release.git.opinion.Strategies.getSNAPSHOT()
}
tasks {
named("release") {
mustRunAfter("snapshotSetup", "finalSetup")
}
}
description = "Java Bindings for the OpenTelemetry Protocol (OTLP)"
val grpcVersion = "1.68.1"
val protobufVersion = "4.28.3"
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
api("com.google.protobuf:protobuf-java:$protobufVersion")
// Workaround for @javax.annotation.Generated
// see: https://github.com/grpc/grpc-java/issues/3633
compileOnly("javax.annotation:javax.annotation-api:1.3.2")
compileOnly("io.grpc:grpc-api:$grpcVersion")
compileOnly("io.grpc:grpc-protobuf:$grpcVersion")
compileOnly("io.grpc:grpc-stub:$grpcVersion")
}
protobuf {
protoc {
// The artifact spec for the Protobuf Compiler
artifact = "com.google.protobuf:protoc:$protobufVersion"
}
plugins {
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion"
}
}
generateProtoTasks {
all().configureEach {
plugins {
id("grpc")
}
}
}
}
// Proto version is set from -Prelease.version or inferred from the latest tag
var protoVersion = if (properties.contains(
"release.version"
)) {
properties.get("release.version") as String
} else {
NearestVersionLocator(release.gitReadCommands, TagStrategy()).locate().any.toString()
}
val protoArchive = file("$buildDir/archives/opentelemetry-proto-$protoVersion.zip")
tasks {
val downloadProtoArchive by registering(Download::class) {
onlyIf { !protoArchive.exists() }
src("https://github.com/open-telemetry/opentelemetry-proto/archive/v$protoVersion.zip")
dest(protoArchive)
}
val unzipProtoArchive by registering(Copy::class) {
dependsOn(downloadProtoArchive)
from(zipTree(protoArchive))
into("$buildDir/protos")
}
named("processResources") {
dependsOn(unzipProtoArchive)
}
afterEvaluate {
named("generateProto") {
dependsOn(unzipProtoArchive)
}
}
}
sourceSets {
main {
proto {
srcDir("$buildDir/protos/opentelemetry-proto-$protoVersion")
}
}
}
nexusPublishing {
packageGroup.set("io.opentelemetry")
repositories {
sonatype {
username.set(System.getenv("SONATYPE_USER"))
password.set(System.getenv("SONATYPE_KEY"))
}
}
connectTimeout.set(Duration.ofMinutes(5))
clientTimeout.set(Duration.ofMinutes(5))
transitionCheckOptions {
maxRetries.set(300)
delayBetween.set(Duration.ofSeconds(10))
}
}