Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Migrated core/logs Module to KMP #2735

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions androidApp/dependencies/demoDebugRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ dev.chrisbanes.snapper:snapper:0.2.2
io.github.mr0xf00:easycrop:0.1.1
io.insert-koin:koin-android:4.0.1-RC1
io.insert-koin:koin-androidx-compose:4.0.1-RC1
io.insert-koin:koin-annotations-jvm:1.4.0-RC4
io.insert-koin:koin-annotations:1.4.0-RC4
io.insert-koin:koin-bom:4.0.1-RC1
io.insert-koin:koin-compose-jvm:4.0.1-RC1
io.insert-koin:koin-compose-viewmodel-jvm:4.0.1-RC1
io.insert-koin:koin-compose-viewmodel:4.0.1-RC1
Expand All @@ -212,16 +215,16 @@ org.jetbrains.androidx.lifecycle:lifecycle-viewmodel:2.8.3
org.jetbrains.androidx.savedstate:savedstate:1.2.2
org.jetbrains.compose.animation:animation-core:1.7.0-rc01
org.jetbrains.compose.animation:animation:1.7.0-rc01
org.jetbrains.compose.annotation-internal:annotation:1.7.0-rc01
org.jetbrains.compose.collection-internal:collection:1.7.0-rc01
org.jetbrains.compose.annotation-internal:annotation:1.7.3
org.jetbrains.compose.collection-internal:collection:1.7.3
org.jetbrains.compose.foundation:foundation-layout:1.7.0-rc01
org.jetbrains.compose.foundation:foundation:1.7.0-rc01
org.jetbrains.compose.material3:material3:1.7.0-rc01
org.jetbrains.compose.material:material-icons-core:1.7.0-rc01
org.jetbrains.compose.material:material-ripple:1.7.0-rc01
org.jetbrains.compose.material:material:1.7.0-rc01
org.jetbrains.compose.runtime:runtime-saveable:1.7.0-rc01
org.jetbrains.compose.runtime:runtime:1.7.0-rc01
org.jetbrains.compose.runtime:runtime:1.7.3
org.jetbrains.compose.ui:ui-geometry:1.7.0-rc01
org.jetbrains.compose.ui:ui-graphics:1.7.0-rc01
org.jetbrains.compose.ui:ui-text:1.7.0-rc01
Expand Down
9 changes: 6 additions & 3 deletions androidApp/dependencies/demoReleaseRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ dev.chrisbanes.snapper:snapper:0.2.2
io.github.mr0xf00:easycrop:0.1.1
io.insert-koin:koin-android:4.0.1-RC1
io.insert-koin:koin-androidx-compose:4.0.1-RC1
io.insert-koin:koin-annotations-jvm:1.4.0-RC4
io.insert-koin:koin-annotations:1.4.0-RC4
io.insert-koin:koin-bom:4.0.1-RC1
io.insert-koin:koin-compose-jvm:4.0.1-RC1
io.insert-koin:koin-compose-viewmodel-jvm:4.0.1-RC1
io.insert-koin:koin-compose-viewmodel:4.0.1-RC1
Expand All @@ -207,16 +210,16 @@ org.jetbrains.androidx.lifecycle:lifecycle-viewmodel:2.8.3
org.jetbrains.androidx.savedstate:savedstate:1.2.2
org.jetbrains.compose.animation:animation-core:1.7.0-rc01
org.jetbrains.compose.animation:animation:1.7.0-rc01
org.jetbrains.compose.annotation-internal:annotation:1.7.0-rc01
org.jetbrains.compose.collection-internal:collection:1.7.0-rc01
org.jetbrains.compose.annotation-internal:annotation:1.7.3
org.jetbrains.compose.collection-internal:collection:1.7.3
org.jetbrains.compose.foundation:foundation-layout:1.7.0-rc01
org.jetbrains.compose.foundation:foundation:1.7.0-rc01
org.jetbrains.compose.material3:material3:1.7.0-rc01
org.jetbrains.compose.material:material-icons-core:1.7.0-rc01
org.jetbrains.compose.material:material-ripple:1.7.0-rc01
org.jetbrains.compose.material:material:1.7.0-rc01
org.jetbrains.compose.runtime:runtime-saveable:1.7.0-rc01
org.jetbrains.compose.runtime:runtime:1.7.0-rc01
org.jetbrains.compose.runtime:runtime:1.7.3
org.jetbrains.compose.ui:ui-geometry:1.7.0-rc01
org.jetbrains.compose.ui:ui-graphics:1.7.0-rc01
org.jetbrains.compose.ui:ui-text:1.7.0-rc01
Expand Down
9 changes: 6 additions & 3 deletions androidApp/dependencies/prodDebugRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ dev.chrisbanes.snapper:snapper:0.2.2
io.github.mr0xf00:easycrop:0.1.1
io.insert-koin:koin-android:4.0.1-RC1
io.insert-koin:koin-androidx-compose:4.0.1-RC1
io.insert-koin:koin-annotations-jvm:1.4.0-RC4
io.insert-koin:koin-annotations:1.4.0-RC4
io.insert-koin:koin-bom:4.0.1-RC1
io.insert-koin:koin-compose-jvm:4.0.1-RC1
io.insert-koin:koin-compose-viewmodel-jvm:4.0.1-RC1
io.insert-koin:koin-compose-viewmodel:4.0.1-RC1
Expand All @@ -212,16 +215,16 @@ org.jetbrains.androidx.lifecycle:lifecycle-viewmodel:2.8.3
org.jetbrains.androidx.savedstate:savedstate:1.2.2
org.jetbrains.compose.animation:animation-core:1.7.0-rc01
org.jetbrains.compose.animation:animation:1.7.0-rc01
org.jetbrains.compose.annotation-internal:annotation:1.7.0-rc01
org.jetbrains.compose.collection-internal:collection:1.7.0-rc01
org.jetbrains.compose.annotation-internal:annotation:1.7.3
org.jetbrains.compose.collection-internal:collection:1.7.3
org.jetbrains.compose.foundation:foundation-layout:1.7.0-rc01
org.jetbrains.compose.foundation:foundation:1.7.0-rc01
org.jetbrains.compose.material3:material3:1.7.0-rc01
org.jetbrains.compose.material:material-icons-core:1.7.0-rc01
org.jetbrains.compose.material:material-ripple:1.7.0-rc01
org.jetbrains.compose.material:material:1.7.0-rc01
org.jetbrains.compose.runtime:runtime-saveable:1.7.0-rc01
org.jetbrains.compose.runtime:runtime:1.7.0-rc01
org.jetbrains.compose.runtime:runtime:1.7.3
org.jetbrains.compose.ui:ui-geometry:1.7.0-rc01
org.jetbrains.compose.ui:ui-graphics:1.7.0-rc01
org.jetbrains.compose.ui:ui-text:1.7.0-rc01
Expand Down
9 changes: 6 additions & 3 deletions androidApp/dependencies/prodReleaseRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ dev.chrisbanes.snapper:snapper:0.2.2
io.github.mr0xf00:easycrop:0.1.1
io.insert-koin:koin-android:4.0.1-RC1
io.insert-koin:koin-androidx-compose:4.0.1-RC1
io.insert-koin:koin-annotations-jvm:1.4.0-RC4
io.insert-koin:koin-annotations:1.4.0-RC4
io.insert-koin:koin-bom:4.0.1-RC1
io.insert-koin:koin-compose-jvm:4.0.1-RC1
io.insert-koin:koin-compose-viewmodel-jvm:4.0.1-RC1
io.insert-koin:koin-compose-viewmodel:4.0.1-RC1
Expand All @@ -207,16 +210,16 @@ org.jetbrains.androidx.lifecycle:lifecycle-viewmodel:2.8.3
org.jetbrains.androidx.savedstate:savedstate:1.2.2
org.jetbrains.compose.animation:animation-core:1.7.0-rc01
org.jetbrains.compose.animation:animation:1.7.0-rc01
org.jetbrains.compose.annotation-internal:annotation:1.7.0-rc01
org.jetbrains.compose.collection-internal:collection:1.7.0-rc01
org.jetbrains.compose.annotation-internal:annotation:1.7.3
org.jetbrains.compose.collection-internal:collection:1.7.3
org.jetbrains.compose.foundation:foundation-layout:1.7.0-rc01
org.jetbrains.compose.foundation:foundation:1.7.0-rc01
org.jetbrains.compose.material3:material3:1.7.0-rc01
org.jetbrains.compose.material:material-icons-core:1.7.0-rc01
org.jetbrains.compose.material:material-ripple:1.7.0-rc01
org.jetbrains.compose.material:material:1.7.0-rc01
org.jetbrains.compose.runtime:runtime-saveable:1.7.0-rc01
org.jetbrains.compose.runtime:runtime:1.7.0-rc01
org.jetbrains.compose.runtime:runtime:1.7.3
org.jetbrains.compose.ui:ui-geometry:1.7.0-rc01
org.jetbrains.compose.ui:ui-graphics:1.7.0-rc01
org.jetbrains.compose.ui:ui-text:1.7.0-rc01
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import org.gradle.kotlin.dsl.assign
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinBaseExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

/**
* Configure base Kotlin with Android options
Expand All @@ -35,7 +34,7 @@ internal fun Project.configureKotlinAndroid(
}
}

configureKotlin<KotlinAndroidProjectExtension>()
configureKotlin()

dependencies {
add("coreLibraryDesugaring", libs.findLibrary("android.desugarJdkLibs").get())
Expand All @@ -53,30 +52,26 @@ internal fun Project.configureKotlinJvm() {
targetCompatibility = JavaVersion.VERSION_17
}

configureKotlin<KotlinJvmProjectExtension>()
configureKotlin()
}

/**
* Configure base Kotlin options
*/
private inline fun <reified T : KotlinBaseExtension> Project.configureKotlin() = configure<T> {
// Treat all Kotlin warnings as errors (disabled by default)
// Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties
val warningsAsErrors: String? by project
when (this) {
is KotlinAndroidProjectExtension -> compilerOptions
is KotlinJvmProjectExtension -> compilerOptions
else -> TODO("Unsupported project extension $this ${T::class}")
}.apply {
jvmTarget = JvmTarget.JVM_17
allWarningsAsErrors = warningsAsErrors.toBoolean()
freeCompilerArgs.add(
// Enable experimental coroutines APIs, including Flow
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
)
freeCompilerArgs.add(
"-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
)
private fun Project.configureKotlin() {
// Use withType to workaround https://youtrack.jetbrains.com/issue/KT-55947
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
// Set JVM target to 17
jvmTarget = JvmTarget.JVM_17
// Treat all Kotlin warnings as errors (disabled by default)
// Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties
val warningsAsErrors: String? by project
allWarningsAsErrors = warningsAsErrors.toBoolean()
freeCompilerArgs.add(
// Enable experimental coroutines APIs, including Flow
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
)
}
}
}

}
27 changes: 14 additions & 13 deletions core/logs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
*/
plugins {
alias(libs.plugins.mifos.android.library)
alias(libs.plugins.mifos.android.library.compose)
alias(libs.plugins.mifos.android.hilt)
alias(libs.plugins.mifos.kmp.library)
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.compose.compiler)

}

android {
namespace = "org.mifos.mobile.core.logs"
}


dependencies {
implementation(libs.androidx.compose.runtime)

implementation(platform(libs.firebase.bom))
implementation(libs.firebase.analytics)

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.androidx.test.espresso.core)
kotlin {
sourceSets {
commonMain.dependencies {
implementation(libs.jb.composeRuntime)
}
androidMain.dependencies {
implementation(project.dependencies.platform(libs.firebase.bom))
implementation(libs.firebase.analytics)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
*/
package org.mifos.mobile.core.logs.di

import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.ktx.Firebase
import org.koin.dsl.module
import org.mifos.mobile.core.logs.AnalyticsHelper

val AnalyticsModule = module {

single {
Firebase.analytics
}
single<AnalyticsHelper> {
FirebaseAnalyticsHelper(firebaseAnalytics = get())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.analytics.logEvent
import org.mifos.mobile.core.logs.AnalyticsEvent
import org.mifos.mobile.core.logs.AnalyticsHelper
import javax.inject.Inject

/**
* Implementation of `AnalyticsHelper` which logs events to a Firebase backend.
*/
internal class FirebaseAnalyticsHelper @Inject constructor(
internal class FirebaseAnalyticsHelper(
private val firebaseAnalytics: FirebaseAnalytics,
) : AnalyticsHelper {
override fun logEvent(event: AnalyticsEvent) {
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion core/testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {
api(libs.bundles.androidx.compose.ui.test)
api(libs.kotlinx.coroutines.test)
api(projects.core.data)
api(projects.core.logs)
// api(projects.core.logs)
api(projects.core.model)
api(libs.turbine)
api(libs.mockito.core)
Expand Down
Loading