Skip to content

Commit 4dc8b8a

Browse files
authored
Merge pull request #352 from skydoves/kotlin/2.0.0
Bump Kotlin to 2.0.0 and Compose compiler
2 parents fc6bcf7 + face74a commit 4dc8b8a

File tree

4 files changed

+48
-69
lines changed

4 files changed

+48
-69
lines changed
Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,50 @@
11
plugins {
2-
`kotlin-dsl`
2+
`kotlin-dsl`
33
}
44

55
group = "com.skydoves.chatgpt.buildlogic"
66

77
java {
8-
sourceCompatibility = JavaVersion.VERSION_17
9-
targetCompatibility = JavaVersion.VERSION_17
8+
sourceCompatibility = JavaVersion.VERSION_17
9+
targetCompatibility = JavaVersion.VERSION_17
1010
}
1111

1212
dependencies {
13-
compileOnly(libs.android.gradlePlugin)
14-
compileOnly(libs.kotlin.gradlePlugin)
15-
compileOnly(libs.spotless.gradlePlugin)
13+
compileOnly(libs.android.gradlePlugin)
14+
compileOnly(libs.kotlin.gradlePlugin)
15+
compileOnly(libs.compose.compiler.gradlePlugin)
16+
compileOnly(libs.spotless.gradlePlugin)
1617
}
1718

1819
gradlePlugin {
19-
plugins {
20-
register("androidApplicationCompose") {
21-
id = "skydoves.android.application.compose"
22-
implementationClass = "AndroidApplicationComposeConventionPlugin"
23-
}
24-
register("androidApplication") {
25-
id = "skydoves.android.application"
26-
implementationClass = "AndroidApplicationConventionPlugin"
27-
}
28-
register("androidLibraryCompose") {
29-
id = "skydoves.android.library.compose"
30-
implementationClass = "AndroidLibraryComposeConventionPlugin"
31-
}
32-
register("androidLibrary") {
33-
id = "skydoves.android.library"
34-
implementationClass = "AndroidLibraryConventionPlugin"
35-
}
36-
register("androidFeature") {
37-
id = "skydoves.android.feature"
38-
implementationClass = "AndroidFeatureConventionPlugin"
39-
}
40-
register("androidHilt") {
41-
id = "skydoves.android.hilt"
42-
implementationClass = "AndroidHiltConventionPlugin"
43-
}
44-
register("spotless") {
45-
id = "skydoves.spotless"
46-
implementationClass = "SpotlessConventionPlugin"
47-
}
20+
plugins {
21+
register("androidApplicationCompose") {
22+
id = "skydoves.android.application.compose"
23+
implementationClass = "AndroidApplicationComposeConventionPlugin"
4824
}
25+
register("androidApplication") {
26+
id = "skydoves.android.application"
27+
implementationClass = "AndroidApplicationConventionPlugin"
28+
}
29+
register("androidLibraryCompose") {
30+
id = "skydoves.android.library.compose"
31+
implementationClass = "AndroidLibraryComposeConventionPlugin"
32+
}
33+
register("androidLibrary") {
34+
id = "skydoves.android.library"
35+
implementationClass = "AndroidLibraryConventionPlugin"
36+
}
37+
register("androidFeature") {
38+
id = "skydoves.android.feature"
39+
implementationClass = "AndroidFeatureConventionPlugin"
40+
}
41+
register("androidHilt") {
42+
id = "skydoves.android.hilt"
43+
implementationClass = "AndroidHiltConventionPlugin"
44+
}
45+
register("spotless") {
46+
id = "skydoves.spotless"
47+
implementationClass = "SpotlessConventionPlugin"
48+
}
49+
}
4950
}

build-logic/convention/src/main/kotlin/com/skydoves/chatgpt/AndroidCompose.kt

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,26 @@ import java.io.File
55
import org.gradle.api.Project
66
import org.gradle.api.artifacts.VersionCatalogsExtension
77
import org.gradle.kotlin.dsl.getByType
8+
import org.gradle.kotlin.dsl.assign
9+
import org.gradle.kotlin.dsl.configure
10+
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
811

912
/**
1013
* Configure Compose-specific options
1114
*/
1215
internal fun Project.configureAndroidCompose(
1316
commonExtension: CommonExtension<*, *, *, *, *, *>,
1417
) {
15-
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
18+
pluginManager.apply("org.jetbrains.kotlin.plugin.compose")
1619

1720
commonExtension.apply {
1821
buildFeatures {
1922
compose = true
2023
}
21-
22-
composeOptions {
23-
kotlinCompilerExtensionVersion = libs.findVersion("androidxComposeCompiler").get().toString()
24-
}
25-
26-
kotlinOptions {
27-
freeCompilerArgs = freeCompilerArgs + buildComposeMetricsParameters()
28-
}
29-
}
30-
}
31-
32-
private fun Project.buildComposeMetricsParameters(): List<String> {
33-
val metricParameters = mutableListOf<String>()
34-
val enableMetricsProvider = project.providers.gradleProperty("enableComposeCompilerMetrics")
35-
val enableMetrics = (enableMetricsProvider.orNull == "true")
36-
if (enableMetrics) {
37-
val metricsFolder = File(project.buildDir, "compose-metrics")
38-
metricParameters.add("-P")
39-
metricParameters.add(
40-
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + metricsFolder.absolutePath
41-
)
4224
}
4325

44-
val enableReportsProvider = project.providers.gradleProperty("enableComposeCompilerReports")
45-
val enableReports = (enableReportsProvider.orNull == "true")
46-
if (enableReports) {
47-
val reportsFolder = File(project.buildDir, "compose-reports")
48-
metricParameters.add("-P")
49-
metricParameters.add(
50-
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + reportsFolder.absolutePath
51-
)
26+
extensions.configure<ComposeCompilerGradlePluginExtension> {
27+
enableStrongSkippingMode = true
28+
reportsDestination = layout.buildDirectory.dir("compose_compiler")
5229
}
53-
return metricParameters.toList()
5430
}

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ buildscript {
77

88
plugins {
99
alias(libs.plugins.android.application) apply false
10+
alias(libs.plugins.compose.compiler) apply false
1011
alias(libs.plugins.kotlin.jvm) apply false
1112
alias(libs.plugins.ksp) apply false
1213
alias(libs.plugins.hilt) apply false

gradle/libs.versions.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ androidGradlePlugin = "8.4.2"
77
androidxActivity = "1.9.0"
88
androidxAppCompat = "1.7.0"
99
androidxCompose = "1.6.8"
10-
androidxComposeCompiler = "1.5.11"
1110
androidxComposeMaterial3 = "1.2.1"
1211
androidxComposeConstraintLayout = "1.0.1"
1312
androidxComposeNavigation = "2.7.7"
@@ -28,9 +27,9 @@ viewModelLifecycle = "1.1.0"
2827
hilt = "2.51.1"
2928
hiltWorker = "1.2.0"
3029
junit4 = "4.13.2"
31-
kotlin = "1.9.23"
30+
kotlin = "2.0.0"
3231
kotlinxCoroutines = "1.8.1"
33-
ksp = "1.9.23-1.0.20"
32+
ksp = "2.0.0-1.0.22"
3433
ktlint = "0.43.0"
3534
okhttp = "4.12.0"
3635
googleSecretPlugin = "2.0.1"
@@ -99,12 +98,14 @@ firebase-crashlytics = { module = "com.google.firebase:firebase-crashlytics" }
9998
# Dependencies of the included build-logic
10099
android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" }
101100
kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
101+
compose-compiler-gradlePlugin = { group = "org.jetbrains.kotlin", name = "compose-compiler-gradle-plugin", version.ref = "kotlin" }
102102
spotless-gradlePlugin = { group = "com.diffplug.spotless", name = "spotless-plugin-gradle", version.ref = "spotless" }
103103

104104
[plugins]
105105
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
106106
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
107107
android-test = { id = "com.android.test", version.ref = "androidGradlePlugin" }
108+
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
108109
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
109110
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
110111
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

0 commit comments

Comments
 (0)