Skip to content

build: declare the Kotlin JVM toolchain explicitly - #883

Merged
nickolas-dimitrakas merged 1 commit into
mainfrom
build/jvm-toolchain
Oct 7, 2026
Merged

nickolas-dimitrakas merged 1 commit into
mainfrom
build/jvm-toolchain

Conversation

@nickolas-dimitrakas

Copy link
Copy Markdown
Contributor

Why

Several modules in this SDK compile both Java and Kotlin source, and each one needs both languages to target the exact same JDK release so the two compilers produce compatible bytecode. Today, most of those modules declare that target for Java but never for Kotlin, so the Kotlin compiler is left to an implicit default instead. That gap is harmless right now only by coincidence, and it becomes a real risk as more of the SDK's internals move from Java to Kotlin: a silent mismatch would show up as a confusing compile failure, or worse, inconsistent bytecode in a published release. This change makes every module declare its Kotlin target the same explicit way a sibling module already does successfully, closing that gap before it can bite.

Programme

Part of an in-progress, internally planned Java-to-Kotlin migration for this SDK's core modules. No public tracking page exists yet; the migration's documentation and progress tracker are being added in mParticle/mparticle-android-sdk#846 (not yet merged).

What changes

Before: android-core, android-kit-base and tooling/android-plugin declared a Java target but no Kotlin target at all; testutils declared its Kotlin target through an API the Kotlin team has deprecated; tooling/custom-lint-rules hardcoded its Java target as a literal number instead of using the shared project setting every other module uses.

After: all five modules declare their Kotlin target the same explicit, current way, matching the one module (tooling/common) that already did this correctly. The declared value is unchanged everywhere — this does not move any module to a different JDK release, it only makes the existing target explicit and consistent.

No documentation, changelog or runbook changes accompany this: it has no user-visible behavior to describe. A reviewer can start with any one of the five files — the change is the same one-line addition (or deprecated-API swap) in each, so reading one tells you what the rest do. Nothing else in these files, and no other module, was touched.

Linked work

Depends on: None.
Unblocks: None.
Related: mParticle/mparticle-android-sdk#846 — adds the migration playbook and tracker this change is part of.

Rollout

Path: ships to consumers only when a release is next cut from main; nothing about this PR itself triggers a release. It changes build configuration only, not the published artifacts' public API or runtime behavior.
Feature flags: none.
Turning it off: revert the pull request; the previous build configuration returns immediately on the next build.
What we watch: standard CI build and test jobs on this and every subsequent pull request against main — any JDK-target mismatch this change was meant to prevent would show up there as a compile failure, not silently in production.

Risks

  • A module's Kotlin output could end up targeting a different bytecode version than before, changing what the published artifact requires at runtime; prevented by setting the declared value to the same JAVA_VERSION each module's Java compilation already uses, and confirmed by a clean compile and a passing API-compatibility check with no detected drift; we would see it immediately as a compile failure or an API-check failure in CI, not in production.

Risk class: low.

Who

Written by: Claude Code, an automated coding agent, from an internal Java-to-Kotlin migration plan agreed with the SDK team lead (September 2026).
Code reviewed before opening: automated adversarial review by Claude Code's commit-reviewer agent, twice (after an initial pass flagged two style inconsistencies, which were fixed and re-reviewed); no human review yet.
Design reviewed before opening: no one.
Decision this implements: the SDK team lead's decision to proceed with the Java-to-Kotlin migration plan, agreed September 2026.
Checked: ./gradlew compileReleaseKotlin / compileDebugKotlin / compileKotlin across all five touched modules (clean, no new warnings), ./gradlew apiCheck (passes, no public API drift), and ./gradlew test (passes; android-core 311 tests, android-kit-base 89 tests, unchanged from main) — all run locally just before opening this PR.
Not checked: instrumented (androidTest) tests were not run — this change affects only how Kotlin source is compiled, not runtime behavior, so the unit-test and API-compatibility checks above are the relevant signal. The kits under kits/ build via a separate Gradle invocation and were not touched or rebuilt; they are unaffected by this change.

Size

Hand-written: 22 lines, 5 files.
Generated: none.

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

Binary compatibility

  • ✅ android-core is compatible with 6.1.5 (115 classes compared, 1 with additions only).
  • ✅ android-kit-base is compatible with 6.1.5 (44 classes compared, 0 with additions only).

Compares the release AAR against the same artifact at the last version published to Maven Central; R8-renamed classes and members are excluded (see the script docstring). Full japicmp HTML/XML reports are attached as the api-compat-reports workflow artifact. This check is not in the required-check set yet, so a red result here does not block merging.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

📦 SDK Size Impact Report

What the SDK adds to a minified release APK.

Measured against an empty baseline app. Unlike the Rokt kit, android-core ships no Compose and no resources, so there is nothing here that a host app would already provide.

mParticle Core SDK

Metric Target branch This PR Change
APK size 119.78 KB 119.79 KB +14 bytes
Download size 117.59 KB 117.61 KB +14 bytes
Dex bytes 213.75 KB 213.75 KB 0 bytes

➡️ SDK size impact change is minimal.

Raw measurements

Target branch:

{"baseline_dex_bytes": 0, "baseline_download_bytes": 2518, "baseline_install_bytes": 7534, "core_dex_bytes": 218884, "core_download_bytes": 122935, "core_install_bytes": 130188}

This PR:

{"baseline_dex_bytes": 0, "baseline_download_bytes": 2512, "baseline_install_bytes": 7528, "core_dex_bytes": 218884, "core_download_bytes": 122943, "core_install_bytes": 130196}

Measured 6222f9b merged into 2b7cfed

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

📦 SDK Size Impact Report

What the SDK adds to a minified release APK.

Measured against a Compose + Material3 reference app, so these are the costs on top of an app that already ships Compose. The reference app's dependencies are a documented convention, not a measured average: see size-report-rokt/README.md.

mParticle Core + Rokt kit

Metric Target branch This PR Change
APK size 1.26 MB 1.26 MB 0 bytes
Download size 1.24 MB 1.24 MB -3 bytes
Dex bytes 2.22 MB 2.22 MB 0 bytes

Rokt SDK+ umbrella (adds the payment extension)

Metric Target branch This PR Change On top of mParticle Core + Rokt kit
APK size 6.53 MB 6.53 MB 0 bytes +5.27 MB
Download size 6.43 MB 6.43 MB +2 bytes +5.19 MB
Dex bytes 7.10 MB 7.10 MB 0 bytes +4.89 MB

➡️ SDK size impact change is minimal.

Raw measurements

Target branch:

{"baseline_dex_bytes": 1829108, "baseline_download_bytes": 1240062, "baseline_install_bytes": 1300934, "kit_dex_bytes": 4156052, "kit_download_bytes": 2540334, "kit_install_bytes": 2623275, "sdkplus_dex_bytes": 9278708, "sdkplus_download_bytes": 7978463, "sdkplus_install_bytes": 8148975}

This PR:

{"baseline_dex_bytes": 1829108, "baseline_download_bytes": 1240062, "baseline_install_bytes": 1300934, "kit_dex_bytes": 4156052, "kit_download_bytes": 2540331, "kit_install_bytes": 2623275, "sdkplus_dex_bytes": 9278708, "sdkplus_download_bytes": 7978465, "sdkplus_install_bytes": 8148975}

Measured 6222f9b merged into 2b7cfed

@nickolas-dimitrakas nickolas-dimitrakas self-assigned this Oct 7, 2026
@nickolas-dimitrakas
nickolas-dimitrakas marked this pull request as ready for review October 7, 2026 19:53
@nickolas-dimitrakas
nickolas-dimitrakas requested a review from a team as a code owner October 7, 2026 19:53
@nickolas-dimitrakas
nickolas-dimitrakas merged commit a124f8b into main Oct 7, 2026
46 checks passed
@nickolas-dimitrakas
nickolas-dimitrakas deleted the build/jvm-toolchain branch October 7, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants