Posted by Ben Tregrove – Developer Relations Engineer, Nick Butcher – Product Manager for Jetpack Write
We are happy to announce that the Jetpack Composer compiler will be moving to the Kotlin repository in the upcoming Kotlin 2.0 release. This means that a corresponding Compose compiler is released alongside each Kotlin release. You no longer have to wait for the corresponding editor release before updating the Kotlin version in your editor application. The scripting team at Google will continue to develop the compiler and work closely with JetBrains, the co-founders of the Kotlin Foundation. The compiler version now always matches the Kotlin version. So the compiler version is jumping to 2.0.0.
To simplify compilation, we're also releasing the Compose Compiler Gradle plugin that lets you configure the Compose Compiler with a secure API. The Compose Compiler Gradle plugin version matches Kotlin, and is available since Kotlin 2.0.0.
To migrate to the new plugin, add the Compose Compiler Gradle plugin dependency to the Plugins section of your Gradle version catalog.
[versions]
kotlin = "2.0.0"
[plugins]
org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
// Add the Compose Compiler Gradle plugin, the version matches the Kotlin plugin
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
In your project's root level Gradle file, add the plugin:
plugins {
// Existing plugins
alias(libs.plugins.compose.compiler) apply false
}
Then apply the plugin in modules that use write:
plugins {
// Existing plugins
alias(libs.plugins.compose.compiler)
}
of kotlinCompilerExtensionVersion No need to configure anymore composeOptions And it can be removed.
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
If desired, you can now add a high-level class to the same gradle file to configure options for the script compilation.
android { ... }
composeCompiler {
enableStrongSkippingMode = true
}
Currently, you may be able to reference the compiler directly in your build configuration, instead of implementing the configuration plugin using AGP. If that's the case, note that the maven artifacts will also change:
Old |
brand new |
androidx.compose.compiler: Compile |
org.jetbrains.kotlin:kotlin-compose-compiler-plugin-embeddable |
androidx.compose.compiler: Compiler-hosted |
org.jetbrains.kotlin:kotlin-compose-compiler-plugin |
For an example of this migration, see this pull request.
For more information on migrating to the new configuration management legacy, including instructions for configuring non-versioned catalogs, see the updated documentation.