diff --git a/foundation/database/src/main/kotlin/inject/DatabaseModule.kt b/foundation/database/src/main/kotlin/inject/DatabaseModule.kt index feb593e8..389c9e5f 100644 --- a/foundation/database/src/main/kotlin/inject/DatabaseModule.kt +++ b/foundation/database/src/main/kotlin/inject/DatabaseModule.kt @@ -8,6 +8,7 @@ package ru.pixnews.foundation.database.inject import android.content.Context import androidx.room.Room import androidx.room.RoomDatabase.JournalMode.WRITE_AHEAD_LOGGING +import androidx.sqlite.driver.bundled.BundledSQLiteDriver import co.touchlab.kermit.Logger import com.squareup.anvil.annotations.ContributesTo import com.squareup.anvil.annotations.optional.SingleIn @@ -15,7 +16,9 @@ import dagger.Module import dagger.Provides import ru.pixnews.foundation.appconfig.AppConfig import ru.pixnews.foundation.appconfig.logDatabaseQueries +import ru.pixnews.foundation.coroutines.IoCoroutineDispatcherProvider import ru.pixnews.foundation.database.PixnewsDatabase +import ru.pixnews.foundation.database.PixnewsDatabase_Impl import ru.pixnews.foundation.database.util.QueryLogger import ru.pixnews.foundation.di.base.qualifiers.ApplicationContext import ru.pixnews.foundation.di.base.scopes.AppScope @@ -28,15 +31,18 @@ public object DatabaseModule { public fun providePixnewsDatabase( @ApplicationContext applicationContext: Context, appConfig: AppConfig, + databaseDispatcher: IoCoroutineDispatcherProvider, logger: Logger, ): PixnewsDatabase { - val builder = Room.databaseBuilder( - applicationContext, - PixnewsDatabase::class.java, - "pixnews", + val builder = Room.databaseBuilder( + context = applicationContext, + name = "pixnews", + factory = ::PixnewsDatabase_Impl, ) .setJournalMode(WRITE_AHEAD_LOGGING) .createFromAsset("pixnews.db") + .setDriver(BundledSQLiteDriver()) + .setQueryCoroutineContext(databaseDispatcher.get()) if (appConfig.logDatabaseQueries()) { builder.setQueryCallback(QueryLogger(logger), QueryLogger.createLoggerExecutor()) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f74f65c4..83f16d17 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,7 @@ anvil = "2.5.0-beta09" bmversions = "0.51.0" detekt = "1.23.6" diktat = "2.0.0" -detekt-compose-rules = "0.3.21" +detekt-compose-rules = "0.4.1" dagger = "2.51.1" kotlin = "1.9.24" ksp = "1.9.24-1.0.20" @@ -40,14 +40,15 @@ androidx-navigation-compose = "2.7.7" androidx-paging = "3.3.0" androidx-paging-compose = "3.3.0" androidx-profileinstaller = "1.3.1" -androidx-room = "2.6.1" +androidx-room = "2.7.0-alpha02" androidx-splashscreen = "1.1.0-rc01" +androidx-sqlite = "2.5.0-alpha02" androidx-startup = "1.2.0-alpha02" -androidx-test-core = "1.6.0-alpha06" -androidx-test-espresso = "3.6.0-alpha04" +androidx-test-core = "1.6.0-beta01" +androidx-test-espresso = "3.6.0-beta01" androidx-test-junit = "1.1.5" -androidx-test-runner = "1.6.0-alpha07" -androidx-test-rules = "1.6.0-alpha04" +androidx-test-runner = "1.6.0-beta01" +androidx-test-rules = "1.6.0-beta01" androidx-test-uiautomator = "2.3.0" androidx-tracing = "1.3.0-alpha02" androidx-tracing-perfetto = "1.0.0-alpha12" @@ -68,7 +69,7 @@ kotest = "5.9.0" kotest-assertions-arrow = "1.4.0" kotlin-compile-testing-fork = "0.4.1" kotlinpoet = "1.16.0" -mockk = "1.13.10" +mockk = "1.13.11" mockwebserver-dsl = "1.0.0" okhttp = "4.12.0" okio = "3.9.0" @@ -123,10 +124,13 @@ androidx-paging-common = { group = "androidx.paging", name = "paging-common", ve androidx-paging-compose = { group = "androidx.paging", name = "paging-compose", version.ref = "androidx-paging-compose" } androidx-paging-testing = { group = "androidx.paging", name = "paging-testing", version.ref = "androidx-paging-compose" } androidx-profileinstaller = { group = "androidx.profileinstaller", name = "profileinstaller", version.ref = "androidx-profileinstaller" } -androidx-room = { group = "androidx.room", name = "room-ktx", version.ref = "androidx-room" } +androidx-room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "androidx-room" } androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "androidx-room" } androidx-room-testing = { group = "androidx.room", name = "room-testing", version.ref = "androidx-room" } androidx-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "androidx-splashscreen" } +androidx-sqlite = { group = "androidx.sqlite", name = "sqlite", version.ref = "androidx-sqlite" } +androidx-sqlite-framework = { group = "androidx.sqlite", name = "sqlite-framework", version.ref = "androidx-sqlite" } +androidx-sqlite-bundled = { group = "androidx.sqlite", name = "sqlite-bundled", version.ref = "androidx-sqlite" } androidx-startup = { group = "androidx.startup", name = "startup-runtime", version.ref = "androidx-startup" } androidx-test-core = { group = "androidx.test", name = "core-ktx", version.ref = "androidx-test-core" } androidx-test-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidx-test-espresso" } diff --git a/gradle/plugin/project/android/convention/room.gradle.kts b/gradle/plugin/project/android/convention/room.gradle.kts index 9771567c..0a1f6b1d 100644 --- a/gradle/plugin/project/android/convention/room.gradle.kts +++ b/gradle/plugin/project/android/convention/room.gradle.kts @@ -37,8 +37,9 @@ extensions.configure>("android") { dependencies { add("annotationProcessor", versionCatalog.findLibrary("androidx.room.compiler").get()) - add("api", versionCatalog.findLibrary("androidx.room").get()) + add("api", versionCatalog.findLibrary("androidx.room.runtime").get()) add("ksp", versionCatalog.findLibrary("androidx.room.compiler").get()) + add("implementation", versionCatalog.findLibrary("androidx.sqlite.bundled").get()) add("testImplementation", versionCatalog.findLibrary("androidx.room.testing").get()) } diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 6ec32222..f46932e7 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -139,6 +139,8 @@ + + diff --git a/settings.gradle.kts b/settings.gradle.kts index ebc23cf3..04f26fb8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -25,7 +25,7 @@ buildscript { classpath("com.google.devtools.ksp:symbol-processing-gradle-plugin:1.9.24-1.0.20") classpath("com.squareup.wire:wire-gradle-plugin:4.9.9") classpath("com.github.ben-manes:gradle-versions-plugin:0.51.0") - classpath("androidx.room:androidx.room.gradle.plugin:2.6.1") + classpath("androidx.room:androidx.room.gradle.plugin:2.7.0-alpha02") classpath("com.diffplug.spotless:spotless-plugin-gradle:6.25.0") classpath("com.saveourtool.diktat:diktat-gradle-plugin:2.0.0") classpath("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.6")