Browse Source

Introduce non-alpha bom (#6576)

Trask Stalnaker 2 years ago
parent
commit
1ab62654f2

+ 2 - 15
bom-alpha/build.gradle.kts

@@ -1,7 +1,5 @@
 plugins {
-  id("java-platform")
-
-  id("otel.publish-conventions")
+  id("otel.bom-conventions")
 }
 
 description = "OpenTelemetry Instrumentation Bill of Materials (Alpha)"
@@ -19,15 +17,4 @@ dependencies {
   api(platform("io.opentelemetry:opentelemetry-bom-alpha:${otelVersion}-alpha"))
 }
 
-dependencies {
-  constraints {
-    rootProject.subprojects {
-      val proj = this
-      if (!proj.name.startsWith("bom") && proj.name != "javaagent") {
-        proj.plugins.withId("maven-publish") {
-          api(proj)
-        }
-      }
-    }
-  }
-}
+otelBom.projectFilter.set { it.findProperty("otel.stable") != "true" }

+ 19 - 0
bom/build.gradle.kts

@@ -0,0 +1,19 @@
+plugins {
+  id("otel.bom-conventions")
+}
+
+description = "OpenTelemetry Instrumentation Bill of Materials"
+group = "io.opentelemetry.instrumentation"
+base.archivesName.set("opentelemetry-instrumentation-bom")
+
+javaPlatform {
+  allowDependencies()
+}
+
+val otelVersion: String by project
+
+dependencies {
+  api(platform("io.opentelemetry:opentelemetry-bom:${otelVersion}"))
+}
+
+otelBom.projectFilter.set { it.findProperty("otel.stable") == "true" }

+ 1 - 0
bom/gradle.properties

@@ -0,0 +1 @@
+otel.stable=true

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

@@ -0,0 +1,14 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.instrumentation.gradle
+
+import org.gradle.api.Project
+import org.gradle.api.provider.Property
+import java.util.function.Predicate
+
+abstract class OtelBomExtension {
+  abstract val projectFilter: Property<Predicate<Project>>
+}

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

@@ -0,0 +1,35 @@
+import io.opentelemetry.instrumentation.gradle.OtelBomExtension
+
+plugins {
+  id("otel.publish-conventions")
+  id("java-platform")
+}
+
+if (!project.name.startsWith("bom")) {
+  throw IllegalStateException("Name of BOM projects must start with 'bom'.")
+}
+
+rootProject.subprojects.forEach { subproject ->
+  if (!subproject.name.startsWith("bom")) {
+    evaluationDependsOn(subproject.path)
+  }
+}
+val otelBom = extensions.create<OtelBomExtension>("otelBom")
+
+afterEvaluate {
+  otelBom.projectFilter.finalizeValue()
+  val bomProjects = rootProject.subprojects
+    .sortedBy { it.findProperty("archivesName") as String? }
+    .filter { !it.name.startsWith("bom") }
+    .filter { !it.name.equals("javaagent") }
+    .filter(otelBom.projectFilter.get()::test)
+    .filter { it.plugins.hasPlugin("maven-publish") }
+
+  bomProjects.forEach { project ->
+    dependencies {
+      constraints {
+        api(project)
+      }
+    }
+  }
+}

+ 1 - 0
settings.gradle.kts

@@ -106,6 +106,7 @@ include(":javaagent-tooling")
 include(":javaagent-tooling:javaagent-tooling-java9")
 include(":javaagent")
 
+include(":bom")
 include(":bom-alpha")
 include(":instrumentation-api")
 include(":instrumentation-api-semconv")