From 6222f9ba497de67413e7be5971441faa3a5ccf10 Mon Sep 17 00:00:00 2001 From: Nickolas Dimitrakas Date: Wed, 7 Oct 2026 14:57:35 -0400 Subject: [PATCH] build: declare the Kotlin JVM toolchain explicitly android-core, android-kit-base and tooling/android-plugin set a Java sourceCompatibility/targetCompatibility but had no corresponding Kotlin JVM target, relying on the Kotlin Gradle plugin's implicit default. testutils declared one through the deprecated kotlinOptions.jvmTarget DSL. Only tooling/common used the modern kotlin { jvmToolchain(...) } API. Apply that same, already-proven pattern to the remaining Kotlin-enabled modules so every module compiles Kotlin against the same JDK release (JAVA_VERSION, currently 17) as its Java sources, declared the same way everywhere. No source, dependency, or ProGuard changes. apiCheck passes with no public API drift, and android-core/android-kit-base unit tests are unaffected. Co-Authored-By: Claude Sonnet 5 --- android-core/build.gradle | 4 ++++ android-kit-base/build.gradle | 4 ++++ testutils/build.gradle | 7 ++++--- tooling/android-plugin/build.gradle | 4 ++++ tooling/custom-lint-rules/build.gradle | 8 ++++++-- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/android-core/build.gradle b/android-core/build.gradle index af9b92c54..659a84604 100644 --- a/android-core/build.gradle +++ b/android-core/build.gradle @@ -113,6 +113,10 @@ android { } } +kotlin { + jvmToolchain(Integer.parseInt(JAVA_VERSION)) +} + dependencies { //noinspection GradleCompatible compileOnly 'com.google.firebase:firebase-messaging:[10.2.1, )' diff --git a/android-kit-base/build.gradle b/android-kit-base/build.gradle index 14832e89a..fa6f6f2b5 100644 --- a/android-kit-base/build.gradle +++ b/android-kit-base/build.gradle @@ -49,6 +49,10 @@ android { } } +kotlin { + jvmToolchain(Integer.parseInt(JAVA_VERSION)) +} + tasks.withType(Test).configureEach { jvmArgs('--add-opens=java.base/java.lang=ALL-UNNAMED') jvmArgs("--add-opens=java.base/java.util=ALL-UNNAMED") diff --git a/testutils/build.gradle b/testutils/build.gradle index 54dbd5d46..eff3e62b2 100644 --- a/testutils/build.gradle +++ b/testutils/build.gradle @@ -10,9 +10,6 @@ android { targetCompatibility = JavaVersion.toVersion(JAVA_VERSION) } - kotlinOptions { - jvmTarget = JAVA_VERSION - } defaultConfig { //This is set to 21 to avoid slow multidex. minSdk 21 @@ -63,6 +60,10 @@ android { } } +kotlin { + jvmToolchain(Integer.parseInt(JAVA_VERSION)) +} + dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) compileOnly project(':android-core') diff --git a/tooling/android-plugin/build.gradle b/tooling/android-plugin/build.gradle index ae244614c..7c7213ac3 100644 --- a/tooling/android-plugin/build.gradle +++ b/tooling/android-plugin/build.gradle @@ -5,6 +5,10 @@ apply plugin: 'mparticle.android.library.publish' sourceCompatibility = JavaVersion.toVersion(JAVA_VERSION) targetCompatibility = JavaVersion.toVersion(JAVA_VERSION) +kotlin { + jvmToolchain(Integer.parseInt(JAVA_VERSION)) +} + mparticleMavenPublish { artifactId.set('android-plugin') description.set('mParticle Gradle Plugin for managing Dataplanning functionality') diff --git a/tooling/custom-lint-rules/build.gradle b/tooling/custom-lint-rules/build.gradle index 95e303c6b..a9a41a289 100644 --- a/tooling/custom-lint-rules/build.gradle +++ b/tooling/custom-lint-rules/build.gradle @@ -4,8 +4,12 @@ apply plugin: 'java-library' apply plugin: 'kotlin' apply plugin: 'com.android.lint' -sourceCompatibility = 17 -targetCompatibility = 17 +sourceCompatibility = JavaVersion.toVersion(JAVA_VERSION) +targetCompatibility = JavaVersion.toVersion(JAVA_VERSION) + +kotlin { + jvmToolchain(Integer.parseInt(JAVA_VERSION)) +} buildscript { ext {