From 1396c6f47e75a48680bcfb9a44dec3dcfcea382b Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 7 Oct 2024 21:35:08 +0200 Subject: [PATCH] fix: cleanup and resolve app module startup crash - Assures that `AndroidScopeCompoent` is implemented in lifecycle drivers --- .../anitrend/support/markdown/core/AbstractActivity.kt | 3 ++- .../anitrend/support/markdown/core/AbstractFragment.kt | 3 ++- buildSrc/build.gradle.kts | 3 --- .../support/markdown/buildSrc/plugin/CorePlugin.kt | 10 ++++------ 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/src/main/kotlin/co/anitrend/support/markdown/core/AbstractActivity.kt b/app/src/main/kotlin/co/anitrend/support/markdown/core/AbstractActivity.kt index ce89d1b..cbd40b2 100644 --- a/app/src/main/kotlin/co/anitrend/support/markdown/core/AbstractActivity.kt +++ b/app/src/main/kotlin/co/anitrend/support/markdown/core/AbstractActivity.kt @@ -5,12 +5,13 @@ import androidx.appcompat.app.AppCompatActivity import androidx.viewbinding.ViewBinding import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.MainScope +import org.koin.android.scope.AndroidScopeComponent import org.koin.androidx.fragment.android.setupKoinFragmentFactory import org.koin.androidx.scope.activityRetainedScope import org.koin.core.component.KoinScopeComponent abstract class AbstractActivity : AppCompatActivity(), - CoroutineScope by MainScope(), KoinScopeComponent { + CoroutineScope by MainScope(), AndroidScopeComponent { override val scope by activityRetainedScope() diff --git a/app/src/main/kotlin/co/anitrend/support/markdown/core/AbstractFragment.kt b/app/src/main/kotlin/co/anitrend/support/markdown/core/AbstractFragment.kt index 48a0e9b..9e1bbd9 100644 --- a/app/src/main/kotlin/co/anitrend/support/markdown/core/AbstractFragment.kt +++ b/app/src/main/kotlin/co/anitrend/support/markdown/core/AbstractFragment.kt @@ -10,11 +10,12 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.MainScope import kotlinx.coroutines.launch +import org.koin.android.scope.AndroidScopeComponent import org.koin.androidx.scope.fragmentScope import org.koin.core.component.KoinScopeComponent abstract class AbstractFragment(@LayoutRes layoutId: Int) : Fragment(layoutId), - CoroutineScope by MainScope(), KoinScopeComponent { + CoroutineScope by MainScope(), AndroidScopeComponent { override val scope by fragmentScope() diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 2197600..ccb49ab 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,6 +1,3 @@ -import org.gradle.accessors.dm.LibrariesForLibs -import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile - plugins { `kotlin-dsl` `maven-publish` diff --git a/buildSrc/src/main/java/co/anitrend/support/markdown/buildSrc/plugin/CorePlugin.kt b/buildSrc/src/main/java/co/anitrend/support/markdown/buildSrc/plugin/CorePlugin.kt index 4641d62..30022b9 100644 --- a/buildSrc/src/main/java/co/anitrend/support/markdown/buildSrc/plugin/CorePlugin.kt +++ b/buildSrc/src/main/java/co/anitrend/support/markdown/buildSrc/plugin/CorePlugin.kt @@ -13,9 +13,8 @@ open class CorePlugin : Plugin { * Inspecting available extensions */ private fun Project.availableExtensions() { - val extensionSchema = project.extensions.extensionsSchema - extensionSchema.forEach { - println("Available extension for module ${project.path}: ${it.name} -> ${it.publicType}") + extensions.extensionsSchema.forEach { + logger.lifecycle("Available extension for module ${project.path}: ${it.name} -> ${it.publicType}") } } @@ -23,9 +22,8 @@ open class CorePlugin : Plugin { * Inspecting available components */ private fun Project.availableComponents() { - val collectionSchema = project.components.asMap - collectionSchema.forEach { - println("Available component for module ${project.path}: ${it.key} -> ${it.value}") + components.forEach { + logger.lifecycle("Available component for module ${project.path}: ${it.name} -> ${it}") } }