diff --git a/build-logic/src/main/kotlin/elmslie.kotlin-jvm-lib.gradle.kts b/build-logic/src/main/kotlin/elmslie.kotlin-jvm-lib.gradle.kts deleted file mode 100644 index a6e69bbe..00000000 --- a/build-logic/src/main/kotlin/elmslie.kotlin-jvm-lib.gradle.kts +++ /dev/null @@ -1,45 +0,0 @@ -@file:Suppress("UnstableApiUsage") - -plugins { - id("org.jetbrains.kotlin.jvm") - id("org.jetbrains.dokka") - id("com.android.lint") - id("elmslie.base-lib") - id("elmslie.detekt") - id("elmslie.tests-convention") - `maven-publish` -} - -java { - withJavadocJar() - withSourcesJar() -} - -tasks.named("javadocJar") { from(tasks.named("dokkaJavadoc")) } - -val catalog = extensions.getByType().named("libs") - -dependencies { catalog.findLibrary("dokka-kotlinAsJavaPlugin").ifPresent { dokkaHtmlPlugin(it) } } - -lint { - checkDependencies = true - ignoreTestSources = true - - abortOnError = true - warningsAsErrors = true - - htmlReport = true - xmlReport = false -} - -val libraryGroup: String by project -val libraryVersion: String by project - -afterEvaluate { - publishing.publications.create("maven") { - from(components["java"]) - artifactId = project.name - groupId = libraryGroup - version = libraryVersion - } -} diff --git a/build-logic/src/main/kotlin/elmslie.kotlin-multiplatform-lib.gradle.kts b/build-logic/src/main/kotlin/elmslie.kotlin-multiplatform-lib.gradle.kts index a85a9692..6c6c26d1 100644 --- a/build-logic/src/main/kotlin/elmslie.kotlin-multiplatform-lib.gradle.kts +++ b/build-logic/src/main/kotlin/elmslie.kotlin-multiplatform-lib.gradle.kts @@ -1,22 +1,22 @@ -@file:Suppress("UnstableApiUsage") +import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { kotlin("multiplatform") - id("com.android.library") id("elmslie.detekt") } kotlin { applyDefaultHierarchyTemplate() - androidTarget { + jvm { compilations.all { - kotlinOptions { - jvmTarget = JvmTarget.toString() + compilerOptions.configure { + jvmTarget.set(JvmTarget.JVM_11) } } } - iosX64() iosArm64() -} + iosSimulatorArm64() + iosX64() +} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index b22d873a..e1358f9a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,4 @@ plugins { alias(libs.plugins.androidApplication) apply false - alias(libs.plugins.kotlinJvm) apply false + alias(libs.plugins.kotlinMultiplatform) apply false } \ No newline at end of file diff --git a/elmslie-core/build.gradle.kts b/elmslie-core/build.gradle.kts index a16e6bdd..36a476e5 100644 --- a/elmslie-core/build.gradle.kts +++ b/elmslie-core/build.gradle.kts @@ -1,9 +1,19 @@ plugins { - id("elmslie.kotlin-jvm-lib") - id("elmslie.tests-convention") + id("elmslie.kotlin-multiplatform-lib") } -dependencies { - implementation(libs.kotlinx.coroutinesCore) - testImplementation(libs.kotlinx.coroutinesTest) -} +kotlin { + sourceSets { + val commonMain by getting { + dependencies { + implementation(libs.kotlinx.coroutinesCore) + } + } + val commonTest by getting { + dependencies { + implementation(libs.kotlinx.coroutinesTest) + implementation(libs.kotlin.test) + } + } + } +} \ No newline at end of file diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/ElmScope.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/ElmScope.kt similarity index 93% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/ElmScope.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/ElmScope.kt index 0fe5e087..4efd69c8 100644 --- a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/ElmScope.kt +++ b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/ElmScope.kt @@ -6,7 +6,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.SupervisorJob import money.vivid.elmslie.core.config.ElmslieConfig -@SuppressWarnings("detekt.FunctionNaming") +@Suppress("detekt.FunctionNaming") fun ElmScope(name: String): CoroutineScope = CoroutineScope( context = diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/config/ElmslieConfig.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/config/ElmslieConfig.kt similarity index 93% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/config/ElmslieConfig.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/config/ElmslieConfig.kt index c1cb63d5..1393a172 100644 --- a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/config/ElmslieConfig.kt +++ b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/config/ElmslieConfig.kt @@ -2,14 +2,17 @@ package money.vivid.elmslie.core.config import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.IO import money.vivid.elmslie.core.logger.ElmslieLogConfiguration import money.vivid.elmslie.core.logger.ElmslieLogger import money.vivid.elmslie.core.logger.strategy.IgnoreLog import money.vivid.elmslie.core.store.StoreListener +import kotlin.concurrent.Volatile object ElmslieConfig { - @Volatile private lateinit var _logger: ElmslieLogger + @Volatile + private lateinit var _logger: ElmslieLogger @Volatile private lateinit var _ioDispatchers: CoroutineDispatcher diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/logger/ElmslieLogConfiguration.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/logger/ElmslieLogConfiguration.kt similarity index 92% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/logger/ElmslieLogConfiguration.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/logger/ElmslieLogConfiguration.kt index 7afa7096..c3220428 100644 --- a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/logger/ElmslieLogConfiguration.kt +++ b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/logger/ElmslieLogConfiguration.kt @@ -23,7 +23,7 @@ class ElmslieLogConfiguration { /** Apply the same logging strategy to all log levels */ fun always(strategy: LogStrategy) = apply { - LogSeverity.values().forEach { strategies[it] = strategy } + LogSeverity.entries.forEach { strategies[it] = strategy } } internal fun build() = ElmslieLogger(strategies) diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/logger/ElmslieLogger.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/logger/ElmslieLogger.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/logger/ElmslieLogger.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/logger/ElmslieLogger.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/logger/LogSeverity.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/logger/LogSeverity.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/logger/LogSeverity.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/logger/LogSeverity.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/logger/strategy/IgnoreLog.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/logger/strategy/IgnoreLog.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/logger/strategy/IgnoreLog.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/logger/strategy/IgnoreLog.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/logger/strategy/LogStrategy.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/logger/strategy/LogStrategy.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/logger/strategy/LogStrategy.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/logger/strategy/LogStrategy.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/Actor.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/Actor.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/Actor.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/Actor.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/EffectCachingElmStore.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/EffectCachingElmStore.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/EffectCachingElmStore.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/EffectCachingElmStore.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/ElmStore.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/ElmStore.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/ElmStore.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/ElmStore.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/NoOpActor.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/NoOpActor.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/NoOpActor.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/NoOpActor.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/NoOpReducer.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/NoOpReducer.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/NoOpReducer.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/NoOpReducer.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/Result.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/Result.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/Result.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/Result.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/ScreenReducer.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/ScreenReducer.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/ScreenReducer.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/ScreenReducer.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/StateReducer.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/StateReducer.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/StateReducer.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/StateReducer.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/Store.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/Store.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/Store.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/Store.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/StoreListener.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/StoreListener.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/StoreListener.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/StoreListener.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/dsl/OperationsBuilder.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/dsl/OperationsBuilder.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/dsl/OperationsBuilder.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/dsl/OperationsBuilder.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/dsl/ResultBuilder.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/dsl/ResultBuilder.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/store/dsl/ResultBuilder.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/store/dsl/ResultBuilder.kt diff --git a/elmslie-core/src/main/kotlin/money/vivid/elmslie/core/switcher/Switcher.kt b/elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/switcher/Switcher.kt similarity index 100% rename from elmslie-core/src/main/kotlin/money/vivid/elmslie/core/switcher/Switcher.kt rename to elmslie-core/src/commonMain/kotlin/money/vivid/elmslie/core/switcher/Switcher.kt diff --git a/elmslie-core/src/test/kotlin/money/vivid/elmslie/core/store/EffectCachingElmStoreTest.kt b/elmslie-core/src/commonTest/kotlin/money/vivid/elmslie/core/store/EffectCachingElmStoreTest.kt similarity index 100% rename from elmslie-core/src/test/kotlin/money/vivid/elmslie/core/store/EffectCachingElmStoreTest.kt rename to elmslie-core/src/commonTest/kotlin/money/vivid/elmslie/core/store/EffectCachingElmStoreTest.kt diff --git a/elmslie-core/src/test/kotlin/money/vivid/elmslie/core/store/ElmStoreTest.kt b/elmslie-core/src/commonTest/kotlin/money/vivid/elmslie/core/store/ElmStoreTest.kt similarity index 100% rename from elmslie-core/src/test/kotlin/money/vivid/elmslie/core/store/ElmStoreTest.kt rename to elmslie-core/src/commonTest/kotlin/money/vivid/elmslie/core/store/ElmStoreTest.kt diff --git a/elmslie-core/src/test/kotlin/money/vivid/elmslie/core/store/dsl/DslReducerTest.kt b/elmslie-core/src/commonTest/kotlin/money/vivid/elmslie/core/store/dsl/DslReducerTest.kt similarity index 100% rename from elmslie-core/src/test/kotlin/money/vivid/elmslie/core/store/dsl/DslReducerTest.kt rename to elmslie-core/src/commonTest/kotlin/money/vivid/elmslie/core/store/dsl/DslReducerTest.kt diff --git a/elmslie-core/src/test/kotlin/money/vivid/elmslie/core/store/dsl/Models.kt b/elmslie-core/src/commonTest/kotlin/money/vivid/elmslie/core/store/dsl/Models.kt similarity index 100% rename from elmslie-core/src/test/kotlin/money/vivid/elmslie/core/store/dsl/Models.kt rename to elmslie-core/src/commonTest/kotlin/money/vivid/elmslie/core/store/dsl/Models.kt diff --git a/elmslie-core/src/test/kotlin/money/vivid/elmslie/core/store/dsl/ScreenReducerTest.kt b/elmslie-core/src/commonTest/kotlin/money/vivid/elmslie/core/store/dsl/ScreenReducerTest.kt similarity index 100% rename from elmslie-core/src/test/kotlin/money/vivid/elmslie/core/store/dsl/ScreenReducerTest.kt rename to elmslie-core/src/commonTest/kotlin/money/vivid/elmslie/core/store/dsl/ScreenReducerTest.kt diff --git a/elmslie-core/src/test/kotlin/money/vivid/elmslie/core/testutil/model/StoreModels.kt b/elmslie-core/src/commonTest/kotlin/money/vivid/elmslie/core/testutil/model/StoreModels.kt similarity index 100% rename from elmslie-core/src/test/kotlin/money/vivid/elmslie/core/testutil/model/StoreModels.kt rename to elmslie-core/src/commonTest/kotlin/money/vivid/elmslie/core/testutil/model/StoreModels.kt diff --git a/gradle.properties b/gradle.properties index dcaa4733..03bda685 100644 --- a/gradle.properties +++ b/gradle.properties @@ -27,6 +27,11 @@ kapt.incremental.apt=true # https://kotlinlang.org/docs/reference/kapt.html?_ga=2.52861352.147014511.1570608228-996117368.1567680991#compile-avoidance-for-kapt-since-1320 kapt.include.compile.classpath=false # +# +# ----- Kotlin/Native features ----- +# +kotlin.native.distribution.downloadFromMaven=true +# # ----- AGP 4.0 build features ----- # # disable build config generation diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f7570ec3..0c1f9d04 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -24,5 +24,5 @@ kotlinx-coroutinesCore = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-co kotlinx-coroutinesTest = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } [plugins] -kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } androidApplication = { id = "com.android.application", version.ref = "agp" } \ No newline at end of file