Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / build-logic / src / main / kotlin / RoomExtension.kt

RoomExtension.kt26 lines · 1.1 KiBRaw
1import com.google.devtools.ksp.gradle.KspExtension
2import org.gradle.api.Project
3import org.gradle.kotlin.dsl.DependencyHandlerScope
4import org.gradle.kotlin.dsl.configure
5
6fun 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 */
19fun 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}