forked from open-telemetry/opentelemetry-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
655 lines (561 loc) · 27.1 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
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
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
import com.diffplug.gradle.spotless.SpotlessExtension
import com.google.protobuf.gradle.*
import de.marcphilipp.gradle.nexus.NexusPublishExtension
import io.morethan.jmhreport.gradle.JmhReportExtension
import me.champeau.jmh.JmhParameters
import me.champeau.gradle.japicmp.JapicmpTask
import nebula.plugin.release.git.opinion.Strategies
import net.ltgt.gradle.errorprone.CheckSeverity
import net.ltgt.gradle.errorprone.ErrorProneOptions
import net.ltgt.gradle.errorprone.ErrorPronePlugin
import net.ltgt.gradle.nullaway.NullAwayOptions
import org.gradle.api.plugins.JavaPlugin.*
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import ru.vyarus.gradle.plugin.animalsniffer.AnimalSnifferExtension
import ru.vyarus.gradle.plugin.animalsniffer.AnimalSnifferPlugin
import java.time.Duration
plugins {
id("com.diffplug.spotless")
id("com.github.ben-manes.versions")
id("io.codearte.nexus-staging")
id("nebula.release")
id("com.google.protobuf") apply false
id("de.marcphilipp.nexus-publish") apply false
id("io.morethan.jmhreport") apply false
id("me.champeau.jmh") apply false
id("net.ltgt.errorprone") apply false
id("net.ltgt.nullaway") apply false
id("ru.vyarus.animalsniffer") apply false
id("me.champeau.gradle.japicmp") apply false
}
/**
* Locate the project's artifact of a particular version.
*/
fun Project.findArtifact(version: String) : File {
val existingGroup = this.group
try {
// Temporarily change the group name because we want to fetch an artifact with the same
// Maven coordinates as the project, which Gradle would not allow otherwise.
this.group = "virtual_group"
val depModule = "io.opentelemetry:${base.archivesBaseName}:$version@jar"
val depJar = "${base.archivesBaseName}-${version}.jar"
val configuration: Configuration = configurations.detachedConfiguration(
dependencies.create(depModule)
)
return files(configuration.files).filter {
it.name.equals(depJar)
}.singleFile
} finally {
this.group = existingGroup
}
}
/**
* The latest *released* version of the project. Evaluated lazily so the work is only done if necessary.
*/
val latestReleasedVersion : String by lazy {
// hack to find the current released version of the project
val temp: Configuration = project.configurations.create("tempConfig")
// pick the api, since it's always there.
dependencies.add("tempConfig", "io.opentelemetry:opentelemetry-api:latest.release")
val moduleVersion = project.configurations["tempConfig"].resolvedConfiguration.firstLevelModuleDependencies.elementAt(0).moduleVersion
project.configurations.remove(temp)
println("Discovered latest release version: " + moduleVersion)
moduleVersion
}
if (!JavaVersion.current().isJava11Compatible()) {
throw GradleException("JDK 11 or higher is required to build. " +
"One option is to download it from https://adoptopenjdk.net/. If you believe you already " +
"have it, please check that the JAVA_HOME environment variable is pointing at the " +
"JDK 11 installation.")
}
// 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.
var releaseTask: TaskProvider<Task>
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")
}
nexusStaging {
packageGroup = "io.opentelemetry"
username = System.getenv("SONATYPE_USER")
password = System.getenv("SONATYPE_KEY")
// 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.
numberOfRetries = 300
delayBetweenRetriesInMillis = 10000
}
val enableNullaway: String? by project
subprojects {
group = "io.opentelemetry"
plugins.withId("java") {
plugins.apply("checkstyle")
plugins.apply("eclipse")
plugins.apply("idea")
plugins.apply("jacoco")
plugins.apply("com.diffplug.spotless")
plugins.apply("net.ltgt.errorprone")
plugins.apply("net.ltgt.nullaway")
configure<BasePluginConvention> {
archivesBaseName = "opentelemetry-${name}"
}
configure<JavaPluginExtension> {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
withJavadocJar()
withSourcesJar()
}
configure<CheckstyleExtension> {
configDirectory.set(file("$rootDir/buildscripts/"))
toolVersion = "8.12"
isIgnoreFailures = false
configProperties["rootDir"] = rootDir
}
configure<JacocoPluginExtension> {
toolVersion = "0.8.7"
}
val javaToolchains = the<JavaToolchainService>()
tasks {
val testJava8 by registering(Test::class) {
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(8))
})
configure<JacocoTaskExtension> {
enabled = false
}
}
val testAdditionalJavaVersions: String? by rootProject
if (testAdditionalJavaVersions == "true") {
named("check") {
dependsOn(testJava8)
}
}
withType(JavaCompile::class) {
options.release.set(8)
if (name != "jmhCompileGeneratedClasses") {
options.compilerArgs.addAll(listOf(
"-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",
// Fail build on any warning
"-Werror"
))
}
//disable deprecation warnings for the protobuf module
if (project.name == "proto") {
options.compilerArgs.add("-Xlint:-deprecation")
}
options.encoding = "UTF-8"
if (name.contains("Test")) {
// serialVersionUID is basically guaranteed to be useless in tests
options.compilerArgs.add("-Xlint:-serial")
}
(options as ExtensionAware).extensions.configure<ErrorProneOptions> {
disableWarningsInGeneratedCode.set(true)
allDisabledChecksAsWarnings.set(true)
(this as ExtensionAware).extensions.configure<NullAwayOptions> {
// Enable nullaway on main sources.
// TODO(anuraaga): Remove enableNullaway flag when all errors fixed
if (!name.contains("Test") && !name.contains("Jmh") && enableNullaway == "true") {
severity.set(CheckSeverity.ERROR)
} else {
severity.set(CheckSeverity.OFF)
}
annotatedPackages.add("io.opentelemetry")
}
// Doesn't currently use Var annotations.
disable("Var") // "-Xep:Var:OFF"
// ImmutableRefactoring suggests using com.google.errorprone.annotations.Immutable,
// but currently uses javax.annotation.concurrent.Immutable
disable("ImmutableRefactoring") // "-Xep:ImmutableRefactoring:OFF"
// AutoValueImmutableFields suggests returning Guava types from API methods
disable("AutoValueImmutableFields")
// Suggests using Guava types for fields but we don't use Guava
disable("ImmutableMemberCollection")
// "-Xep:AutoValueImmutableFields:OFF"
// Fully qualified names may be necessary when deprecating a class to avoid
// deprecation warning.
disable("UnnecessarilyFullyQualified")
// Ignore warnings for protobuf and jmh generated files.
excludedPaths.set(".*generated.*|.*internal.shaded.*")
// "-XepExcludedPaths:.*/build/generated/source/proto/.*"
disable("Java7ApiChecker")
disable("AndroidJdkLibsChecker")
//apparently disabling android doesn't disable this
disable("StaticOrDefaultInterfaceMethod")
//until we have everything converted, we need these
disable("JdkObsolete")
disable("UnnecessaryAnonymousClass")
// Limits APIs
disable("NoFunctionalReturnType")
// We don't depend on Guava so use normal splitting
disable("StringSplitter")
// Prevents lazy initialization
disable("InitializeInline")
if (name.contains("Jmh") || name.contains("Test")) {
// Allow underscore in test-type method names
disable("MemberName")
}
}
}
withType(Test::class) {
useJUnitPlatform()
testLogging {
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
showStackTraces = true
}
maxHeapSize = "1500m"
}
withType(Javadoc::class) {
exclude("io/opentelemetry/**/internal/**")
with(options as StandardJavadocDocletOptions) {
source = "8"
encoding = "UTF-8"
docEncoding = "UTF-8"
breakIterator(true)
addBooleanOption("html5", true)
links("https://docs.oracle.com/javase/8/docs/api/")
addBooleanOption("Xdoclint:all,-missing", true)
afterEvaluate {
val title = "${project.description}"
docTitle = title
windowTitle = title
}
}
}
afterEvaluate {
withType(Jar::class) {
val moduleName: String by project
inputs.property("moduleName", moduleName)
manifest {
attributes(
"Automatic-Module-Name" to moduleName,
"Built-By" to System.getProperty("user.name"),
"Built-JDK" to System.getProperty("java.version"),
"Implementation-Title" to project.name,
"Implementation-Version" to project.version)
}
}
}
}
// https://docs.gradle.org/current/samples/sample_jvm_multi_project_with_code_coverage.html
// Do not generate reports for individual projects
tasks.named("jacocoTestReport") {
enabled = false
}
configurations {
val implementation by getting
create("transitiveSourceElements") {
isVisible = false
isCanBeResolved = false
isCanBeConsumed = true
extendsFrom(implementation)
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named("source-folders"))
}
val mainSources = the<JavaPluginConvention>().sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)
mainSources.java.srcDirs.forEach {
outgoing.artifact(it)
}
}
create("coverageDataElements") {
isVisible = false
isCanBeResolved = false
isCanBeConsumed = true
extendsFrom(implementation)
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named("jacoco-coverage-data"))
}
// This will cause the test task to run if the coverage data is requested by the aggregation task
tasks.withType(Test::class) {
outgoing.artifact(extensions.getByType<JacocoTaskExtension>().destinationFile!!)
}
}
configureEach {
resolutionStrategy {
failOnVersionConflict()
preferProjectModules()
}
}
}
configure<SpotlessExtension> {
java {
googleJavaFormat("1.9")
licenseHeaderFile(rootProject.file("buildscripts/spotless.license.java"), "(package|import|class|// Includes work from:)")
}
}
val dependencyManagement by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = false
isVisible = false
}
dependencies {
add(dependencyManagement.name, platform(project(":dependencyManagement")))
afterEvaluate {
configurations.configureEach {
if (isCanBeResolved && !isCanBeConsumed) {
extendsFrom(dependencyManagement)
}
}
}
add(COMPILE_ONLY_CONFIGURATION_NAME, "com.google.auto.value:auto-value-annotations")
add(COMPILE_ONLY_CONFIGURATION_NAME, "com.google.code.findbugs:jsr305")
add(TEST_COMPILE_ONLY_CONFIGURATION_NAME, "com.google.auto.value:auto-value-annotations")
add(TEST_COMPILE_ONLY_CONFIGURATION_NAME, "com.google.errorprone:error_prone_annotations")
add(TEST_COMPILE_ONLY_CONFIGURATION_NAME, "com.google.code.findbugs:jsr305")
add(TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.junit.jupiter:junit-jupiter-api")
add(TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.junit.jupiter:junit-jupiter-params")
add(TEST_IMPLEMENTATION_CONFIGURATION_NAME, "nl.jqno.equalsverifier:equalsverifier")
add(TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.mockito:mockito-core")
add(TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.mockito:mockito-junit-jupiter")
add(TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.assertj:assertj-core")
add(TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.awaitility:awaitility")
add(TEST_IMPLEMENTATION_CONFIGURATION_NAME, "io.github.netmikey.logunit:logunit-jul")
add(TEST_RUNTIME_ONLY_CONFIGURATION_NAME, "org.junit.jupiter:junit-jupiter-engine")
add(TEST_RUNTIME_ONLY_CONFIGURATION_NAME, "org.junit.vintage:junit-vintage-engine")
add(ErrorPronePlugin.CONFIGURATION_NAME, "com.google.errorprone:error_prone_core")
add(ErrorPronePlugin.CONFIGURATION_NAME, "com.uber.nullaway:nullaway")
add(ANNOTATION_PROCESSOR_CONFIGURATION_NAME, "com.google.guava:guava-beta-checker")
// Workaround for @javax.annotation.Generated
// see: https://github.com/grpc/grpc-java/issues/3633
add(COMPILE_ONLY_CONFIGURATION_NAME, "javax.annotation:javax.annotation-api")
}
plugins.withId("com.google.protobuf") {
protobuf {
val versions: Map<String, String> by project
protoc {
// The artifact spec for the Protobuf Compiler
artifact = "com.google.protobuf:protoc:${versions["com.google.protobuf"]}"
}
plugins {
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:${versions["io.grpc"]}"
}
}
generateProtoTasks {
all().configureEach {
plugins {
id("grpc")
}
}
}
}
afterEvaluate {
// Classpath when compiling protos, we add dependency management directly
// since it doesn't follow Gradle conventions of naming / properties.
dependencies {
add("compileProtoPath", platform(project(":dependencyManagement")))
add("testCompileProtoPath", platform(project(":dependencyManagement")))
}
}
}
plugins.withId("ru.vyarus.animalsniffer") {
dependencies {
add(AnimalSnifferPlugin.SIGNATURE_CONF, "com.toasttab.android:gummy-bears-api-21:0.3.0:coreLib@signature")
}
configure<AnimalSnifferExtension> {
sourceSets = listOf(the<JavaPluginConvention>().sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME))
}
}
plugins.withId("me.champeau.jmh") {
// Always include the jmhreport plugin and run it after jmh task.
plugins.apply("io.morethan.jmhreport")
dependencies {
add("jmh", platform(project(":dependencyManagement")))
add("jmh", "org.openjdk.jmh:jmh-core")
add("jmh", "org.openjdk.jmh:jmh-generator-bytecode")
}
// invoke jmh on a single benchmark class like so:
// ./gradlew -PjmhIncludeSingleClass=StatsTraceContextBenchmark clean :grpc-core:jmh
configure<JmhParameters> {
failOnError.set(true)
resultFormat.set("JSON")
// Otherwise an error will happen:
// Could not expand ZIP 'byte-buddy-agent-1.9.7.jar'.
includeTests.set(false)
profilers.add("gc")
val jmhIncludeSingleClass: String? by project
if (jmhIncludeSingleClass != null) {
includes.add(jmhIncludeSingleClass as String)
}
}
configure<JmhReportExtension> {
jmhResultPath = file("${buildDir}/results/jmh/results.json").absolutePath
jmhReportOutput = file("${buildDir}/results/jmh").absolutePath
}
tasks {
// TODO(anuraaga): Unclear why this is triggering even though there don't seem to
// be duplicates, possibly a bug in JMH plugin.
named<ProcessResources>("processJmhResources") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
named("jmh") {
finalizedBy(named("jmhReport"))
}
}
}
}
plugins.withId("me.champeau.gradle.japicmp") {
afterEvaluate {
tasks {
val jApiCmp by registering(JapicmpTask::class) {
dependsOn("jar")
// the japicmp "old" version is either the user-specified one, or the latest release.
val userRequestedBase = project.properties["apiBaseVersion"] as String?
val baselineVersion: String = userRequestedBase ?: latestReleasedVersion
val baselineArtifact: File = project.findArtifact(baselineVersion)
oldClasspath = files(baselineArtifact)
// the japicmp "new" version is either the user-specified one, or the locally built jar.
val newVersion : String? = project.properties["apiNewVersion"] as String?
val newArtifact: File = if (newVersion == null) {
val jar = getByName("jar") as Jar
file(jar.archiveFile)
} else {
project.findArtifact(newVersion)
}
newClasspath = files(newArtifact)
//only output changes, not everything
isOnlyModified = true
//this is needed so that we only consider the current artifact, and not dependencies
isIgnoreMissingClasses = true
// double wildcards don't seem to work here (*.internal.*)
packageExcludes = listOf("*.internal", "io.opentelemetry.internal.shaded.jctools.*")
if (newVersion == null) {
val baseVersionString = if (userRequestedBase == null) "latest" else baselineVersion
txtOutputFile = file("$rootDir/docs/apidiffs/current_vs_${baseVersionString}/${project.base.archivesBaseName}.txt")
} else {
txtOutputFile = file("$rootDir/docs/apidiffs/${newVersion}_vs_${baselineVersion}/${project.base.archivesBaseName}.txt")
}
}
// have the check task depend on the api comparison task, to make it more likely it will get used.
named("check") {
dependsOn(jApiCmp)
}
}
}
}
plugins.withId("maven-publish") {
// generate the api diff report for any module that is stable and publishes a jar.
if (!project.hasProperty("otel.release") && !project.name.startsWith("bom")) {
plugins.apply("me.champeau.gradle.japicmp")
}
plugins.apply("signing")
plugins.apply("de.marcphilipp.nexus-publish")
configure<PublishingExtension> {
publications {
register<MavenPublication>("mavenPublication") {
val release = findProperty("otel.release")
if (release != null) {
val versionParts = version.split('-').toMutableList()
versionParts[0] += "-${release}"
version = versionParts.joinToString("-")
}
groupId = "io.opentelemetry"
afterEvaluate {
// not available until evaluated.
artifactId = the<BasePluginConvention>().archivesBaseName
pom.description.set(project.description)
}
plugins.withId("java-platform") {
from(components["javaPlatform"])
}
plugins.withId("java-library") {
from(components["java"])
}
versionMapping {
allVariants {
fromResolutionResult()
}
}
pom {
name.set("OpenTelemetry Java")
url.set("https://github.com/open-telemetry/opentelemetry-java")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("opentelemetry")
name.set("OpenTelemetry")
url.set("https://github.com/open-telemetry/community")
}
}
scm {
connection.set("scm:git:[email protected]:open-telemetry/opentelemetry-java.git")
developerConnection.set("scm:git:[email protected]:open-telemetry/opentelemetry-java.git")
url.set("[email protected]:open-telemetry/opentelemetry-java.git")
}
}
}
}
}
configure<NexusPublishExtension> {
repositories {
sonatype()
}
connectTimeout.set(Duration.ofMinutes(5))
clientTimeout.set(Duration.ofMinutes(5))
}
val publishToSonatype by tasks.getting
releaseTask.configure {
finalizedBy(publishToSonatype)
}
rootProject.tasks.named("closeAndReleaseRepository") {
mustRunAfter(publishToSonatype)
}
tasks.withType(Sign::class) {
onlyIf { System.getenv("CI") != null }
}
configure<SigningExtension> {
useInMemoryPgpKeys(System.getenv("GPG_PRIVATE_KEY"), System.getenv("GPG_PASSWORD"))
sign(the<PublishingExtension>().publications["mavenPublication"])
}
}
}
allprojects {
tasks.register("updateVersionInDocs") {
group = "documentation"
doLast {
val versionParts = version.toString().split('.')
val minorVersionNumber = Integer.parseInt(versionParts[1])
val nextSnapshot = "${versionParts[0]}.${minorVersionNumber + 1}.0-SNAPSHOT"
val readme = file("README.md")
if (readme.exists()) {
val readmeText = readme.readText()
val updatedText = readmeText
.replace("""<version>\d+\.\d+\.\d+</version>""".toRegex(), "<version>${version}</version>")
.replace("""<version>\d+\.\d+\.\d+-SNAPSHOT</version>""".toRegex(), "<version>${nextSnapshot}</version>")
.replace("""(implementation.*io\.opentelemetry:.*:)(\d+\.\d+\.\d+)(?!-SNAPSHOT)(.*)""".toRegex(), "\$1${version}\$3")
.replace("""(implementation.*io\.opentelemetry:.*:)(\d+\.\d+\.\d+-SNAPSHOT)(.*)""".toRegex(), "\$1${nextSnapshot}\$3")
.replace("""<!--VERSION_STABLE-->.*<!--/VERSION_STABLE-->""".toRegex(), "<!--VERSION_STABLE-->${version}<!--/VERSION_STABLE-->")
.replace("""<!--VERSION_UNSTABLE-->.*<!--/VERSION_UNSTABLE-->""".toRegex(), "<!--VERSION_UNSTABLE-->${version}-alpha<!--/VERSION_UNSTABLE-->")
readme.writeText(updatedText)
}
}
}
}