Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / build-logic / src / main / kotlin / RoomExtension.kt
RoomExtension.kt26 lines · 1.1 KiBRaw
| 1 | import com.google.devtools.ksp.gradle.KspExtension |
| 2 | import org.gradle.api.Project |
| 3 | import org.gradle.kotlin.dsl.DependencyHandlerScope |
| 4 | import org.gradle.kotlin.dsl.configure |
| 5 | |
| 6 | fun DependencyHandlerScope.implementRoom(libs: org.gradle.accessors.dm.LibrariesForLibs) { |
| 7 | add("implementation", libs.androidx.room3.runtime) |
| 8 | add("ksp", libs.androidx.room3.compiler) |
| 9 | } |
| 10 | |
| 11 | /** |
| 12 | * Every Room module exports its schema to `<module>/schemas` (committed, so |
| 13 | * migrations can be tested against the actual previous schema). Wired once |
| 14 | * here instead of a per-module `ksp { arg("room.schemaLocation", ...) }` |
| 15 | * block (only `:todo` had one, and the other committed schema dirs went |
| 16 | * stale). Configuration-cache safe: resolves the project dir eagerly and |
| 17 | * captures only the resulting String. |
| 18 | */ |
| 19 | fun Project.wireRoomSchemaLocation() { |
| 20 | val schemaDir = layout.projectDirectory.dir("schemas").asFile.absolutePath |
| 21 | pluginManager.withPlugin("com.google.devtools.ksp") { |
| 22 | extensions.configure<KspExtension> { |
| 23 | arg("room.schemaLocation", schemaDir) |
| 24 | } |
| 25 | } |
| 26 | } |