Skip to content

Commit 2c813a6

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 2c813a6

File tree

485 files changed

+10528
-11257
lines changed

Some content is hidden

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

485 files changed

+10528
-11257
lines changed

app/build.gradle.kts

Lines changed: 58 additions & 45 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
@@ -73,15 +72,15 @@ fun buildTime(): String {
7372
return df.format(Date())
7473
}
7574

76-
fun gitHash(): String {
77-
return "git -C $rootDir rev-parse --short HEAD".runCommand()
78-
}
75+
fun gitHash(): String = "git -C $rootDir rev-parse --short HEAD".runCommand()
7976

80-
val version = "1.6.0-alpha.1"
81-
val code = 125
77+
val appVersionName = "1.6.0-alpha.1"
78+
val appVersionCode = 125
79+
val minSDKVersion = 23
80+
val compileSDKVersion = 35
8281

8382
android {
84-
compileSdk = 35
83+
compileSdk = compileSDKVersion
8584
namespace = "com.kelsos.mbrc"
8685

8786
buildFeatures {
@@ -90,14 +89,18 @@ android {
9089

9190
defaultConfig {
9291
applicationId = "com.kelsos.mbrc"
93-
minSdk = 23
94-
targetSdk = 35
95-
versionCode = code
96-
versionName = version
92+
minSdk = minSDKVersion
93+
targetSdk = compileSDKVersion
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,51 +215,49 @@ 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)
223221
implementation(libs.androidx.constraintlayout)
224222
implementation(libs.androidx.datastore)
225223
implementation(libs.androidx.fragment.ktx)
226-
implementation(libs.androidx.media)
224+
implementation(libs.bundles.androidx.media3)
227225
implementation(libs.androidx.paging.runtime.ktx)
228226
implementation(libs.androidx.preference.ktx)
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) {
@@ -352,8 +361,6 @@ tasks {
352361
}
353362
}
354363

355-
356-
357364
val copyDummyGoogleServicesJson by registering(GenerateGoogleServicesJson::class) {
358365
onlyIf { System.getenv("CI") == "true" }
359366
configuration = dummyGoogleServicesJson
@@ -365,7 +372,8 @@ tasks {
365372
doLast {
366373
if (!project.file("google-services.json").exists()) {
367374
throw GradleException(
368-
"You need a google-services.json file to run this project. Please refer to the CONTRIBUTING.md file for details."
375+
"You need a google-services.json file to run this project." +
376+
" Please refer to the CONTRIBUTING.md file for details."
369377
)
370378
}
371379
}
@@ -379,16 +387,21 @@ tasks {
379387
}
380388
}
381389

382-
kotlin {
383-
sourceSets.all {
384-
languageSettings.enableLanguageFeature("ExplicitBackingFields")
385-
}
386-
}
387-
388390
configurations.all {
389391
resolutionStrategy {
390392
force("com.google.code.findbugs:jsr305:3.0.2")
391393
force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${project.libs.versions.kotlin.get()}")
392394
force("org.jetbrains.kotlin:kotlin-reflect:${project.libs.versions.kotlin.get()}")
393395
}
394396
}
397+
398+
399+
fun String.toKebabCase(): String {
400+
return this.trim()
401+
.replace(Regex("([a-z])([A-Z])"), "$1-$2")
402+
.replace(Regex("[\\s_]+"), "-")
403+
.replace(Regex("[^a-zA-Z0-9-]"), "")
404+
.lowercase()
405+
}
406+
407+
fun String.prefixIfNot(prefix: String): String = if (this.startsWith(prefix)) this else "$prefix-$this"

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)