diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b609dff --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +# Disable ktlint on generated source code, see +# https://github.com/JLLeitschuh/ktlint-gradle/issues/746 +[**/build/generated/**] +ktlint = disabled + +[*.{kt,kts}] +insert_final_newline = true +max_line_length = 250 +ij_kotlin_imports_layout = *, ^ +ij_kotlin_allow_trailing_comma = true +ij_kotlin_allow_trailing_comma_on_call_site = true +ktlint_compose_preview-public-check = disabled +ktlint_function_naming_ignore_when_annotated_with = Composable \ No newline at end of file diff --git a/.gitignore b/.gitignore index edd7223..b6b351d 100644 --- a/.gitignore +++ b/.gitignore @@ -42,14 +42,14 @@ # When using Gradle or Maven with auto-import, you should exclude module files, # since they will be recreated, and may cause churn. Uncomment if using # auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr + .idea/artifacts + .idea/compiler.xml + .idea/jarRepositories.xml + .idea/modules.xml + .idea/*.iml + .idea/modules + *.iml + *.ipr # CMake cmake-build-*/ @@ -187,4 +187,6 @@ gradle-app.setting .DS_Store -local.properties \ No newline at end of file +local.properties + +.kotlin \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3f0caa8..33f7c35 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,16 +7,16 @@ koin-android = "3.5.6" koin-compose = "3.5.6" kotlin = "2.0.0" coroutines = "1.8.1" -kotest = "5.9.0" -material = "1.7.0" -mvi = "1.7.0" +kotest = "5.9.1" +material = "1.7.1" +mvi = "1.8.2-alpha01" mvi-compose = "0.0.3" activity = "1.9.2" -lifecycle = "2.8.5" +androidx-lifecycle = "2.8.0" ktlint-gradle = "12.1.0" android-library = "8.3.2" maven-publish = "0.29.0" -ui = "1.7.0" +ui = "1.7.1" mockk = "1.13.11" mvi-kotest = "0.0.2" @@ -35,7 +35,7 @@ mvi = { module = "com.adidas.mvi:mvi", version.ref = "mvi" } mviCompose = { module = "com.adidas.mvi:mvi-compose", version.ref = "mvi-compose" } mviKotest = { module = "com.adidas.mvi:mvi-kotest", version.ref = "mvi-kotest" } activityCompose = { module = "androidx.activity:activity-compose", version.ref = "activity" } -lifecycleRuntimeCompose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycle" } +androidx-lifecycle-runtime-compose = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidx-lifecycle" } material = { module = "androidx.compose.material:material", version.ref = "material" } ui = { module = "androidx.compose.ui:ui", version.ref = "ui" } koinCore = { module = "io.insert-koin:koin-core", version.ref = "koin" } diff --git a/mvi-compose/build.gradle.kts b/mvi-compose/build.gradle.kts index 485b9f9..693497a 100644 --- a/mvi-compose/build.gradle.kts +++ b/mvi-compose/build.gradle.kts @@ -1,12 +1,56 @@ +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jlleitschuh.gradle.ktlint.KtlintExtension + plugins { - alias(libs.plugins.android.library) - alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlinMultiplatform) + alias(libs.plugins.ktlint) alias(libs.plugins.mavenPublish) alias(libs.plugins.compose.compiler) + alias(libs.plugins.android.library) } kotlin { explicitApi() + + jvm() + androidTarget { + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) + } + } + + listOf( + iosX64(), + iosArm64(), + iosSimulatorArm64(), + macosX64(), + macosArm64(), + watchosArm32(), + watchosArm64(), + watchosSimulatorArm64(), + watchosX64(), + tvosArm64(), + tvosSimulatorArm64(), + tvosX64(), + ).forEach { + it.binaries.framework { + baseName = "mvi-compose" + isStatic = true + } + } + + sourceSets { + commonMain.dependencies { + implementation(libs.mvi) + implementation(libs.androidx.lifecycle.runtime.compose) + } + + androidMain.dependencies { + implementation(libs.activityCompose) + } + } } android { @@ -25,16 +69,13 @@ android { isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" + "proguard-rules.pro", ) } } compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } buildFeatures { @@ -42,10 +83,6 @@ android { } } -dependencies { - - implementation(platform(libs.kotlinBom)) - implementation(libs.mvi) - implementation(libs.activityCompose) - implementation(libs.lifecycleRuntimeCompose) +configure { + version.set(libs.versions.ktlint.lib.get()) } diff --git a/mvi-compose/gradle.properties b/mvi-compose/gradle.properties index 548121e..d9f4433 100644 --- a/mvi-compose/gradle.properties +++ b/mvi-compose/gradle.properties @@ -1,7 +1,7 @@ POM_ARTIFACT_ID=mvi-compose GROUP=com.adidas.mvi VERSION_CODE=1 -VERSION_NAME=0.0.3 +VERSION_NAME=0.1.0 POM_NAME=Adidas MVI Compose POM_DESCRIPTION=Adidas MVI Compose POM_PACKAGING=aar diff --git a/mvi-compose/src/main/kotlin/com/adidas/mvi/compose/MviScreen.kt b/mvi-compose/src/androidMain/kotlin/com/adidas/mvi/compose/MviScreen.kt similarity index 100% rename from mvi-compose/src/main/kotlin/com/adidas/mvi/compose/MviScreen.kt rename to mvi-compose/src/androidMain/kotlin/com/adidas/mvi/compose/MviScreen.kt diff --git a/mvi-compose/src/main/kotlin/com/adidas/mvi/compose/MviContainer.kt b/mvi-compose/src/commonMain/kotlin/com/adidas/mvi/compose/MviContainer.kt similarity index 100% rename from mvi-compose/src/main/kotlin/com/adidas/mvi/compose/MviContainer.kt rename to mvi-compose/src/commonMain/kotlin/com/adidas/mvi/compose/MviContainer.kt diff --git a/mvi-compose/src/main/AndroidManifest.xml b/mvi-compose/src/main/AndroidManifest.xml deleted file mode 100644 index 568741e..0000000 --- a/mvi-compose/src/main/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/mvi-sample/build.gradle.kts b/mvi-sample/build.gradle.kts index be9e238..36c370f 100644 --- a/mvi-sample/build.gradle.kts +++ b/mvi-sample/build.gradle.kts @@ -79,7 +79,7 @@ dependencies { implementation(libs.material) implementation(libs.mvi) - implementation(libs.mviCompose) + implementation(project(":mvi-compose")) implementation(libs.koinCore) implementation(libs.koinAndroid) @@ -90,4 +90,4 @@ dependencies { testImplementation(libs.kotestRunner) testImplementation(libs.mockk) testImplementation(libs.mviKotest) -} \ No newline at end of file +} diff --git a/mvi/src/commonMain/kotlin/com/adidas/mvi/Reducer.kt b/mvi/src/commonMain/kotlin/com/adidas/mvi/Reducer.kt index afd2efd..1a79e7f 100644 --- a/mvi/src/commonMain/kotlin/com/adidas/mvi/Reducer.kt +++ b/mvi/src/commonMain/kotlin/com/adidas/mvi/Reducer.kt @@ -1,6 +1,8 @@ package com.adidas.mvi import com.adidas.mvi.transform.StateTransform +import kotlin.coroutines.coroutineContext +import kotlin.reflect.KClass import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -13,8 +15,6 @@ import kotlinx.coroutines.flow.scan import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.isActive import kotlinx.coroutines.launch -import kotlin.coroutines.coroutineContext -import kotlin.reflect.KClass public class Reducer( private val coroutineScope: CoroutineScope, diff --git a/mvi/src/commonMain/kotlin/com/adidas/mvi/requirements/ReduceExtensions.kt b/mvi/src/commonMain/kotlin/com/adidas/mvi/requirements/ReduceExtensions.kt index b2e1505..3604b1f 100644 --- a/mvi/src/commonMain/kotlin/com/adidas/mvi/requirements/ReduceExtensions.kt +++ b/mvi/src/commonMain/kotlin/com/adidas/mvi/requirements/ReduceExtensions.kt @@ -9,9 +9,7 @@ public inline fun requ return StateReduceRequirement(TRequiredState::class, reduce).reduce(state) } -public inline fun requireState( - noinline reduce: (TRequiredState) -> TState, -): ReduceRequirement { +public inline fun requireState(noinline reduce: (TRequiredState) -> TState): ReduceRequirement { return StateReduceRequirement(TRequiredState::class, reduce) } diff --git a/mvi/src/jvmTest/kotlin/com/adidas/mvi/reducer/ReducerTests.kt b/mvi/src/jvmTest/kotlin/com/adidas/mvi/reducer/ReducerTests.kt index 9096dbf..416766f 100644 --- a/mvi/src/jvmTest/kotlin/com/adidas/mvi/reducer/ReducerTests.kt +++ b/mvi/src/jvmTest/kotlin/com/adidas/mvi/reducer/ReducerTests.kt @@ -189,9 +189,7 @@ internal class ReducerTests : BehaviorSpec({ } }) -private fun createIntentExecutorContainer( - executedIntents: MutableList = mutableListOf(), -): (TestIntent) -> Flow>> = +private fun createIntentExecutorContainer(executedIntents: MutableList = mutableListOf()): (TestIntent) -> Flow>> = { executedIntents.add(it) flowOf(TestTransform.Transform1) diff --git a/mvi/src/jvmTest/kotlin/com/adidas/mvi/sideeffects/SideEffectsTest.kt b/mvi/src/jvmTest/kotlin/com/adidas/mvi/sideeffects/SideEffectsTest.kt index 3a0ea38..3b5f813 100644 --- a/mvi/src/jvmTest/kotlin/com/adidas/mvi/sideeffects/SideEffectsTest.kt +++ b/mvi/src/jvmTest/kotlin/com/adidas/mvi/sideeffects/SideEffectsTest.kt @@ -5,12 +5,12 @@ import io.kotest.matchers.booleans.shouldBeFalse import io.kotest.matchers.collections.shouldBeEmpty import io.kotest.matchers.collections.shouldContain import io.kotest.matchers.collections.shouldContainInOrder -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import kotlinx.coroutines.sync.Semaphore import kotlin.time.DurationUnit import kotlin.time.ExperimentalTime import kotlin.time.toDuration +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.sync.Semaphore @ExperimentalTime internal class SideEffectsTest : BehaviorSpec({