Skip to content

Commit a698630

Browse files
committed
refactor: migrate from legacy libraries
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.
1 parent ec41973 commit a698630

File tree

394 files changed

+10105
-10677
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

394 files changed

+10105
-10677
lines changed

app/build.gradle.kts

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ plugins {
1111
alias(libs.plugins.android.application)
1212
alias(libs.plugins.kotlinAndroid)
1313
alias(libs.plugins.kotlinParcelize)
14-
alias(libs.plugins.kapt)
1514
alias(libs.plugins.ksp)
1615
alias(libs.plugins.protobuf)
1716
alias(libs.plugins.googleServices) apply false
@@ -77,8 +76,8 @@ fun gitHash(): String {
7776
return "git -C $rootDir rev-parse --short HEAD".runCommand()
7877
}
7978

80-
val version = "1.6.0-alpha.1"
81-
val code = 125
79+
val appVersionName = "1.6.0-alpha.1"
80+
val appVersionCode = 125
8281

8382
android {
8483
compileSdk = 35
@@ -92,12 +91,16 @@ android {
9291
applicationId = "com.kelsos.mbrc"
9392
minSdk = 23
9493
targetSdk = 35
95-
versionCode = code
96-
versionName = version
94+
versionCode = appVersionCode
95+
versionName = appVersionName
9796
buildConfigField("String", "GIT_SHA", "\"${gitHash()}\"")
9897
buildConfigField("String", "BUILD_TIME", "\"${buildTime()}\"")
9998

10099
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
100+
101+
ksp {
102+
arg("room.schemaLocation", "$projectDir/schemas")
103+
}
101104
}
102105

103106
testOptions {
@@ -191,6 +194,13 @@ android {
191194
}
192195
}
193196

197+
198+
detekt {
199+
source.setFrom(files("src/main/java", "src/main/kotlin"))
200+
config.setFrom(files(rootProject.file("config/detekt/detekt.yml")))
201+
buildUponDefaultConfig = true
202+
}
203+
194204
val dummyGoogleServicesJson: Configuration by configurations.creating {
195205
isCanBeResolved = true
196206
isCanBeConsumed = false
@@ -205,18 +215,6 @@ dependencies {
205215

206216
implementation(projects.changelog)
207217

208-
testImplementation(libs.androidx.arch.core.testing)
209-
testImplementation(libs.androidx.test.core)
210-
testImplementation(libs.androidx.test.runner)
211-
testImplementation(libs.androidx.test.junit)
212-
testImplementation(libs.androidx.test.truth)
213-
testImplementation(libs.bundles.androidx.test.espresso)
214-
testImplementation(libs.truth)
215-
testImplementation(libs.koin.test)
216-
testImplementation(libs.kotlin.coroutines.test)
217-
testImplementation(libs.mockk)
218-
testImplementation(libs.robolectric)
219-
220218
implementation(libs.androidx.annotation)
221219
implementation(libs.androidx.appcompat)
222220
implementation(libs.androidx.core.ktx)
@@ -229,27 +227,37 @@ dependencies {
229227
implementation(libs.androidx.recyclerview)
230228
implementation(libs.androidx.core.splashscreen)
231229
implementation(libs.androidx.viewpager2)
230+
implementation(libs.androidx.swiperefreshlayout)
232231
implementation(libs.bundles.androidx.lifecycle)
233-
implementation(libs.androidx.legacy.support.v4)
234-
implementation(libs.androidx.legacy.support.v13)
235232
implementation(libs.bundles.coroutines)
233+
implementation(libs.bundles.androidx.room)
236234
implementation(libs.bundles.coil)
237235
implementation(libs.bundles.koin)
238236
implementation(libs.google.material)
239237
implementation(libs.google.protobuf.javalite)
238+
implementation(libs.squareup.moshi.lib)
240239
implementation(libs.squareup.okio)
240+
implementation(libs.squareup.okhttp)
241241
implementation(libs.timber)
242242

243-
implementation(libs.bundles.dbflow)
244-
implementation(libs.bundles.jackson)
245-
implementation(libs.kotlin.stdlib)
246-
implementation(libs.kotlin.reflect)
247-
implementation(libs.rxandroid)
248-
implementation(libs.rxjava)
249-
implementation(libs.rxkotlin)
250-
implementation(libs.rxrelay)
243+
ksp(libs.androidx.room.compiler)
244+
ksp(libs.squareup.moshi.codegen)
251245

252-
kapt(libs.dbflow.processor)
246+
testImplementation(libs.androidx.arch.core.testing)
247+
testImplementation(libs.androidx.room.testing)
248+
testImplementation(libs.androidx.test.core)
249+
testImplementation(libs.androidx.test.runner)
250+
testImplementation(libs.androidx.test.junit)
251+
testImplementation(libs.androidx.test.truth)
252+
testImplementation(libs.bundles.androidx.test.espresso)
253+
testImplementation(libs.androidx.paging.common.ktx)
254+
testImplementation(libs.androidx.paging.testing)
255+
testImplementation(libs.turbine)
256+
testImplementation(libs.truth)
257+
testImplementation(libs.koin.test)
258+
testImplementation(libs.kotlin.coroutines.test)
259+
testImplementation(libs.mockk)
260+
testImplementation(libs.robolectric)
253261

254262
debugImplementation(libs.squareup.leakcanary)
255263
debugImplementation(libs.androidx.fragment.testing)
@@ -336,7 +344,8 @@ tasks {
336344
}
337345
detekt.forEach {
338346
from(it.sarifReportFile) {
339-
rename { "detekt.sarif" }
347+
val name = it.sarifReportFile.get().asFile.nameWithoutExtension.prefixIfNot("detekt").toKebabCase()
348+
rename { "$name.sarif" }
340349
}
341350
}
342351
from(lintReportReleaseSarifOutput) {
@@ -365,7 +374,8 @@ tasks {
365374
doLast {
366375
if (!project.file("google-services.json").exists()) {
367376
throw GradleException(
368-
"You need a google-services.json file to run this project. Please refer to the CONTRIBUTING.md file for details."
377+
"You need a google-services.json file to run this project." +
378+
" Please refer to the CONTRIBUTING.md file for details."
369379
)
370380
}
371381
}
@@ -379,16 +389,23 @@ tasks {
379389
}
380390
}
381391

382-
kotlin {
383-
sourceSets.all {
384-
languageSettings.enableLanguageFeature("ExplicitBackingFields")
385-
}
386-
}
387-
388392
configurations.all {
389393
resolutionStrategy {
390394
force("com.google.code.findbugs:jsr305:3.0.2")
391395
force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${project.libs.versions.kotlin.get()}")
392396
force("org.jetbrains.kotlin:kotlin-reflect:${project.libs.versions.kotlin.get()}")
393397
}
394398
}
399+
400+
401+
fun String.toKebabCase(): String {
402+
return this.trim()
403+
.replace(Regex("([a-z])([A-Z])"), "$1-$2")
404+
.replace(Regex("[\\s_]+"), "-")
405+
.replace(Regex("[^a-zA-Z0-9-]"), "")
406+
.lowercase()
407+
}
408+
409+
fun String.prefixIfNot(prefix: String): String {
410+
return if (this.startsWith(prefix)) this else "$prefix-$this"
411+
}

app/proguard-rules.pro

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -46,94 +46,14 @@
4646
public static *** v(...);
4747
}
4848

49-
50-
# Proguard configuration for Jackson 2.x (fasterxml package instead of codehaus package)
51-
52-
-keep class com.fasterxml.jackson.databind.ObjectMapper {
53-
public <methods>;
54-
protected <methods>;
55-
}
56-
-keep class com.fasterxml.jackson.databind.ObjectWriter {
57-
public ** writeValueAsString(**);
58-
}
59-
60-
## Retrolambda specific rules ##
61-
6249
# as per official recommendation: https://github.com/evant/gradle-retrolambda#proguard
6350
-dontwarn java.lang.invoke.*
6451

65-
66-
# rxjava
67-
-keep class rx.schedulers.Schedulers {
68-
public static <methods>;
69-
}
70-
-keep class rx.schedulers.ImmediateScheduler {
71-
public <methods>;
72-
}
73-
-keep class rx.schedulers.TestScheduler {
74-
public <methods>;
75-
}
76-
-keep class rx.schedulers.Schedulers {
77-
public static ** test();
78-
}
79-
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
80-
long producerIndex;
81-
long consumerIndex;
82-
}
83-
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
84-
long producerNode;
85-
long consumerNode;
86-
}
87-
88-
# DBFlow
89-
-keep class * extends com.raizlabs.android.dbflow.config.DatabaseHolder { *; }
90-
-keep class com.raizlabs.android.dbflow.config.GeneratedDatabaseHolder
91-
-keep class * extends com.raizlabs.android.dbflow.config.BaseDatabaseDefinition { *; }
92-
9352
## OKHttp ##
9453

9554
-dontwarn com.squareup.okhttp.**
9655

97-
98-
# AppCompat v7
99-
-keep public class android.support.v7.widget.** { *; }
100-
-keep public class android.support.v7.internal.widget.** { *; }
101-
-keep public class android.support.v7.internal.view.menu.** { *; }
102-
103-
-keep public class * extends android.support.v4.view.ActionProvider {
104-
public <init>(android.content.Context);
105-
}
106-
107-
# Support Design
108-
-dontwarn android.support.design.**
109-
-keep class android.support.design.** { *; }
110-
-keep interface android.support.design.** { *; }
111-
-keep public class android.support.design.R$* { *; }
112-
113-
114-
-dontwarn com.fasterxml.jackson.databind.ext.**
115-
-dontwarn rx.internal.util.unsafe.**
116-
117-
### Jackson SERIALIZER SETTINGS
118-
-keepclassmembers class * {
119-
@com.fasterxml.jackson.annotation.* <fields>;
120-
@com.fasterxml.jackson.annotation.* <init>(...);
121-
}
122-
123-
# Jackson
124-
-dontskipnonpubliclibraryclassmembers
125-
-keepattributes *Annotation*,EnclosingMethod,Signature
126-
-keepnames class com.fasterxml.jackson.** { *; }
127-
-dontwarn com.fasterxml.jackson.databind.**
128-
129-
# Keep anything annotated with @JsonCreator
130-
-keepclassmembers public class * {
131-
@com.fasterxml.jackson.annotation.JsonCreator *;
132-
@com.fasterxml.jackson.annotation.JsonProperty *;
133-
}
134-
13556
-keep class kotlin.** { *; }
136-
-keep class com.raizlabs.android.dbflow.structure.Model { *; }
13757

13858
-keep class com.kelsos.mbrc.** {
13959
void set*(***);

0 commit comments

Comments
 (0)