My current Android application employs build-logic to define standard plugins
the Room plugin resembles this:-
class AndroidRoomConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("androidx.room")
pluginManager.apply("com.google.devtools.ksp")
extensions.configure<KspExtension> {
arg("room.generateKotlin", "false")
}
extensions.configure<RoomExtension> {
// The schemas directory contains a schema file for each version of the Room database.
// This is required to enable Room auto migrations.
// See https://developer.android.com/reference/kotlin/androidx/room/AutoMigration.
schemaDirectory("$projectDir/schemas")
}
dependencies {
add("api", libs.findLibrary("room.runtime").get())
add("api", libs.findLibrary("room.ktx").get())
add("ksp", libs.findLibrary("room.compiler").get())
}
}
}
}
is there an approach I can take to control when/if the following snippet is added to the gradle build file?
extensions.configure<RoomExtension> {
// The schemas directory contains a schema file for each version of the Room database.
// This is required to enable Room auto migrations.
// See https://developer.android.com/reference/kotlin/androidx/room/AutoMigration.
schemaDirectory("$projectDir/schemas")
}
the reason i require this conditional build configuration is the my Android application has a number of feature modules which each have their own Room schema location and i do not want to add “duplicate”
room {
schemaDirectory("$projectDir/fetaureOneSchemas")
}
to these modules?
is there anyway I can detect the existence of the room { schemaDirectory() }
entry in the existing gradle build file from within my AndroidRoomConventionPlugin and NOT add another…
extensions.configure<RoomExtension> {
// The schemas directory contains a schema file for each version of the Room database.
// This is required to enable Room auto migrations.
// See https://developer.android.com/reference/kotlin/androidx/room/AutoMigration.
schemaDirectory("$projectDir/schemas")
}
so as NOT to add another/duplicate room { schemaDirectory() }
entry?