Skip to content

Migrate to AGP 9 built-in Kotlin and new DSL [CLF-723] - #201

Merged
zach-klippenstein merged 1 commit into
mainfrom
zachklipp/agp-builtin-kotlin
Nov 4, 2026
Merged

zach-klippenstein merged 1 commit into
mainfrom
zachklipp/agp-builtin-kotlin

Conversation

@zach-klippenstein

Copy link
Copy Markdown
Collaborator

Follow-up to #199. That PR temporarily set android.builtInKotlin=false and android.newDsl=false so the standalone org.jetbrains.kotlin.android plugin kept working under AGP 9.1.1. AGP marks both flags deprecated and removes them in AGP 10. This PR removes them and finishes the migration.

Stacked on #199 (base is zachklipp/compose-1-12-a559f8); retarget to main once that merges.

Changes

  • Drop kotlin("android") from all six modules; AGP compiles Kotlin itself. kotlin-gradle-plugin stays on the buildscript classpath to pin the Kotlin version (AGP has a runtime dependency on KGP and a higher classpath version wins), and org.jetbrains.kotlin.plugin.compose remains the Compose compiler wiring for the Compose modules.
  • Move compiler options from tasks.withType<KotlinCompile> to the kotlin {} extension AGP registers. jvmTarget is no longer set explicitly: built-in Kotlin defaults it to compileOptions.targetCompatibility, so radiography stays on JVM 1.8 / compileSdk 35 (verified: release classes are major version 52, POM unchanged vs. 2.10) and the two Compose test modules on JVM 11 (major version 55).
  • radiography now uses kotlin { explicitApi() }; AGP applies it to production sources only, which resolves the old TODO about KT-37652.
  • binary-compatibility-validator: BCV 0.16.3 (and its master branch) only configures Android modules via pluginManager.withPlugin("kotlin-android"), so under built-in Kotlin it registered no api tasks and ./gradlew apiCheck failed with "task not found". Bumping BCV doesn't help, and KGP 2.3.10's KotlinAndroidProjectExtension has no abiValidation. radiography/build.gradle.kts now registers BCV's public KotlinApiBuildTask / KotlinApiCompareTask plus an apiDump task itself, mirroring BCV's kotlin-android path, and adds kotlin-metadata-jvm to BCV's worker classpath. api/radiography.api is unchanged.
  • Drop the explicit kotlin("stdlib") dependency in stoic-plugin; built-in Kotlin adds it.

Verification

  • ./gradlew build --warning-mode all: green, zero deprecation warnings (none about org.jetbrains.kotlin.android, the old Project.android(...) DSL, or android.newDsl).
  • ./gradlew apiCheck: passes with no .api changes; apiDump is a no-op. Sanity-checked that it fails when a public class is added and that explicit API mode still rejects implicit visibility in main sources.
  • ./gradlew connectedCheck on a USB Samsung SM-A256U1 (Android 16): 43 tests, 0 failures across all five instrumented modules.

🤖 Generated with Claude Code

Removes the temporary android.builtInKotlin=false / android.newDsl=false
opt-outs added with the Compose 1.12.1 upgrade. AGP marks both deprecated
and removes them in AGP 10.

- Drop the standalone org.jetbrains.kotlin.android plugin from every module;
  AGP now compiles Kotlin itself. The Kotlin Gradle plugin stays on the
  buildscript classpath to pin the Kotlin version (AGP depends on KGP at
  runtime and a higher classpath version wins), and the
  org.jetbrains.kotlin.plugin.compose plugin is still the Compose compiler
  wiring for the Compose modules.
- Move compiler options from tasks.withType<KotlinCompile> to the kotlin {}
  extension AGP registers. jvmTarget is no longer set explicitly: built-in
  Kotlin defaults it to compileOptions.targetCompatibility, so radiography
  stays on JVM 1.8 and the Compose test modules on JVM 11.
- Use kotlin { explicitApi() } in radiography; AGP applies it to production
  sources only, resolving the old TODO.
- binary-compatibility-validator 0.16.3 only configures Android modules when
  it sees the kotlin-android plugin id, so it registered no api tasks at all
  under built-in Kotlin. radiography/build.gradle.kts now registers BCV's
  public apiBuild/apiCheck/apiDump task types itself, mirroring BCV's
  kotlin-android path, and adds kotlin-metadata-jvm to BCV's worker
  classpath. api/radiography.api is unchanged.
- Drop the explicit kotlin("stdlib") dependency in stoic-plugin; built-in
  Kotlin adds it.

Verified: ./gradlew build --warning-mode all is green with no deprecation
warnings, apiCheck passes with no .api changes (and fails on an added public
class), and connectedCheck passes on a Samsung SM-A256U1 (43 tests).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Base automatically changed from zachklipp/compose-1-12-a559f8 to main November 4, 2026 08:12
@zach-klippenstein
zach-klippenstein merged commit 373c302 into main Nov 4, 2026
8 checks passed
@zach-klippenstein
zach-klippenstein deleted the zachklipp/agp-builtin-kotlin branch November 4, 2026 19:17
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