From 96c291402c756fe37f1808121cb0cb7d9f50ef3c Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Tue, 23 Jan 2024 17:30:08 +0200 Subject: [PATCH] Disable jApiCmp for 1.x (#10293) --- .../main/kotlin/otel.japicmp-conventions.gradle.kts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts b/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts index e3fd6ed5d559..b1e371719d53 100644 --- a/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts @@ -47,6 +47,10 @@ fun findArtifact(version: String): File { } } +fun getMajorVersion(version: String): Int { + return version.substringBefore('.').toInt() +} + // generate the api diff report for any module that is stable if (project.findProperty("otel.stable") == "true") { afterEvaluate { @@ -66,6 +70,14 @@ if (project.findProperty("otel.stable") == "true") { // the japicmp "old" version is either the user-specified one, or the latest release. val apiBaseVersion: String? by project val baselineVersion = apiBaseVersion ?: latestReleasedVersion + if (apiBaseVersion == null && apiNewVersion == null) { + val baseMajor = getMajorVersion(baselineVersion) + val projectMajor = getMajorVersion(project.version as String) + // disable japicmp when project major version is behind major version of latest release, + // if that is the case we are building a patch for the previous release + enabled = projectMajor >= baseMajor + } + oldClasspath.from( try { files(findArtifact(baselineVersion))