Skip to content

Commit

Permalink
refactor: migrate from legacy libraries
Browse files Browse the repository at this point in the history
Finishes migration from dbflow to room keeping the schema,
Also includes the jackson to moshi migration to drop reflection,
drops the last remaining usages of rxjava, and finalizes
migration from mvp to mvvm.
  • Loading branch information
kelsos committed Jan 8, 2025
1 parent ec41973 commit 547334e
Show file tree
Hide file tree
Showing 389 changed files with 9,802 additions and 10,315 deletions.
86 changes: 52 additions & 34 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.kotlinParcelize)
alias(libs.plugins.kapt)
alias(libs.plugins.ksp)
alias(libs.plugins.protobuf)
alias(libs.plugins.googleServices) apply false
Expand Down Expand Up @@ -77,8 +76,8 @@ fun gitHash(): String {
return "git -C $rootDir rev-parse --short HEAD".runCommand()
}

val version = "1.6.0-alpha.1"
val code = 125
val appVersionName = "1.6.0-alpha.1"
val appVersionCode = 125

android {
compileSdk = 35
Expand All @@ -92,12 +91,16 @@ android {
applicationId = "com.kelsos.mbrc"
minSdk = 23
targetSdk = 35
versionCode = code
versionName = version
versionCode = appVersionCode
versionName = appVersionName
buildConfigField("String", "GIT_SHA", "\"${gitHash()}\"")
buildConfigField("String", "BUILD_TIME", "\"${buildTime()}\"")

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}
}

testOptions {
Expand Down Expand Up @@ -191,6 +194,13 @@ android {
}
}


detekt {
source.setFrom(files("src/main/java", "src/main/kotlin"))
config.setFrom(files(rootProject.file("config/detekt/detekt.yml")))
buildUponDefaultConfig = true
}

val dummyGoogleServicesJson: Configuration by configurations.creating {
isCanBeResolved = true
isCanBeConsumed = false
Expand All @@ -205,18 +215,6 @@ dependencies {

implementation(projects.changelog)

testImplementation(libs.androidx.arch.core.testing)
testImplementation(libs.androidx.test.core)
testImplementation(libs.androidx.test.runner)
testImplementation(libs.androidx.test.junit)
testImplementation(libs.androidx.test.truth)
testImplementation(libs.bundles.androidx.test.espresso)
testImplementation(libs.truth)
testImplementation(libs.koin.test)
testImplementation(libs.kotlin.coroutines.test)
testImplementation(libs.mockk)
testImplementation(libs.robolectric)

implementation(libs.androidx.annotation)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core.ktx)
Expand All @@ -233,23 +231,34 @@ dependencies {
implementation(libs.androidx.legacy.support.v4)
implementation(libs.androidx.legacy.support.v13)
implementation(libs.bundles.coroutines)
implementation(libs.bundles.androidx.room)
implementation(libs.bundles.coil)
implementation(libs.bundles.koin)
implementation(libs.google.material)
implementation(libs.google.protobuf.javalite)
implementation(libs.squareup.moshi.lib)
implementation(libs.squareup.okio)
implementation(libs.squareup.okhttp)
implementation(libs.timber)

implementation(libs.bundles.dbflow)
implementation(libs.bundles.jackson)
implementation(libs.kotlin.stdlib)
implementation(libs.kotlin.reflect)
implementation(libs.rxandroid)
implementation(libs.rxjava)
implementation(libs.rxkotlin)
implementation(libs.rxrelay)
ksp(libs.androidx.room.compiler)
ksp(libs.squareup.moshi.codegen)

kapt(libs.dbflow.processor)
testImplementation(libs.androidx.arch.core.testing)
testImplementation(libs.androidx.room.testing)
testImplementation(libs.androidx.test.core)
testImplementation(libs.androidx.test.runner)
testImplementation(libs.androidx.test.junit)
testImplementation(libs.androidx.test.truth)
testImplementation(libs.bundles.androidx.test.espresso)
testImplementation(libs.androidx.paging.common.ktx)
testImplementation(libs.androidx.paging.testing)
testImplementation(libs.turbine)
testImplementation(libs.truth)
testImplementation(libs.koin.test)
testImplementation(libs.kotlin.coroutines.test)
testImplementation(libs.mockk)
testImplementation(libs.robolectric)

debugImplementation(libs.squareup.leakcanary)
debugImplementation(libs.androidx.fragment.testing)
Expand Down Expand Up @@ -336,7 +345,8 @@ tasks {
}
detekt.forEach {
from(it.sarifReportFile) {
rename { "detekt.sarif" }
val name = it.sarifReportFile.get().asFile.nameWithoutExtension.prefixIfNot("detekt").toKebabCase()
rename { "$name.sarif" }
}
}
from(lintReportReleaseSarifOutput) {
Expand Down Expand Up @@ -365,7 +375,8 @@ tasks {
doLast {
if (!project.file("google-services.json").exists()) {
throw GradleException(
"You need a google-services.json file to run this project. Please refer to the CONTRIBUTING.md file for details."
"You need a google-services.json file to run this project." +
" Please refer to the CONTRIBUTING.md file for details."
)
}
}
Expand All @@ -379,16 +390,23 @@ tasks {
}
}

kotlin {
sourceSets.all {
languageSettings.enableLanguageFeature("ExplicitBackingFields")
}
}

configurations.all {
resolutionStrategy {
force("com.google.code.findbugs:jsr305:3.0.2")
force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${project.libs.versions.kotlin.get()}")
force("org.jetbrains.kotlin:kotlin-reflect:${project.libs.versions.kotlin.get()}")
}
}


fun String.toKebabCase(): String {
return this.trim()
.replace(Regex("([a-z])([A-Z])"), "$1-$2")
.replace(Regex("[\\s_]+"), "-")
.replace(Regex("[^a-zA-Z0-9-]"), "")
.lowercase()
}

fun String.prefixIfNot(prefix: String): String {
return if (this.startsWith(prefix)) this else "$prefix-$this"
}
Loading

0 comments on commit 547334e

Please sign in to comment.