From 1ab62654f28a42374ab929070eca5a21c02f455a Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 11 Sep 2022 12:17:38 -0700 Subject: [PATCH] Introduce non-alpha bom (#6576) --- bom-alpha/build.gradle.kts | 17 ++------- bom/build.gradle.kts | 19 ++++++++++ bom/gradle.properties | 1 + .../gradle/OtelBomExtension.kt | 14 ++++++++ .../kotlin/otel.bom-conventions.gradle.kts | 35 +++++++++++++++++++ settings.gradle.kts | 1 + 6 files changed, 72 insertions(+), 15 deletions(-) create mode 100644 bom/build.gradle.kts create mode 100644 bom/gradle.properties create mode 100644 conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/OtelBomExtension.kt create mode 100644 conventions/src/main/kotlin/otel.bom-conventions.gradle.kts diff --git a/bom-alpha/build.gradle.kts b/bom-alpha/build.gradle.kts index 4f1030cb8d1d..c9722144c17e 100644 --- a/bom-alpha/build.gradle.kts +++ b/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" } diff --git a/bom/build.gradle.kts b/bom/build.gradle.kts new file mode 100644 index 000000000000..7c5fe1a78f1b --- /dev/null +++ b/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" } diff --git a/bom/gradle.properties b/bom/gradle.properties new file mode 100644 index 000000000000..45d64bec279d --- /dev/null +++ b/bom/gradle.properties @@ -0,0 +1 @@ +otel.stable=true diff --git a/conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/OtelBomExtension.kt b/conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/OtelBomExtension.kt new file mode 100644 index 000000000000..85029753de39 --- /dev/null +++ b/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> +} diff --git a/conventions/src/main/kotlin/otel.bom-conventions.gradle.kts b/conventions/src/main/kotlin/otel.bom-conventions.gradle.kts new file mode 100644 index 000000000000..f863bd539e24 --- /dev/null +++ b/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("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) + } + } + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 0ec769f07868..4ea320e69fd5 100644 --- a/settings.gradle.kts +++ b/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")