Posted by Ben Trengrove – Developer Relations Engineer, Nick Butcher – Product Supervisor for Jetpack Compose
We’re excited to announce that with the upcoming launch of Kotlin 2.0, the Jetpack Compose compiler will transfer to the Kotlin repository. Because of this an identical Compose compiler will launch alongside every launch of Kotlin. You’ll not have to attend for an identical Compose compiler launch earlier than upgrading the Kotlin model in your Compose app. The Compose workforce at Google will proceed to be answerable for creating the compiler and can work intently with JetBrains, our co-founders of the Kotlin Basis. The model of the Compose compiler now all the time matches the Kotlin model. The compiler model is subsequently leaping to 2.0.0.
To simplify the arrange of Compose, we’re additionally releasing a brand new Compose Compiler Gradle plugin which helps you to configure the Compose compiler with a sort protected API. The Compose Compiler Gradle plugin’s versioning matches Kotlin’s, and it’s accessible from Kotlin 2.0.0.
Emigrate to the brand new plugin, add the Compose Compiler Gradle plugin dependency to the plugins part of your Gradle model catalog:
[versions]
kotlin = "2.0.0"
[plugins]
org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", model.ref = "kotlin" }
// Add the Compose Compiler Gradle plugin, the model matches the Kotlin plugin
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", model.ref = "kotlin" }
In your venture’s root stage Gradle file, add the plugin:
plugins {
// Current plugins
alias(libs.plugins.compose.compiler) apply false
}
Then in modules that use Compose, apply the plugin:
plugins {
// Current plugins
alias(libs.plugins.compose.compiler)
}
The kotlinCompilerExtensionVersion is not required to be configured in composeOptions and could be eliminated.
composeOptions {
kotlinCompilerExtensionVersion = libs.variations.compose.compiler.get()
}
If required, now you can add a high stage part to the identical Gradle file to configure choices for the Compose compiler.
android { ... }
composeCompiler {
enableStrongSkippingMode = true
}
You may at present straight referencing the Compose compiler in your construct setup, slightly than utilizing AGP to use the compose compiler plugin. If that’s the case, observe that the maven artifacts may also change:
Previous |
New |
androidx.compose.compiler:compiler |
org.jetbrains.kotlin:kotlin-compose-compiler-plugin-embeddable |
androidx.compose.compiler:compiler-hosted |
org.jetbrains.kotlin:kotlin-compose-compiler-plugin |
For an instance of this migration, see this pull request.
For extra info on migrating to the brand new Compose compiler artifact, together with directions for non-version catalog setups, see our up to date documentation.
Leave a Comment