Browse Source

Add semconv to alpha bom (#9425)

Trask Stalnaker 1 year ago
parent
commit
b2b1eb19e1

+ 7 - 0
bom-alpha/build.gradle.kts

@@ -14,6 +14,13 @@ dependencies {
   api(platform("io.opentelemetry:opentelemetry-bom"))
   api(platform("io.opentelemetry:opentelemetry-bom-alpha"))
   api(platform(project(":bom")))
+
+  // Get the semconv version from :dependencyManagement
+  val semconvConstraint = project(":dependencyManagement").dependencyProject.configurations["api"].allDependencyConstraints
+    .find { it.group.equals("io.opentelemetry.semconv")
+            && it.name.equals("opentelemetry-semconv") }
+    ?: throw Exception("semconv constraint not found")
+  otelBom.addExtra(semconvConstraint.group, semconvConstraint.name, semconvConstraint.version ?: throw Exception("missing version"))
 }
 
 otelBom.projectFilter.set { it.findProperty("otel.stable") != "true" }

+ 5 - 0
conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/OtelBomExtension.kt

@@ -11,4 +11,9 @@ import java.util.function.Predicate
 
 abstract class OtelBomExtension {
   abstract val projectFilter: Property<Predicate<Project>>
+  val additionalDependencies: MutableSet<String> = hashSetOf()
+
+  fun addExtra(groupId: String, artifactId: String, version: String) {
+    this.additionalDependencies.add(groupId + ":" + artifactId + ":" + version)
+  }
 }

+ 7 - 0
conventions/src/main/kotlin/otel.bom-conventions.gradle.kts

@@ -31,6 +31,13 @@ afterEvaluate {
       }
     }
   }
+  otelBom.additionalDependencies.forEach { dependency ->
+    dependencies {
+      constraints {
+        api(dependency)
+      }
+    }
+  }
 }
 
 // this applies version numbers to the SDK bom and SDK alpha bom which are dependencies of the instrumentation boms