Skip to content

Commit

Permalink
Update Room to 2.7.0-alpha02 with bundled sqlite driver. Update other…
Browse files Browse the repository at this point in the history
… dependencies (#284)
  • Loading branch information
illarionov authored May 19, 2024
1 parent 0fc2c98 commit 2104ef5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
14 changes: 10 additions & 4 deletions foundation/database/src/main/kotlin/inject/DatabaseModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ 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
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
Expand All @@ -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<PixnewsDatabase>(
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())
Expand Down
20 changes: 12 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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" }
Expand Down
3 changes: 2 additions & 1 deletion gradle/plugin/project/android/convention/room.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ extensions.configure<CommonExtension<*, *, *, *, *, *>>("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())
}
2 changes: 2 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@
<trusting group="androidx.fragment"/>
<trusting group="androidx.lifecycle"/>
<trusting group="androidx.paging"/>
<trusting group="androidx.room"/>
<trusting group="androidx.sqlite"/>
<trusting group="^androidx[.]compose($|([.].*))" regex="true"/>
<trusting group="^androidx[.]test($|([.].*))" regex="true"/>
</trusted-key>
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 2104ef5

Please sign in to comment.