From 26d8708d9969823c886f38b29d4109df4a4c2f82 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Mon, 27 Jul 2026 15:40:18 -0400 Subject: [PATCH] Build: Add kotlin-metadata-jvm override for dependency analysis Force a newer kotlin-metadata-jvm onto the root buildscript classpath so the dependency analysis plugin's ExplodeJarTask can read Kotlin 2.4.0 metadata instead of failing with "Provided Metadata instance has version 2.4.0, while maximum supported version is 2.3.0". The project's own Kotlin bump to 2.4.10 (#23086) makes every module emit 2.4.0 metadata, which exceeds the 2.3.0 cap of the kotlin-metadata-jvm:2.2.21 reader that dependency-analysis 3.17.0 bundles, so buildHealth's explodeJar tasks fail on the weekly CI job. DAGP resolves kotlin-metadata-jvm unshaded into the same buildscript classpath configuration used here, so Gradle's ordinary conflict resolution upgrades both to the higher version (2.2.21 -> 2.4.10). Pinned to this project's own Kotlin version so it never forces a newer kotlin-stdlib onto DAGP's classpath than the project already uses elsewhere. Interim workaround endorsed by the plugin author; removable once upstream isolates kotlin-metadata-jvm onto its own worker classpath: https://github.com/autonomousapps/dependency-analysis-gradle-plugin/issues/1661 https://github.com/autonomousapps/dependency-analysis-gradle-plugin/pull/1719 Co-Authored-By: Claude Opus 4.8 --- build.gradle | 12 ++++++++++++ gradle/libs.versions.toml | 1 + 2 files changed, 13 insertions(+) diff --git a/build.gradle b/build.gradle index fed48cbcaedf..583733191359 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,18 @@ import com.automattic.android.measure.reporters.SlowSlowTasksMetricsReporter import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +buildscript { + dependencies { + // TODO: Remove once dependency-analysis-gradle-plugin isolates its kotlin-metadata-jvm + // dependency onto its own worker classpath, making this override moot (see PR below). + // Interim workaround, endorsed by the plugin author, for reading Kotlin metadata newer + // than DAGP's own bundled reader supports. Tracks this project's own Kotlin version. + // https://github.com/autonomousapps/dependency-analysis-gradle-plugin/issues/1661 + // https://github.com/autonomousapps/dependency-analysis-gradle-plugin/pull/1719 + classpath(libs.kotlin.metadata.jvm) + } +} + plugins { alias(libs.plugins.detekt) alias(libs.plugins.automattic.measure.builds) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7a76e1cd5eec..a46626fe87e5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -239,6 +239,7 @@ jsoup = { group = "org.jsoup", name = "jsoup", version.ref = "jsoup" } junit = { group = "junit", name = "junit", version.ref = "junit" } kotlin-compile-testing-ksp = { group = "com.github.tschuchortdev", name = "kotlin-compile-testing-ksp", version.ref = "kotlin-compile-testing" } kotlin-compile-testing-main = { group = "com.github.tschuchortdev", name = "kotlin-compile-testing", version.ref = "kotlin-compile-testing" } +kotlin-metadata-jvm = { group = "org.jetbrains.kotlin", name = "kotlin-metadata-jvm", version.ref = "kotlin-main" } kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin-main" } kotlin-test-junit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit", version.ref = "kotlin-main" } kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }