-
Notifications
You must be signed in to change notification settings - Fork 20
/
build.gradle.kts
142 lines (117 loc) · 4.67 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import de.undercouch.gradle.tasks.download.Download
import java.time.Duration
plugins {
id("otel.java-conventions")
id("otel.publish-conventions")
id("otel.japicmp-conventions")
id("otel.animalsniffer-conventions")
id("de.undercouch.download")
id("io.github.gradle-nexus.publish-plugin")
}
// start - updated by ./.github/workflows/prepare-release-branch.yml
val snapshot = true
// end
// The release version of https://github.com/open-telemetry/semantic-conventions used to generate classes
var semanticConventionsVersion = "1.23.1"
// Compute the artifact version, which includes the "-alpha" suffix and includes "-SNAPSHOT" suffix if not releasing
// Release example: version=1.21.0-alpha
// Snapshot example: version=1.21.0-alpha-SNAPSHOT
var releaseVersion = semanticConventionsVersion + "-alpha"
if (snapshot) {
releaseVersion += "-SNAPSHOT"
}
base {
version = releaseVersion
description = "OpenTelemetry Semantic Conventions generated classes for Java"
archivesName.set("opentelemetry-semconv")
}
nexusPublishing {
packageGroup.set("io.opentelemetry.semconv")
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 {
// We have many artifacts so Maven Central takes a long time on its compliance checks. This sets
// the timeout for waiting for the repository to close to a comfortable 50 minutes.
maxRetries.set(300)
delayBetween.set(Duration.ofSeconds(10))
}
}
val opentelemetryJavaVersion = "1.31.0"
dependencies {
compileOnly("io.opentelemetry:opentelemetry-api:$opentelemetryJavaVersion")
testImplementation("io.opentelemetry:opentelemetry-api:$opentelemetryJavaVersion")
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testImplementation("org.junit.jupiter:junit-jupiter-engine")
testImplementation(platform("org.assertj:assertj-bom:3.24.2"))
testImplementation("org.assertj:assertj-core")
}
// start - define tasks to download, unzip, and generate from opentelemetry/semantic-conventions
var generatorVersion = "0.23.0"
val semanticConventionsRepoZip = "https://github.com/open-telemetry/semantic-conventions/archive/v$semanticConventionsVersion.zip"
val schemaUrl = "https://opentelemetry.io/schemas/$semanticConventionsVersion"
val downloadSemanticConventions by tasks.registering(Download::class) {
src(semanticConventionsRepoZip)
dest("$buildDir/semantic-conventions/semantic-conventions.zip")
overwrite(false)
}
val unzipConfigurationSchema by tasks.registering(Copy::class) {
dependsOn(downloadSemanticConventions)
from(zipTree(downloadSemanticConventions.get().dest))
eachFile(closureOf<FileCopyDetails> {
// Remove the top level folder "/semantic-conventions-$semanticConventionsVersion"
val pathParts = path.split("/")
path = pathParts.subList(1, pathParts.size).joinToString("/")
})
into("$buildDir/semantic-conventions/")
}
val generateSemanticAttributes by tasks.registering(Exec::class) {
dependsOn(unzipConfigurationSchema)
standardOutput = System.out
executable = "docker"
setArgs(listOf(
"run",
"--rm",
"-v", "$buildDir/semantic-conventions/model:/source",
"-v", "$projectDir/buildscripts/templates:/templates",
"-v", "$projectDir/src/main/java/io/opentelemetry/semconv/:/output",
"otel/semconvgen:$generatorVersion",
"--only", "span,event,attribute_group,scope,metric",
"--yaml-root", "/source", "code",
"--template", "/templates/SemanticAttributes.java.j2",
"--output", "/output/SemanticAttributes.java",
"-Dclass=SemanticAttributes",
"-DschemaUrl=$schemaUrl",
"-Dpkg=io.opentelemetry.semconv"))
}
val generateResourceAttributes by tasks.registering(Exec::class) {
dependsOn(unzipConfigurationSchema)
standardOutput = System.out
executable = "docker"
setArgs(listOf(
"run",
"--rm",
"-v", "$buildDir/semantic-conventions/model:/source",
"-v", "$projectDir/buildscripts/templates:/templates",
"-v", "$projectDir/src/main/java/io/opentelemetry/semconv/:/output",
"otel/semconvgen:$generatorVersion",
"--only", "resource",
"--yaml-root", "/source", "code",
"--template", "/templates/SemanticAttributes.java.j2",
"--output", "/output/ResourceAttributes.java",
"-Dclass=ResourceAttributes",
"-DschemaUrl=$schemaUrl",
"-Dpkg=io.opentelemetry.semconv"))
}
val generateSemanticConventions by tasks.registering {
dependsOn(generateSemanticAttributes)
dependsOn(generateResourceAttributes)
}
// end