Skip to content

Commit ebc6448

Browse files
committedMay 8, 2023
Room: Migrate to KSP
1 parent e523569 commit ebc6448

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed
 

‎.idea/kotlinc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎app/build.gradle.kts

+16-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import java.util.Properties
66
plugins {
77
id("com.android.application")
88
id("kotlin-android")
9+
id("com.google.devtools.ksp")
910
id("kotlin-kapt")
1011
id("org.jetbrains.kotlin.android")
1112
kotlin("plugin.serialization")
@@ -88,12 +89,9 @@ android {
8889
vectorDrawables {
8990
useSupportLibrary = true
9091
}
91-
kapt {
92-
arguments {
93-
arg("room.schemaLocation", "$projectDir/schemas")
94-
arg("room.incremental", "true")
95-
}
96-
correctErrorTypes = true
92+
ksp {
93+
arg(RoomSchemaArgProvider(File(projectDir, "schemas")))
94+
arg("room.incremental", "true")
9795
}
9896
if (!splitApks)
9997
ndk {
@@ -206,7 +204,7 @@ dependencies {
206204
implementation(libs.room.runtime)
207205
implementation(libs.room.ktx)
208206
//TODO: Migrate to KSP
209-
kapt(libs.room.compiler)
207+
ksp(libs.room.compiler)
210208

211209
// okhttp
212210
implementation(libs.okhttp)
@@ -233,3 +231,14 @@ dependencies {
233231
debugImplementation(libs.androidx.compose.ui.tooling)
234232

235233
}
234+
235+
class RoomSchemaArgProvider(
236+
@get:InputDirectory
237+
@get:PathSensitive(PathSensitivity.RELATIVE)
238+
val schemaDir: File
239+
) : CommandLineArgumentProvider {
240+
241+
override fun asArguments(): Iterable<String> {
242+
return listOf("room.schemaLocation=${schemaDir.path}")
243+
}
244+
}

‎build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ plugins {
1414
alias(libs.plugins.hilt) apply false
1515
alias(libs.plugins.kotlin.gradlePlugin) apply false
1616
alias(libs.plugins.kotlin.serialization) apply false
17+
alias(libs.plugins.kotlin.ksp) apply false
1718
}
1819

1920
tasks.register("clean", Delete::class) {

‎gradle/libs.versions.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[versions]
22
accompanist = "0.30.1"
33
androidGradlePlugin = "7.4.0"
4-
androidxComposeBom = "2023.04.01"
5-
androidxComposeCompiler = "1.4.0"
4+
androidxComposeBom = "2023.05.00"
5+
androidxComposeCompiler = "1.4.7"
66
androidxCore = "1.10.0"
77
androidMaterial = "1.9.0-rc01"
88
androidxAppCompat = "1.7.0-alpha02"
@@ -30,7 +30,8 @@ kotlinxDatetime = "0.4.0"
3030
kotlinxSerializationJson = "1.5.0"
3131
okhttp = "5.0.0-alpha.10"
3232

33-
room = "2.5.0"
33+
room = "2.5.1"
34+
ksp = "1.8.21-1.0.11"
3435

3536
youtubedlAndroid = "23b26d55f8"
3637

@@ -119,3 +120,4 @@ hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
119120
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
120121
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
121122
kotlin-gradlePlugin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
123+
kotlin-ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }

0 commit comments

Comments
 (0)
Please sign in to comment.