Skip to content

Commit

Permalink
Merge pull request #23 from skydoves/kotlin/2.0.0
Browse files Browse the repository at this point in the history
Migrate to Kotlin 2.0.0 and Compose compiler
  • Loading branch information
skydoves authored May 22, 2024
2 parents 10a0464 + 4916bc6 commit de49565
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 37 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ android {
buildConfig = true
}

composeOptions {
kotlinCompilerExtensionVersion = libs.versions.androidxComposeCompiler.get()
composeCompiler {
enableStrongSkippingMode = true
reportsDestination = layout.buildDirectory.dir("compose_compiler")
}

hilt {
Expand Down
1 change: 1 addition & 0 deletions baselineprofile/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
alias(libs.plugins.android.test)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.baselineprofile)
id("skydoves.pokedex.spotless")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class AndroidApplicationComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("com.android.application")
pluginManager.apply("org.jetbrains.kotlin.plugin.compose")
val extension = extensions.getByType<BaseAppModuleExtension>()
configureAndroidCompose(extension)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class AndroidFeatureConventionPlugin : Plugin<Project> {
pluginManager.apply {
apply("com.android.library")
apply("org.jetbrains.kotlin.android")
apply("org.jetbrains.kotlin.plugin.compose")
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class AndroidLibraryComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("com.android.library")
pluginManager.apply("org.jetbrains.kotlin.plugin.compose")
val extension = extensions.getByType<LibraryExtension>()
configureAndroidCompose(extension)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,9 @@ import org.gradle.kotlin.dsl.getByType
internal fun Project.configureAndroidCompose(
commonExtension: CommonExtension<*, *, *, *, *, *>,
) {
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")

commonExtension.apply {
buildFeatures {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = libs.findVersion("androidxComposeCompiler").get().toString()
}

kotlinOptions {
freeCompilerArgs = freeCompilerArgs + buildComposeMetricsParameters()
}
}
}

private fun Project.buildComposeMetricsParameters(): List<String> = buildList {
val enableMetricsProvider = project.providers.gradleProperty("enableComposeCompilerMetrics")
val enableMetrics = (enableMetricsProvider.orNull == "true")
if (enableMetrics) {
val metricsFolder = project.layout.buildDirectory.dir("compose-metrics").get()
add("-P")
add(
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=$metricsFolder"
)
}

val enableReportsProvider = project.providers.gradleProperty("enableComposeCompilerReports")
val enableReports = (enableReportsProvider.orNull == "true")
if (enableReports) {
val reportsFolder = project.layout.buildDirectory.dir("compose-reports").get()
add("-P")
add(
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=$reportsFolder"
)
}
}
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.kotlinx.serialization) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.hilt.plugin) apply false
alias(libs.plugins.spotless)
alias(libs.plugins.baselineprofile) apply false
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
agp = "8.4.0"
kotlin = "1.9.24"
ksp = "1.9.24-1.0.20"
kotlin = "2.0.0"
ksp = "2.0.0-1.0.21"
kotlinxImmutable = "0.3.7"
androidxActivity = "1.9.0"
androidxCore = "1.13.1"
Expand All @@ -10,7 +10,6 @@ androidxRoom = "2.6.1"
androidxArchCore = "2.2.0"
androidXStartup = "1.1.1"
androidxCompose = "1.7.0-beta01"
androidxComposeCompiler = "1.5.14"
androidxComposeMaterial3 = "1.3.0-beta01"
androidxNavigation = "2.8.0-beta01"
androidxHiltNavigationCompose = "1.2.0"
Expand Down Expand Up @@ -106,6 +105,7 @@ kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref =
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
hilt-plugin = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
baselineprofile = { id = "androidx.baselineprofile", version.ref = "baselineprofile" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }

[bundles]
retrofitBundle = ["retrofit", "retrofit-kotlinx-serialization", "okhttp-logging-interceptor"]

0 comments on commit de49565

Please sign in to comment.