From 5f9ed107fbfb8623035699c92f9beb1393a25d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Petu=C5=A1ka?= Date: Mon, 27 Jul 2020 19:57:41 +0300 Subject: [PATCH 01/19] Kotlin 1.4.0-rc --- build.gradle | 1 + buildSrc/src/main/kotlin/Versions.kt | 6 +++--- gradle.properties | 4 +++- redux-kotlin/build.gradle | 6 +++--- settings.gradle | 2 -- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index f1e6693..567a727 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ buildscript { repositories { google() + mavenCentral() maven { url 'https://dl.bintray.com/jetbrains/kotlin-native-dependencies' } maven { url "https://plugins.gradle.org/m2/" } maven { url "https://oss.sonatype.org/content/repositories/snapshots" } diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 1cfd377..e5fd87b 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -34,7 +34,7 @@ object Versions { const val dokka_gradle_plugin: String = "0.9.17" // available: "0.9.18" - const val org_jetbrains_kotlin: String = "1.3.72" + const val org_jetbrains_kotlin: String = "1.4.0-rc" const val spek: String = "2.1.0-alpha.0.11+d97ef33" // available: "2.1.0-alpha.0.24+0fdeb6e" @@ -43,9 +43,9 @@ object Versions { const val recycler_view = "1.0.0" - const val coroutines = "1.3.7" + const val coroutines = "1.3.8-1.4.0-rc" - const val atomicFu = "0.14.2" + const val atomicFu = "0.14.3-1.4.0-rc" /** * diff --git a/gradle.properties b/gradle.properties index 3727253..320d3a0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,9 +19,11 @@ android.useAndroidX=true android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official +kotlin.native.ignoreDisabledTargets=true +kotlin.mpp.enableGranularSourceSetsMetadata=true GROUP=org.reduxkotlin -VERSION_NAME=0.5.3 +VERSION_NAME=0.5.3-1.4.0-rc POM_ARTIFACT_ID=reduxkotlin POM_DESCRIPTION=Redux implementation for Kotlin. Mulitiplatform supported. diff --git a/redux-kotlin/build.gradle b/redux-kotlin/build.gradle index 7b9a7b0..b66dd2c 100644 --- a/redux-kotlin/build.gradle +++ b/redux-kotlin/build.gradle @@ -32,7 +32,7 @@ kotlin { commonMain { dependencies { - implementation kotlin("stdlib-common") +// api kotlin("stdlib-common") } } commonTest { @@ -49,7 +49,7 @@ kotlin { jvmMain { kotlin.srcDir('src/jvmMain/kotlin') dependencies { - implementation kotlin("stdlib") +// api kotlin("stdlib") } } jvmTest { @@ -69,7 +69,7 @@ kotlin { jsMain { kotlin.srcDir('src/jsMain/kotlin') dependencies { - implementation kotlin("stdlib-js") + api kotlin("stdlib-js") } compileKotlinJs { kotlinOptions.metaInfo = true diff --git a/settings.gradle b/settings.gradle index e37467e..6180d3d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -18,5 +18,3 @@ include( ) rootProject.name = 'Redux-Kotlin' - -enableFeaturePreview('GRADLE_METADATA') From 5569c4aaf4f6062c81fbab5c869be7a85168c77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Petu=C5=A1ka?= Date: Mon, 27 Jul 2020 21:18:01 +0300 Subject: [PATCH 02/19] Kotlin 1.4.0-rc --- build.gradle | 1 + buildSrc/src/main/kotlin/Libs.kt | 4 ++-- examples/counter/common/build.gradle | 2 +- redux-kotlin-threadsafe/build.gradle | 3 --- redux-kotlin/build.gradle | 4 ---- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 567a727..3a7fbcf 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,7 @@ plugins { allprojects { repositories { + maven { url "https://kotlin.bintray.com/kotlinx" } google() jcenter() maven { url "https://oss.sonatype.org/content/repositories/snapshots" } diff --git a/buildSrc/src/main/kotlin/Libs.kt b/buildSrc/src/main/kotlin/Libs.kt index 14bdb1a..d9c89d0 100644 --- a/buildSrc/src/main/kotlin/Libs.kt +++ b/buildSrc/src/main/kotlin/Libs.kt @@ -181,10 +181,10 @@ object Libs { const val spek_runner_junit5: String = "org.spekframework.spek2:spek-runner-junit5:" + Versions.spek - const val kotlin_coroutines: String = "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:" + + const val kotlin_coroutines: String = "org.jetbrains.kotlinx:kotlinx-coroutines-core:" + Versions.coroutines - const val kotlin_coroutines_jvm: String = "org.jetbrains.kotlinx:kotlinx-coroutines-core:" + + const val kotlin_coroutines_jvm: String = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:" + Versions.coroutines const val kotlin_coroutines_test: String = "org.jetbrains.kotlinx:kotlinx-coroutines-test:" + diff --git a/examples/counter/common/build.gradle b/examples/counter/common/build.gradle index 35468b1..2f857f7 100644 --- a/examples/counter/common/build.gradle +++ b/examples/counter/common/build.gradle @@ -7,7 +7,7 @@ apply plugin: 'kotlin-multiplatform' kotlin { jvm() - js() { + js { [compileKotlinJs, compileTestKotlinJs].each { configuration -> configuration.kotlinOptions { moduleKind = 'umd' diff --git a/redux-kotlin-threadsafe/build.gradle b/redux-kotlin-threadsafe/build.gradle index 91faaae..96f60b3 100644 --- a/redux-kotlin-threadsafe/build.gradle +++ b/redux-kotlin-threadsafe/build.gradle @@ -34,7 +34,6 @@ kotlin { commonMain { dependencies { - implementation kotlin("stdlib-common") api project(":redux-kotlin") } } @@ -52,7 +51,6 @@ kotlin { jvmMain { dependencies { - implementation kotlin("stdlib") } } jvmTest { @@ -72,7 +70,6 @@ kotlin { } jsMain { dependencies { - implementation kotlin("stdlib-js") } compileKotlinJs { kotlinOptions.metaInfo = true diff --git a/redux-kotlin/build.gradle b/redux-kotlin/build.gradle index b66dd2c..7a2f02e 100644 --- a/redux-kotlin/build.gradle +++ b/redux-kotlin/build.gradle @@ -32,7 +32,6 @@ kotlin { commonMain { dependencies { -// api kotlin("stdlib-common") } } commonTest { @@ -49,7 +48,6 @@ kotlin { jvmMain { kotlin.srcDir('src/jvmMain/kotlin') dependencies { -// api kotlin("stdlib") } } jvmTest { @@ -69,7 +67,6 @@ kotlin { jsMain { kotlin.srcDir('src/jsMain/kotlin') dependencies { - api kotlin("stdlib-js") } compileKotlinJs { kotlinOptions.metaInfo = true @@ -83,7 +80,6 @@ kotlin { jsTest { dependencies { implementation kotlin("test-js") - implementation kotlin("stdlib-js") } } winMain { From 94e962009320b5fc6914df36bc112528914b195f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Petu=C5=A1ka?= Date: Mon, 27 Jul 2020 21:24:39 +0300 Subject: [PATCH 03/19] Kotlin 1.4.0-rc --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 320d3a0..7456d61 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,7 +23,7 @@ kotlin.native.ignoreDisabledTargets=true kotlin.mpp.enableGranularSourceSetsMetadata=true GROUP=org.reduxkotlin -VERSION_NAME=0.5.3-1.4.0-rc +VERSION_NAME=0.5.4-SNAPSHOT POM_ARTIFACT_ID=reduxkotlin POM_DESCRIPTION=Redux implementation for Kotlin. Mulitiplatform supported. From 69115333d5d5ca207acb50e243add85d6bc9e5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Petu=C5=A1ka?= Date: Mon, 27 Jul 2020 22:56:40 +0300 Subject: [PATCH 04/19] Kotlin 1.4.0-rc further cleanup --- examples/counter/common/build.gradle | 96 --------------- examples/counter/common/build.gradle.kts | 74 ++++++++++++ gradle.properties | 2 +- redux-kotlin-threadsafe/build.gradle | 128 -------------------- redux-kotlin-threadsafe/build.gradle.kts | 103 ++++++++++++++++ redux-kotlin/build.gradle | 142 ----------------------- redux-kotlin/build.gradle.kts | 113 ++++++++++++++++++ redux-kotlin/proguard-rules.pro | 2 +- 8 files changed, 292 insertions(+), 368 deletions(-) delete mode 100644 examples/counter/common/build.gradle create mode 100644 examples/counter/common/build.gradle.kts delete mode 100644 redux-kotlin-threadsafe/build.gradle create mode 100644 redux-kotlin-threadsafe/build.gradle.kts delete mode 100644 redux-kotlin/build.gradle create mode 100644 redux-kotlin/build.gradle.kts diff --git a/examples/counter/common/build.gradle b/examples/counter/common/build.gradle deleted file mode 100644 index 2f857f7..0000000 --- a/examples/counter/common/build.gradle +++ /dev/null @@ -1,96 +0,0 @@ -repositories { - maven { url "https://dl.bintray.com/spekframework/spek-dev" } -} -apply plugin: 'java' -apply plugin: 'kotlin-multiplatform' - - -kotlin { - jvm() - js { - [compileKotlinJs, compileTestKotlinJs].each { configuration -> - configuration.kotlinOptions { - moduleKind = 'umd' - sourceMap = true - metaInfo = true - } - } - } - - - iosArm64("ios") - iosX64("iosSim") - macosX64("macos") - mingwX64("win") - wasm32("wasm") - linuxArm32Hfp("linArm32") - linuxMips32("linMips32") - linuxMipsel32("linMipsel32") - linuxX64("lin64") - - sourceSets { - commonMain { - dependencies { - implementation kotlin("stdlib-common") - implementation project(":redux-kotlin") - } - } - commonTest { - kotlin.srcDir('src/test/kotlin') - dependencies { - implementation kotlin("test-common") - implementation kotlin("test-annotations-common") - implementation "org.spekframework.spek2:spek-dsl-metadata:$Versions.spek" - implementation "ch.tutteli.atrium:atrium-cc-en_GB-robstoll-common:$Versions.atrium" - implementation "io.mockk:mockk-common:$Versions.mockk" - } - } - - jvmMain { - kotlin.srcDir('src/jvmMain/kotlin') - dependencies { - implementation kotlin("stdlib") - } - } - jvmTest { - dependencies { - implementation kotlin("test") - implementation kotlin("test-junit") - implementation "org.spekframework.spek2:spek-dsl-jvm:$Versions.spek" - implementation "ch.tutteli.atrium:atrium-cc-en_GB-robstoll:$Versions.atrium" - implementation "io.mockk:mockk:$Versions.mockk" - - runtimeOnly "org.spekframework.spek2:spek-runner-junit5:$Versions.spek" - runtimeOnly 'org.jetbrains.kotlin:kotlin-reflect' - } - } - jsMain { - kotlin.srcDir('src/jsMain/kotlin') - dependencies { - implementation kotlin("stdlib-js") - } - compileKotlinJs { - kotlinOptions.metaInfo = true - kotlinOptions.sourceMap = true - kotlinOptions.verbose = true - kotlinOptions.main = "call" - kotlinOptions.moduleKind = "umd" - } - } - jsTest { - dependencies { - implementation kotlin("test-js") - implementation kotlin("stdlib-js") - } - } - - iosSimMain.dependsOn iosMain - iosSimTest.dependsOn iosTest - } -} - -jvmTest { - useJUnitPlatform { - includeEngines 'spek2' - } -} diff --git a/examples/counter/common/build.gradle.kts b/examples/counter/common/build.gradle.kts new file mode 100644 index 0000000..14e823e --- /dev/null +++ b/examples/counter/common/build.gradle.kts @@ -0,0 +1,74 @@ +plugins { + java + kotlin("multiplatform") +} + +repositories { + maven("https://dl.bintray.com/spekframework/spek-dev") +} + +kotlin { + jvm() + js(IR) { + binaries.executable() + } + + iosArm64("ios") + iosX64("iosSim") + macosX64("macos") + mingwX64("win") + wasm32("wasm") + linuxArm32Hfp("linArm32") + linuxMips32("linMips32") + linuxMipsel32("linMipsel32") + linuxX64("lin64") + + sourceSets { + commonMain { + dependencies { + implementation(project(":redux-kotlin")) + } + } + commonTest { + kotlin.srcDir("src/test/kotlin") + dependencies { + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + implementation("org.spekframework.spek2:spek-dsl-metadata:${Versions.spek}") + implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll-common:${Versions.atrium}") + implementation("io.mockk:mockk-common:${Versions.mockk}") + } + } + val jvmTest by getting { + dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-junit")) + implementation("org.spekframework.spek2:spek-dsl-jvm:${Versions.spek}") + implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll:${Versions.atrium}") + implementation("io.mockk:mockk:${Versions.mockk}") + + runtimeOnly("org.spekframework.spek2:spek-runner-junit5:${Versions.spek}") + runtimeOnly("org.jetbrains.kotlin:kotlin-reflect") + } + } + val jsTest by getting { + dependencies { + implementation(kotlin("test-js")) + implementation(kotlin("stdlib-js")) + } + } + + val iosMain by getting + val iosTest by getting + val iosSimMain by getting { dependsOn(iosMain) } + val iosSimTest by getting { dependsOn(iosTest) } + } +} + +tasks { + val jvmTest by getting(Test::class) { + useJUnitPlatform { + includeEngines("spek2") + } + } +} diff --git a/gradle.properties b/gradle.properties index 7456d61..8082345 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,7 +23,7 @@ kotlin.native.ignoreDisabledTargets=true kotlin.mpp.enableGranularSourceSetsMetadata=true GROUP=org.reduxkotlin -VERSION_NAME=0.5.4-SNAPSHOT +VERSION_NAME=0.5.4 POM_ARTIFACT_ID=reduxkotlin POM_DESCRIPTION=Redux implementation for Kotlin. Mulitiplatform supported. diff --git a/redux-kotlin-threadsafe/build.gradle b/redux-kotlin-threadsafe/build.gradle deleted file mode 100644 index 96f60b3..0000000 --- a/redux-kotlin-threadsafe/build.gradle +++ /dev/null @@ -1,128 +0,0 @@ -repositories { - maven { url "https://dl.bintray.com/spekframework/spek-dev" } -} -apply plugin: 'java' -apply plugin: 'kotlin-multiplatform' -apply plugin: 'kotlinx-atomicfu' - -archivesBaseName = 'redux-kotlin-threadsafe' - -kotlin { - jvm() - js() { - [compileKotlinJs, compileTestKotlinJs].each { configuration -> - configuration.kotlinOptions { - moduleKind = 'umd' - sourceMap = true - metaInfo = true - } - } - } - - iosArm64("ios") - iosX64("iosSim") - macosX64("macos") - mingwX64("win") - //below are currently not supported by atomicfu - //wasm32("wasm") - //linuxArm32Hfp("linArm32") - //linuxMips32("linMips32") - //linuxMipsel32("linMipsel32") - linuxX64("lin64") - - sourceSets { - - commonMain { - dependencies { - api project(":redux-kotlin") - } - } - commonTest { - kotlin.srcDir('src/test/kotlin') - dependencies { - implementation kotlin("test-common") - implementation kotlin("test-annotations-common") - implementation Libs.spek_dsl_metadata - implementation Libs.atrium_cc_en_gb_robstoll_common - implementation Libs.mockk_common - implementation Libs.kotlin_coroutines - } - } - - jvmMain { - dependencies { - } - } - jvmTest { - dependencies { - implementation kotlin("test") - implementation kotlin("test-junit") - implementation Libs.kotlin_coroutines_test - implementation Libs.kotlin_coroutines_jvm - implementation Libs.spek_dsl_jvm - implementation Libs.atrium_cc_en_gb_robstoll - implementation Libs.mockk - - runtimeOnly Libs.spek_runner_junit5 - runtimeOnly Libs.kotlin_reflect - - } - } - jsMain { - dependencies { - } - compileKotlinJs { - kotlinOptions.metaInfo = true - kotlinOptions.sourceMap = true - kotlinOptions.suppressWarnings = true - kotlinOptions.verbose = true - kotlinOptions.main = "call" - kotlinOptions.moduleKind = "umd" - } - } - jsTest { - dependencies { - implementation kotlin("test-js") - implementation kotlin("stdlib-js") - } - } - - iosSimMain.dependsOn iosMain - iosSimTest.dependsOn iosTest - } -} - - -afterEvaluate { - // Alias the task names we use elsewhere to the new task names. - tasks.create('installMP').dependsOn('publishKotlinMultiplatformPublicationToMavenLocal') - tasks.create('installLocally') { - dependsOn 'publishKotlinMultiplatformPublicationToTestRepository' - dependsOn 'publishJvmPublicationToTestRepository' - dependsOn 'publishJsPublicationToTestRepository' - dependsOn 'publishMetadataPublicationToTestRepository' - } - tasks.create('installIosLocally') { - dependsOn 'publishKotlinMultiplatformPublicationToTestRepository' - dependsOn 'publishIosArm32PublicationToTestRepository' - dependsOn 'publishIosArm64PublicationToTestRepository' - dependsOn 'publishIosX64PublicationToTestRepository' - dependsOn 'publishMetadataPublicationToTestRepository' - } - // NOTE: We do not alias uploadArchives because CI runs it on Linux and we only want to run it on Mac OS. - //tasks.create('uploadArchives').dependsOn('publishKotlinMultiplatformPublicationToMavenRepository') -} - -apply from: rootProject.file('gradle/publish.gradle') - -publishing { - publications.all { - artifactId = artifactId.replace(project.name, 'redux-kotlin-threadsafe') - } -} - -jvmTest { - useJUnitPlatform { - includeEngines 'spek2' - } -} diff --git a/redux-kotlin-threadsafe/build.gradle.kts b/redux-kotlin-threadsafe/build.gradle.kts new file mode 100644 index 0000000..673d23b --- /dev/null +++ b/redux-kotlin-threadsafe/build.gradle.kts @@ -0,0 +1,103 @@ +plugins { + java + kotlin("multiplatform") + id("kotlinx-atomicfu") +} +repositories { + maven("https://dl.bintray.com/spekframework/spek-dev") +} + +kotlin { + jvm() + js(BOTH) { +// nodejs() +// browser() + } + + iosArm64("ios") + iosX64("iosSim") + macosX64("macos") + mingwX64("win") + //below are currently not supported by atomicfu + //wasm32("wasm") + //linuxArm32Hfp("linArm32") + //linuxMips32("linMips32") + //linuxMipsel32("linMipsel32") + linuxX64("lin64") + + sourceSets { + commonMain { + dependencies { + api(project(":redux-kotlin")) + } + } + commonTest { + kotlin.srcDir("src/test/kotlin") + dependencies { + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + implementation(Libs.spek_dsl_metadata) + implementation(Libs.atrium_cc_en_gb_robstoll_common) + implementation(Libs.mockk_common) + implementation(Libs.kotlin_coroutines) + } + } + val jvmTest by getting { + dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-junit")) + implementation(Libs.kotlin_coroutines_test) + implementation(Libs.kotlin_coroutines_jvm) + implementation(Libs.spek_dsl_jvm) + implementation(Libs.atrium_cc_en_gb_robstoll) + implementation(Libs.mockk) + + runtimeOnly(Libs.spek_runner_junit5) + runtimeOnly(Libs.kotlin_reflect) + + } + } + val jsTest by getting { + dependencies { + implementation(kotlin("test-js")) + implementation(kotlin("stdlib-js")) + } + } + + val iosMain by getting + val iosTest by getting + val iosSimMain by getting { dependsOn(iosMain) } + val iosSimTest by getting { dependsOn(iosTest) } + } +} + + +afterEvaluate { + tasks { + val jvmTest by getting(Test::class) { + useJUnitPlatform { + includeEngines("spek2") + } + } + + // Alias the task names we use elsewhere to the new task names. + create("installMP").dependsOn("publishKotlinMultiplatformPublicationToMavenLocal") + create("installLocally") { + dependsOn("publishKotlinMultiplatformPublicationToTestRepository") + dependsOn("publishJvmPublicationToTestRepository") + dependsOn("publishJsPublicationToTestRepository") + dependsOn("publishMetadataPublicationToTestRepository") + } + create("installIosLocally") { + dependsOn("publishKotlinMultiplatformPublicationToTestRepository") + dependsOn("publishIosArm32PublicationToTestRepository") + dependsOn("publishIosArm64PublicationToTestRepository") + dependsOn("publishIosX64PublicationToTestRepository") + dependsOn("publishMetadataPublicationToTestRepository") + } + // NOTE: We do not alias uploadArchives because CI runs it on Linux and we only want to run it on Mac OS. + //tasks.create("uploadArchives").dependsOn("publishKotlinMultiplatformPublicationToMavenRepository") + } +} + +apply(from = rootProject.file("gradle/publish.gradle")) \ No newline at end of file diff --git a/redux-kotlin/build.gradle b/redux-kotlin/build.gradle deleted file mode 100644 index 7a2f02e..0000000 --- a/redux-kotlin/build.gradle +++ /dev/null @@ -1,142 +0,0 @@ -repositories { - maven { url "https://dl.bintray.com/spekframework/spek-dev" } -} -apply plugin: 'java' -apply plugin: 'kotlin-multiplatform' - -archivesBaseName = 'redux-kotlin' - -kotlin { - jvm() - js() { - [compileKotlinJs, compileTestKotlinJs].each { configuration -> - configuration.kotlinOptions { - moduleKind = 'umd' - sourceMap = true - metaInfo = true - } - } - } - - iosArm64("ios") - iosX64("iosSim") - macosX64("macos") - mingwX64("win") - wasm32("wasm") - linuxArm32Hfp("linArm32") - linuxMips32("linMips32") - linuxMipsel32("linMipsel32") - linuxX64("lin64") - - sourceSets { - - commonMain { - dependencies { - } - } - commonTest { - kotlin.srcDir('src/test/kotlin') - dependencies { - implementation kotlin("test-common") - implementation kotlin("test-annotations-common") - implementation Libs.spek_dsl_metadata - implementation Libs.atrium_cc_en_gb_robstoll_common - implementation Libs.mockk_common - } - } - - jvmMain { - kotlin.srcDir('src/jvmMain/kotlin') - dependencies { - } - } - jvmTest { - dependencies { - implementation kotlin("test") - implementation kotlin("test-junit") - implementation Libs.kotlin_coroutines_test - implementation Libs.kotlin_coroutines_jvm - implementation Libs.spek_dsl_jvm - implementation Libs.atrium_cc_en_gb_robstoll - implementation Libs.mockk - - runtimeOnly Libs.spek_runner_junit5 - runtimeOnly Libs.kotlin_reflect - } - } - jsMain { - kotlin.srcDir('src/jsMain/kotlin') - dependencies { - } - compileKotlinJs { - kotlinOptions.metaInfo = true - kotlinOptions.sourceMap = true - kotlinOptions.suppressWarnings = true - kotlinOptions.verbose = true - kotlinOptions.main = "call" - kotlinOptions.moduleKind = "umd" - } - } - jsTest { - dependencies { - implementation kotlin("test-js") - } - } - winMain { - kotlin.srcDir('src/fallbackMain') - } - wasmMain { - kotlin.srcDir('src/fallbackMain') - } - linArm32Main { - kotlin.srcDir('src/fallbackMain') - } - linMips32Main { - kotlin.srcDir('src/fallbackMain') - } - linMipsel32Main { - kotlin.srcDir('src/fallbackMain') - } - lin64Main { - kotlin.srcDir('src/fallbackMain') - } - - iosSimMain.dependsOn iosMain - iosSimTest.dependsOn iosTest - } -} - - -afterEvaluate { - // Alias the task names we use elsewhere to the new task names. - tasks.create('installMP').dependsOn('publishKotlinMultiplatformPublicationToMavenLocal') - tasks.create('installLocally') { - dependsOn 'publishKotlinMultiplatformPublicationToTestRepository' - dependsOn 'publishJvmPublicationToTestRepository' - dependsOn 'publishJsPublicationToTestRepository' - dependsOn 'publishMetadataPublicationToTestRepository' - } - tasks.create('installIosLocally') { - dependsOn 'publishKotlinMultiplatformPublicationToTestRepository' - dependsOn 'publishIosArm32PublicationToTestRepository' - dependsOn 'publishIosArm64PublicationToTestRepository' - dependsOn 'publishIosX64PublicationToTestRepository' - dependsOn 'publishMetadataPublicationToTestRepository' - } - // NOTE: We do not alias uploadArchives because CI runs it on Linux and we only want to run it on Mac OS. - //tasks.create('uploadArchives').dependsOn('publishKotlinMultiplatformPublicationToMavenRepository') -} - -apply from: rootProject.file('gradle/publish.gradle') - -publishing { - publications.all { - artifactId = artifactId.replace(project.name, 'redux-kotlin') - } -} - -jvmTest { - useJUnitPlatform { - includeEngines 'spek2' - } -} diff --git a/redux-kotlin/build.gradle.kts b/redux-kotlin/build.gradle.kts new file mode 100644 index 0000000..8a8b0b3 --- /dev/null +++ b/redux-kotlin/build.gradle.kts @@ -0,0 +1,113 @@ +plugins { + java + kotlin("multiplatform") + `maven-publish` +} + +repositories { + maven("https://dl.bintray.com/spekframework/spek-dev") +} + +kotlin { + jvm() + js(BOTH) { +// nodejs() +// browser() + } + + iosArm64("ios") + iosX64("iosSim") + macosX64("macos") + mingwX64("win") + wasm32("wasm") + linuxArm32Hfp("linArm32") + linuxMips32("linMips32") + linuxMipsel32("linMipsel32") + linuxX64("lin64") + + sourceSets { + commonTest { + kotlin.srcDir("src/test/kotlin") + dependencies { + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + implementation(Libs.spek_dsl_metadata) + implementation(Libs.atrium_cc_en_gb_robstoll_common) + implementation(Libs.mockk_common) + } + } + val jvmTest by getting { + dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-junit")) + implementation(Libs.kotlin_coroutines_test) + implementation(Libs.kotlin_coroutines_jvm) + implementation(Libs.spek_dsl_jvm) + implementation(Libs.atrium_cc_en_gb_robstoll) + implementation(Libs.mockk) + + runtimeOnly(Libs.spek_runner_junit5) + runtimeOnly(Libs.kotlin_reflect) + } + } + val jsTest by getting { + dependencies { + implementation(kotlin("test-js")) + } + } + val winMain by getting { + kotlin.srcDir("src/fallbackMain") + } + val wasmMain by getting { + kotlin.srcDir("src/fallbackMain") + } + val linArm32Main by getting { + kotlin.srcDir("src/fallbackMain") + } + val linMips32Main by getting { + kotlin.srcDir("src/fallbackMain") + } + val linMipsel32Main by getting { + kotlin.srcDir("src/fallbackMain") + } + val lin64Main by getting { + kotlin.srcDir("src/fallbackMain") + } + + val iosMain by getting + val iosTest by getting + val iosSimMain by getting { dependsOn(iosMain) } + val iosSimTest by getting { dependsOn(iosTest) } + } +} + + +afterEvaluate { + tasks { + val jvmTest by getting(Test::class) { + useJUnitPlatform { + includeEngines("spek2") + } + } + + // Alias the task names we use elsewhere to the new task names. + create("installMP").dependsOn("publishKotlinMultiplatformPublicationToMavenLocal") + create("installLocally") { + dependsOn("publishKotlinMultiplatformPublicationToTestRepository") + dependsOn("publishJvmPublicationToTestRepository") + dependsOn("publishJsPublicationToTestRepository") + dependsOn("publishMetadataPublicationToTestRepository") + } + create("installIosLocally") { + dependsOn("publishKotlinMultiplatformPublicationToTestRepository") + dependsOn("publishIosArm32PublicationToTestRepository") + dependsOn("publishIosArm64PublicationToTestRepository") + dependsOn("publishIosX64PublicationToTestRepository") + dependsOn("publishMetadataPublicationToTestRepository") + } + // NOTE: We do not alias uploadArchives because CI runs it on Linux and we only want to run it on Mac OS. + //tasks.create("uploadArchives").dependsOn("publishKotlinMultiplatformPublicationToMavenRepository") + } +} + +apply(from = rootProject.file("gradle/publish.gradle")) diff --git a/redux-kotlin/proguard-rules.pro b/redux-kotlin/proguard-rules.pro index f1b4245..2f9dc5a 100644 --- a/redux-kotlin/proguard-rules.pro +++ b/redux-kotlin/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html From e6c61a55835a84bf21f6479d1f18a229ee668096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Petu=C5=A1ka?= Date: Mon, 27 Jul 2020 23:04:12 +0300 Subject: [PATCH 05/19] Kotlin 1.4.0-rc further cleanup --- examples/counter/common/build.gradle.kts | 9 +++++++++ redux-kotlin-threadsafe/build.gradle.kts | 9 +++++++++ redux-kotlin/build.gradle.kts | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/examples/counter/common/build.gradle.kts b/examples/counter/common/build.gradle.kts index 14e823e..0697f1a 100644 --- a/examples/counter/common/build.gradle.kts +++ b/examples/counter/common/build.gradle.kts @@ -11,6 +11,15 @@ kotlin { jvm() js(IR) { binaries.executable() + + listOf(compilations["main"], compilations["test"]).forEach { + with(it.kotlinOptions) { + moduleKind = "umd" + sourceMap = true + sourceMapEmbedSources = "always" + metaInfo = true + } + } } iosArm64("ios") diff --git a/redux-kotlin-threadsafe/build.gradle.kts b/redux-kotlin-threadsafe/build.gradle.kts index 673d23b..c0aef84 100644 --- a/redux-kotlin-threadsafe/build.gradle.kts +++ b/redux-kotlin-threadsafe/build.gradle.kts @@ -12,6 +12,15 @@ kotlin { js(BOTH) { // nodejs() // browser() + + listOf(compilations["main"], compilations["test"]).forEach { + with(it.kotlinOptions) { + moduleKind = "umd" + sourceMap = true + sourceMapEmbedSources = "always" + metaInfo = true + } + } } iosArm64("ios") diff --git a/redux-kotlin/build.gradle.kts b/redux-kotlin/build.gradle.kts index 8a8b0b3..a9bef6a 100644 --- a/redux-kotlin/build.gradle.kts +++ b/redux-kotlin/build.gradle.kts @@ -13,6 +13,15 @@ kotlin { js(BOTH) { // nodejs() // browser() + + listOf(compilations["main"], compilations["test"]).forEach { + with(it.kotlinOptions) { + moduleKind = "umd" + sourceMap = true + sourceMapEmbedSources = "always" + metaInfo = true + } + } } iosArm64("ios") From a39c0c4bc3900de9c52a2f4c17b7a78f0cf64b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Petu=C5=A1ka?= Date: Mon, 27 Jul 2020 23:09:23 +0300 Subject: [PATCH 06/19] Kotlin 1.4.0-rc further cleanup --- redux-kotlin-threadsafe/build.gradle.kts | 16 +++++++--------- redux-kotlin/build.gradle.kts | 3 --- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/redux-kotlin-threadsafe/build.gradle.kts b/redux-kotlin-threadsafe/build.gradle.kts index c0aef84..333329c 100644 --- a/redux-kotlin-threadsafe/build.gradle.kts +++ b/redux-kotlin-threadsafe/build.gradle.kts @@ -10,17 +10,15 @@ repositories { kotlin { jvm() js(BOTH) { -// nodejs() -// browser() - listOf(compilations["main"], compilations["test"]).forEach { - with(it.kotlinOptions) { - moduleKind = "umd" - sourceMap = true - sourceMapEmbedSources = "always" - metaInfo = true - } + listOf(compilations["main"], compilations["test"]).forEach { + with(it.kotlinOptions) { + moduleKind = "umd" + sourceMap = true + sourceMapEmbedSources = "always" + metaInfo = true } + } } iosArm64("ios") diff --git a/redux-kotlin/build.gradle.kts b/redux-kotlin/build.gradle.kts index a9bef6a..db2eda8 100644 --- a/redux-kotlin/build.gradle.kts +++ b/redux-kotlin/build.gradle.kts @@ -11,9 +11,6 @@ repositories { kotlin { jvm() js(BOTH) { -// nodejs() -// browser() - listOf(compilations["main"], compilations["test"]).forEach { with(it.kotlinOptions) { moduleKind = "umd" From c3f63a0b63d8d130ecc61aa7bcfa97bd13960636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Petu=C5=A1ka?= Date: Mon, 27 Jul 2020 23:20:17 +0300 Subject: [PATCH 07/19] Kotlin 1.4.0-rc further cleanup --- examples/todos/common/build.gradle | 96 ------------------- examples/todos/common/build.gradle.kts | 83 ++++++++++++++++ redux-kotlin-threadsafe/build.gradle.kts | 1 - redux-kotlin/build.gradle.kts | 1 - .../org/reduxkotlin/ApplyMiddlewareTest.kt | 6 +- .../kotlin/org/reduxkotlin/CreateStoreSpec.kt | 33 ++++--- 6 files changed, 103 insertions(+), 117 deletions(-) delete mode 100644 examples/todos/common/build.gradle create mode 100644 examples/todos/common/build.gradle.kts rename redux-kotlin/src/{test => commonTest}/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt (94%) rename redux-kotlin/src/{test => commonTest}/kotlin/org/reduxkotlin/CreateStoreSpec.kt (73%) diff --git a/examples/todos/common/build.gradle b/examples/todos/common/build.gradle deleted file mode 100644 index 4e84145..0000000 --- a/examples/todos/common/build.gradle +++ /dev/null @@ -1,96 +0,0 @@ -repositories { - maven { url "https://dl.bintray.com/spekframework/spek-dev" } -} -apply plugin: 'java' -apply plugin: 'kotlin-multiplatform' - - -kotlin { - jvm() - js() { - [compileKotlinJs, compileTestKotlinJs].each { configuration -> - configuration.kotlinOptions { - moduleKind = 'umd' - sourceMap = true - metaInfo = true - } - } - } - - - iosArm64("ios") - iosX64("iosSim") - macosX64("macos") - mingwX64("win") - wasm32("wasm") - linuxArm32Hfp("linArm32") - linuxMips32("linMips32") - linuxMipsel32("linMipsel32") - linuxX64("lin64") - - sourceSets { - commonMain { - dependencies { - implementation kotlin("stdlib-common") - implementation project(":redux-kotlin-threadsafe") - } - } - commonTest { - kotlin.srcDir('src/test/kotlin') - dependencies { - implementation kotlin("test-common") - implementation kotlin("test-annotations-common") - implementation "org.spekframework.spek2:spek-dsl-metadata:$Versions.spek" - implementation "ch.tutteli.atrium:atrium-cc-en_GB-robstoll-common:$Versions.atrium" - implementation "io.mockk:mockk-common:$Versions.mockk" - } - } - - jvmMain { - kotlin.srcDir('src/jvmMain/kotlin') - dependencies { - implementation kotlin("stdlib") - } - } - jvmTest { - dependencies { - implementation kotlin("test") - implementation kotlin("test-junit") - implementation "org.spekframework.spek2:spek-dsl-jvm:$Versions.spek" - implementation "ch.tutteli.atrium:atrium-cc-en_GB-robstoll:$Versions.atrium" - implementation "io.mockk:mockk:1.9.3" - - runtimeOnly "org.spekframework.spek2:spek-runner-junit5:$Versions.spek" - runtimeOnly 'org.jetbrains.kotlin:kotlin-reflect' - } - } - jsMain { - kotlin.srcDir('src/jsMain/kotlin') - dependencies { - implementation kotlin("stdlib-js") - } - compileKotlinJs { - kotlinOptions.metaInfo = true - kotlinOptions.sourceMap = true - kotlinOptions.verbose = true - kotlinOptions.main = "call" - kotlinOptions.moduleKind = "umd" - } - } - jsTest { - dependencies { - implementation kotlin("test-js") - implementation kotlin("stdlib-js") - } - } - - iosSimMain.dependsOn iosMain - iosSimTest.dependsOn iosTest - } -} - -jvmTest { - useJUnitPlatform { - includeEngines 'spek2' - } -} diff --git a/examples/todos/common/build.gradle.kts b/examples/todos/common/build.gradle.kts new file mode 100644 index 0000000..d13a1b0 --- /dev/null +++ b/examples/todos/common/build.gradle.kts @@ -0,0 +1,83 @@ +plugins { + java + kotlin("multiplatform") +} + +repositories { + maven("https://dl.bintray.com/spekframework/spek-dev") +} + +kotlin { + jvm() + js(IR) { + binaries.executable() + + listOf(compilations["main"], compilations["test"]).forEach { + with(it.kotlinOptions) { + moduleKind = "umd" + sourceMap = true + sourceMapEmbedSources = "always" + metaInfo = true + } + } + } + + iosArm64("ios") + iosX64("iosSim") + macosX64("macos") + mingwX64("win") + wasm32("wasm") + linuxArm32Hfp("linArm32") + linuxMips32("linMips32") + linuxMipsel32("linMipsel32") + linuxX64("lin64") + + sourceSets { + commonMain { + dependencies { + implementation(project(":redux-kotlin-threadsafe")) + } + } + commonTest { + kotlin.srcDir("src/test/kotlin") + dependencies { + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + implementation("org.spekframework.spek2:spek-dsl-metadata:${Versions.spek}") + implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll-common:${Versions.atrium}") + implementation("io.mockk:mockk-common:${Versions.mockk}") + } + } + val jvmTest by getting { + dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-junit")) + implementation("org.spekframework.spek2:spek-dsl-jvm:${Versions.spek}") + implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll:${Versions.atrium}") + implementation("io.mockk:mockk:${Versions.mockk}") + + runtimeOnly("org.spekframework.spek2:spek-runner-junit5:${Versions.spek}") + runtimeOnly("org.jetbrains.kotlin:kotlin-reflect") + } + } + val jsTest by getting { + dependencies { + implementation(kotlin("test-js")) + implementation(kotlin("stdlib-js")) + } + } + + val iosMain by getting + val iosTest by getting + val iosSimMain by getting { dependsOn(iosMain) } + val iosSimTest by getting { dependsOn(iosTest) } + } +} + +tasks { + val jvmTest by getting(Test::class) { + useJUnitPlatform { + includeEngines("spek2") + } + } +} diff --git a/redux-kotlin-threadsafe/build.gradle.kts b/redux-kotlin-threadsafe/build.gradle.kts index 333329c..62f53a1 100644 --- a/redux-kotlin-threadsafe/build.gradle.kts +++ b/redux-kotlin-threadsafe/build.gradle.kts @@ -39,7 +39,6 @@ kotlin { } } commonTest { - kotlin.srcDir("src/test/kotlin") dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) diff --git a/redux-kotlin/build.gradle.kts b/redux-kotlin/build.gradle.kts index db2eda8..f6ae4b6 100644 --- a/redux-kotlin/build.gradle.kts +++ b/redux-kotlin/build.gradle.kts @@ -33,7 +33,6 @@ kotlin { sourceSets { commonTest { - kotlin.srcDir("src/test/kotlin") dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) diff --git a/redux-kotlin/src/test/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt b/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt similarity index 94% rename from redux-kotlin/src/test/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt rename to redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt index 617e659..c643f3a 100644 --- a/redux-kotlin/src/test/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt +++ b/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt @@ -1,7 +1,5 @@ package org.reduxkotlin -import ch.tutteli.atrium.api.cc.en_GB.toThrow -import ch.tutteli.atrium.domain.creating.AnyAssertions import ch.tutteli.atrium.verbs.expect import org.spekframework.spek2.Spek import org.spekframework.spek2.style.specification.describe @@ -11,7 +9,7 @@ object ApplyMiddlewareSpec : Spek({ describe("applyMiddleware") { it("warns when dispatching during middleware setup") { fun dispatchingMiddleware(store: Store): (next: Dispatcher) -> (action: Any) -> Any { - store.dispatch(AddTodo("1", "Dont dispatch in middleware setup")); + store.dispatch(AddTodo("1", "Dont dispatch in middleware setup")) return { next -> { action -> { @@ -24,7 +22,7 @@ object ApplyMiddlewareSpec : Spek({ expect { val storeEnhancer: StoreEnhancer = applyMiddleware(::dispatchingMiddleware) createStore(todos, TestState(), storeEnhancer) - }.toThrow {} + }.toThrow().asAssert({}) } /* diff --git a/redux-kotlin/src/test/kotlin/org/reduxkotlin/CreateStoreSpec.kt b/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/CreateStoreSpec.kt similarity index 73% rename from redux-kotlin/src/test/kotlin/org/reduxkotlin/CreateStoreSpec.kt rename to redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/CreateStoreSpec.kt index 98217d7..f63fe13 100644 --- a/redux-kotlin/src/test/kotlin/org/reduxkotlin/CreateStoreSpec.kt +++ b/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/CreateStoreSpec.kt @@ -1,6 +1,9 @@ package org.reduxkotlin -import ch.tutteli.atrium.api.cc.en_GB.toBe +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.creating.Assert +import ch.tutteli.atrium.domain.builders.migration.asAssert +import ch.tutteli.atrium.domain.builders.migration.asExpect import ch.tutteli.atrium.verbs.expect import org.spekframework.spek2.Spek import org.spekframework.spek2.style.specification.describe @@ -19,7 +22,7 @@ object CreateStoreSpec : Spek({ ) ) - expect(store.getState()).toBe( + expect(store.getState()).asExpect>().toBe( TestState( listOf( Todo( @@ -28,17 +31,17 @@ object CreateStoreSpec : Spek({ ) ) ) - ) + ).asAssert() } it("applies the reducer to the previous state") { val store = createStore(todos, TestState()) - expect(store.getState()).toBe(TestState()) + expect(store.getState()).asExpect>().toBe(TestState()).asAssert() store.dispatch(Any()) - expect(store.getState()).toBe(TestState()) + expect(store.getState()).asExpect>().toBe(TestState()).asAssert() store.dispatch(AddTodo("1", "Hello")) - expect(store.getState()).toBe( + expect(store.getState()).asExpect>().toBe( TestState( listOf( Todo( @@ -47,11 +50,11 @@ object CreateStoreSpec : Spek({ ) ) ) - ) + ).asAssert() //TODO are ids autoincrement? store.dispatch(AddTodo("2", "World")) - expect(store.getState()).toBe( + expect(store.getState()).asExpect>().toBe( TestState( listOf( Todo( @@ -64,7 +67,7 @@ object CreateStoreSpec : Spek({ ) ) ) - ) + ).asAssert() } it("applies the reducer to the initial state") { @@ -78,7 +81,7 @@ object CreateStoreSpec : Spek({ ) ) ) - expect(store.getState()).toBe( + expect(store.getState()).asExpect>().toBe( TestState( listOf( Todo( @@ -87,10 +90,10 @@ object CreateStoreSpec : Spek({ ) ) ) - ) + ).asAssert() store.dispatch(Any()) - expect(store.getState()).toBe( + expect(store.getState()).asExpect>().toBe( TestState( listOf( Todo( @@ -99,10 +102,10 @@ object CreateStoreSpec : Spek({ ) ) ) - ) + ).asAssert() store.dispatch(AddTodo("2", "World")) - expect(store.getState()).toBe( + expect(store.getState()).asExpect>().toBe( TestState( listOf( Todo( @@ -115,7 +118,7 @@ object CreateStoreSpec : Spek({ ) ) ) - ) + ).asAssert() } } From af8df5bec0f3bc37b9ee088399814020b0321bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Petu=C5=A1ka?= Date: Mon, 27 Jul 2020 23:41:32 +0300 Subject: [PATCH 08/19] Kotlin 1.4.0-rc tests --- .../commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt b/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt index c643f3a..04a014d 100644 --- a/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt +++ b/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt @@ -1,5 +1,6 @@ package org.reduxkotlin +import ch.tutteli.atrium.api.cc.en_GB.toThrow import ch.tutteli.atrium.verbs.expect import org.spekframework.spek2.Spek import org.spekframework.spek2.style.specification.describe @@ -22,7 +23,7 @@ object ApplyMiddlewareSpec : Spek({ expect { val storeEnhancer: StoreEnhancer = applyMiddleware(::dispatchingMiddleware) createStore(todos, TestState(), storeEnhancer) - }.toThrow().asAssert({}) + }.toThrow {} } /* From ecc0bb7b39b207b96881b4ca9c22aed8794e8163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Petu=C5=A1ka?= Date: Tue, 28 Jul 2020 00:52:20 +0300 Subject: [PATCH 09/19] Kotlin 1.4.0-rc JS flavours fixed --- build.gradle | 43 ------------------------ build.gradle.kts | 38 +++++++++++++++++++++ examples/counter/common/build.gradle.kts | 1 + examples/todos/common/build.gradle.kts | 1 + redux-kotlin-threadsafe/build.gradle.kts | 2 ++ redux-kotlin/build.gradle.kts | 5 ++- settings.gradle => settings.gradle.kts | 14 ++++---- 7 files changed, 53 insertions(+), 51 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts rename settings.gradle => settings.gradle.kts (55%) diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 3a7fbcf..0000000 --- a/build.gradle +++ /dev/null @@ -1,43 +0,0 @@ -buildscript { - repositories { - google() - mavenCentral() - maven { url 'https://dl.bintray.com/jetbrains/kotlin-native-dependencies' } - maven { url "https://plugins.gradle.org/m2/" } - maven { url "https://oss.sonatype.org/content/repositories/snapshots" } - jcenter() - } - - dependencies { - classpath Plugins.kotlin - classpath Plugins.dokka - classpath Plugins.android - classpath Plugins.atomicFu - } -} - -plugins { - id("de.fayard.buildSrcVersions") version "0.4.2" -} - -allprojects { - repositories { - maven { url "https://kotlin.bintray.com/kotlinx" } - google() - jcenter() - maven { url "https://oss.sonatype.org/content/repositories/snapshots" } - maven { url "https://dl.bintray.com/spekframework/spek-dev" } - mavenCentral() - } - - group = GROUP - version = VERSION_NAME - if (hasProperty("SNAPSHOT") || System.getenv("SNAPSHOT") != null) { - version = version + "-SNAPSHOT" - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} - diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..d245f60 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,38 @@ +buildscript { + repositories { + google() + mavenCentral() + maven("https://dl.bintray.com/jetbrains/kotlin-native-dependencies") + maven("https://plugins.gradle.org/m2/") + maven("https://oss.sonatype.org/content/repositories/snapshots") + jcenter() + } + + dependencies { + classpath(Plugins.kotlin) + classpath(Plugins.dokka) + classpath(Plugins.android) + classpath(Plugins.atomicFu) + } +} + +plugins { + id("de.fayard.buildSrcVersions") version "0.4.2" +} + +allprojects { + repositories { + google() + jcenter() + maven("https://kotlin.bintray.com/kotlinx") + maven("https://oss.sonatype.org/content/repositories/snapshots") + maven("https://dl.bintray.com/spekframework/spek-dev") + mavenCentral() + } + + group = project.properties["GROUP"]!! + version = project.properties["VERSION_NAME"]!! + if (hasProperty("SNAPSHOT") || System.getenv("SNAPSHOT") != null) { + version = "$version-SNAPSHOT" + } +} \ No newline at end of file diff --git a/examples/counter/common/build.gradle.kts b/examples/counter/common/build.gradle.kts index 0697f1a..59aebc5 100644 --- a/examples/counter/common/build.gradle.kts +++ b/examples/counter/common/build.gradle.kts @@ -10,6 +10,7 @@ repositories { kotlin { jvm() js(IR) { + browser() binaries.executable() listOf(compilations["main"], compilations["test"]).forEach { diff --git a/examples/todos/common/build.gradle.kts b/examples/todos/common/build.gradle.kts index d13a1b0..6c8f0b6 100644 --- a/examples/todos/common/build.gradle.kts +++ b/examples/todos/common/build.gradle.kts @@ -11,6 +11,7 @@ kotlin { jvm() js(IR) { binaries.executable() + browser() listOf(compilations["main"], compilations["test"]).forEach { with(it.kotlinOptions) { diff --git a/redux-kotlin-threadsafe/build.gradle.kts b/redux-kotlin-threadsafe/build.gradle.kts index 62f53a1..c70b295 100644 --- a/redux-kotlin-threadsafe/build.gradle.kts +++ b/redux-kotlin-threadsafe/build.gradle.kts @@ -10,6 +10,8 @@ repositories { kotlin { jvm() js(BOTH) { + browser() + nodejs() listOf(compilations["main"], compilations["test"]).forEach { with(it.kotlinOptions) { diff --git a/redux-kotlin/build.gradle.kts b/redux-kotlin/build.gradle.kts index f6ae4b6..2e8d47d 100644 --- a/redux-kotlin/build.gradle.kts +++ b/redux-kotlin/build.gradle.kts @@ -1,16 +1,19 @@ plugins { java kotlin("multiplatform") - `maven-publish` } repositories { maven("https://dl.bintray.com/spekframework/spek-dev") } + kotlin { jvm() js(BOTH) { + browser() + nodejs() + listOf(compilations["main"], compilations["test"]).forEach { with(it.kotlinOptions) { moduleKind = "umd" diff --git a/settings.gradle b/settings.gradle.kts similarity index 55% rename from settings.gradle rename to settings.gradle.kts index 6180d3d..6b34c57 100644 --- a/settings.gradle +++ b/settings.gradle.kts @@ -9,12 +9,12 @@ pluginManagement { } include( - ':redux-kotlin', - ':redux-kotlin-threadsafe', - ':examples:counter:common', - ':examples:counter:android', - ':examples:todos:common', - ':examples:todos:android' + ":redux-kotlin", + ":redux-kotlin-threadsafe", + ":examples:counter:common", + ":examples:counter:android", + ":examples:todos:common", + ":examples:todos:android" ) -rootProject.name = 'Redux-Kotlin' +rootProject.name = "Redux-Kotlin" From 9d68e53cdb128127c7b1c37cfcb157e83244f465 Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Mon, 27 Jul 2020 18:41:08 -0400 Subject: [PATCH 10/19] Update publish_snapshot.yml add publish snapshot action for kotlin-* branches --- .github/workflows/publish_snapshot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_snapshot.yml b/.github/workflows/publish_snapshot.yml index ae86752..b178b5c 100644 --- a/.github/workflows/publish_snapshot.yml +++ b/.github/workflows/publish_snapshot.yml @@ -2,7 +2,7 @@ name: Publish snapshot on: push: - branches: [ master, feature/* ] + branches: [ master, feature/*, kotlin-* ] pull_request: branches: [ master ] From 61f1c3cf03ca322827ce54047d048220ef91f06f Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Sun, 2 Aug 2020 20:42:05 -0400 Subject: [PATCH 11/19] add iosArm32, androidNative32, androidNative64, tvos, & watchOS --- buildSrc/src/main/kotlin/Libs.kt | 90 ++++---- buildSrc/src/main/kotlin/Plugins.kt | 2 +- buildSrc/src/main/kotlin/Versions.kt | 40 ++-- examples/counter/common/build.gradle.kts | 30 +-- examples/todos/android/build.gradle.kts | 4 +- examples/todos/common/build.gradle.kts | 34 +-- redux-kotlin-threadsafe/build.gradle.kts | 183 +++++++-------- redux-kotlin/build.gradle.kts | 211 ++++++++++-------- .../org/reduxkotlin/utils/ThreadUtilMacOs.kt | 0 9 files changed, 300 insertions(+), 294 deletions(-) rename redux-kotlin/src/{macosMain => macosX64Main}/kotlin/org/reduxkotlin/utils/ThreadUtilMacOs.kt (100%) diff --git a/buildSrc/src/main/kotlin/Libs.kt b/buildSrc/src/main/kotlin/Libs.kt index d9c89d0..0253863 100644 --- a/buildSrc/src/main/kotlin/Libs.kt +++ b/buildSrc/src/main/kotlin/Libs.kt @@ -8,41 +8,32 @@ import kotlin.String */ object Libs { /** - * http://developer.android.com/tools/extras/support-library.html + * https://developer.android.com/jetpack/androidx */ const val appcompat: String = "androidx.appcompat:appcompat:" + Versions.appcompat /** - * https://developer.android.com/reference/android/support/constraint/ConstraintLayout + * http://tools.android.com */ - const val constraintLayout = "androidx.constraintlayout:constraintlayout:" + Versions.constraint_layout + const val constraintlayout: String = "androidx.constraintlayout:constraintlayout:" + + Versions.constraintlayout /** - * https://developer.android.com/guide/topics/ui/layout/recyclerview + * https://developer.android.com/jetpack/androidx */ - const val recyclerView = "androidx.recyclerview:recyclerview:" + Versions.recycler_view - - /** - * https://developer.android.com/testing - */ - const val espresso_core: String = "androidx.test.espresso:espresso-core:" + Versions.espresso_core - - /** - * https://developer.android.com/testing - */ - const val androidx_test_runner: String = "androidx.test:runner:" + Versions.androidx_test_runner + const val recyclerview: String = "androidx.recyclerview:recyclerview:" + Versions.recyclerview /** * https://github.com/robstoll/atrium */ const val atrium_cc_en_gb_robstoll_common: String = - "ch.tutteli.atrium:atrium-cc-en_GB-robstoll-common:" + Versions.atrium + "ch.tutteli.atrium:atrium-cc-en_GB-robstoll-common:" + Versions.ch_tutteli_atrium /** * https://github.com/robstoll/atrium */ const val atrium_cc_en_gb_robstoll: String = "ch.tutteli.atrium:atrium-cc-en_GB-robstoll:" + - Versions.atrium + Versions.ch_tutteli_atrium /** * https://developer.android.com/studio @@ -67,17 +58,12 @@ object Libs { /** * http://mockk.io */ - const val mockk_common: String = "io.mockk:mockk-common:" + Versions.mockk + const val mockk_common: String = "io.mockk:mockk-common:" + Versions.io_mockk /** * http://mockk.io */ - const val mockk: String = "io.mockk:mockk:" + Versions.mockk - - /** - * http://junit.org - */ - const val junit: String = "junit:junit:" + Versions.junit + const val mockk: String = "io.mockk:mockk:" + Versions.io_mockk const val dokka_gradle_plugin: String = "org.jetbrains.dokka:dokka-gradle-plugin:" + Versions.dokka_gradle_plugin @@ -100,12 +86,18 @@ object Libs { const val kotlin_annotation_processing_gradle: String = "org.jetbrains.kotlin:kotlin-annotation-processing-gradle:" + Versions.org_jetbrains_kotlin + const val kotlin_compiler_embeddable: String = + "org.jetbrains.kotlin:kotlin-compiler-embeddable:" + Versions.org_jetbrains_kotlin + /** * https://kotlinlang.org/ */ const val kotlin_gradle_plugin: String = "org.jetbrains.kotlin:kotlin-gradle-plugin:" + Versions.org_jetbrains_kotlin + const val kotlin_klib_commonizer_embeddable: String = + "org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:" + Versions.org_jetbrains_kotlin + /** * https://kotlinlang.org/ */ @@ -119,7 +111,7 @@ object Libs { "org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:" + Versions.org_jetbrains_kotlin /** - * https://kotlinlang.org/ + * 1.3.72 */ const val kotlin_stdlib_common: String = "org.jetbrains.kotlin:kotlin-stdlib-common:" + Versions.org_jetbrains_kotlin @@ -131,13 +123,13 @@ object Libs { Versions.org_jetbrains_kotlin /** - * https://kotlinlang.org/ + * 1.3.72 */ const val kotlin_stdlib_js: String = "org.jetbrains.kotlin:kotlin-stdlib-js:" + Versions.org_jetbrains_kotlin /** - * https://kotlinlang.org/ + * 1.3.72 */ const val kotlin_stdlib: String = "org.jetbrains.kotlin:kotlin-stdlib:" + Versions.org_jetbrains_kotlin @@ -172,21 +164,41 @@ object Libs { const val kotlin_test: String = "org.jetbrains.kotlin:kotlin-test:" + Versions.org_jetbrains_kotlin - const val spek_dsl_jvm: String = "org.spekframework.spek2:spek-dsl-jvm:" + - Versions.spek + /** + * https://github.com/Kotlin/atomicfu + */ + const val atomicfu_gradle_plugin: String = "org.jetbrains.kotlinx:atomicfu-gradle-plugin:" + + Versions.atomicfu_gradle_plugin - const val spek_dsl_metadata: String = "org.spekframework.spek2:spek-dsl-metadata:" + - Versions.spek + /** + * https://github.com/Kotlin/atomicfu + */ + const val atomicfu: String = "org.jetbrains.kotlinx:atomicfu:" + Versions.atomicfu - const val spek_runner_junit5: String = "org.spekframework.spek2:spek-runner-junit5:" + - Versions.spek + /** + * https://github.com/Kotlin/kotlinx.coroutines + */ + const val kotlinx_coroutines_core_jvm: String = + "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:" + Versions.kotlinx_coroutines_core_jvm + + /** + * https://github.com/Kotlin/kotlinx.coroutines + */ + const val kotlinx_coroutines_core: String = "org.jetbrains.kotlinx:kotlinx-coroutines-core:" + + Versions.kotlinx_coroutines_core + + /** + * https://github.com/Kotlin/kotlinx.coroutines + */ + const val kotlinx_coroutines_test: String = "org.jetbrains.kotlinx:kotlinx-coroutines-test:" + + Versions.kotlinx_coroutines_test - const val kotlin_coroutines: String = "org.jetbrains.kotlinx:kotlinx-coroutines-core:" + - Versions.coroutines + const val spek_dsl_jvm: String = "org.spekframework.spek2:spek-dsl-jvm:" + + Versions.org_spekframework_spek2 - const val kotlin_coroutines_jvm: String = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:" + - Versions.coroutines + const val spek_dsl_metadata: String = "org.spekframework.spek2:spek-dsl-metadata:" + + Versions.org_spekframework_spek2 - const val kotlin_coroutines_test: String = "org.jetbrains.kotlinx:kotlinx-coroutines-test:" + - Versions.coroutines + const val spek_runner_junit5: String = "org.spekframework.spek2:spek-runner-junit5:" + + Versions.org_spekframework_spek2 } diff --git a/buildSrc/src/main/kotlin/Plugins.kt b/buildSrc/src/main/kotlin/Plugins.kt index c7fec7d..03f2559 100644 --- a/buildSrc/src/main/kotlin/Plugins.kt +++ b/buildSrc/src/main/kotlin/Plugins.kt @@ -2,5 +2,5 @@ object Plugins { const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.org_jetbrains_kotlin}" const val dokka = "org.jetbrains.dokka:dokka-gradle-plugin:${Versions.dokka_gradle_plugin}" const val android = "com.android.tools.build:gradle:${Versions.com_android_tools_build_gradle}" - const val atomicFu = "org.jetbrains.kotlinx:atomicfu-gradle-plugin:${Versions.atomicFu}" + const val atomicFu = "org.jetbrains.kotlinx:atomicfu-gradle-plugin:${Versions.atomicfu}" } diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index e5fd87b..a2370ee 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -12,49 +12,49 @@ import org.gradle.plugin.use.PluginDependencySpec * YOU are responsible for updating manually the dependency version. */ object Versions { - const val appcompat: String = "1.1.0-rc01" + const val appcompat: String = "1.1.0-rc01" // available: "1.1.0" - const val espresso_core: String = "3.2.0" + const val constraintlayout: String = "1.1.3" - const val androidx_test_runner: String = "1.2.0" + const val recyclerview: String = "1.0.0" // available: "1.1.0" - const val atrium: String = "0.9.2" + const val ch_tutteli_atrium: String = "0.9.2" // available: "0.12.0" - const val aapt2: String = "3.5.0-5435860" + const val aapt2: String = "3.6.0-6040484" // available: "4.0.1-6197926" - const val com_android_tools_build_gradle: String = "3.6.0" + const val com_android_tools_build_gradle: String = "3.6.0" // available: "4.0.1" - const val lint_gradle: String = "26.5.0" + const val lint_gradle: String = "26.6.0" // available: "27.0.1" - const val de_fayard_buildsrcversions_gradle_plugin: String = "0.4.2" + const val de_fayard_buildsrcversions_gradle_plugin: String = "0.4.2" // available: "0.7.0" - const val mockk: String = "1.9.3" + const val io_mockk: String = "1.9.3" // available: "1.10.0" - const val junit: String = "4.12" - - const val dokka_gradle_plugin: String = "0.9.17" // available: "0.9.18" + const val dokka_gradle_plugin: String = "0.9.17" // available: "0.11.0-dev-59" const val org_jetbrains_kotlin: String = "1.4.0-rc" - const val spek: String = "2.1.0-alpha.0.11+d97ef33" - // available: "2.1.0-alpha.0.24+0fdeb6e" + const val atomicfu_gradle_plugin: String = "0.14.3-1.4.0-rc" - const val constraint_layout = "1.1.3" + const val atomicfu: String = "0.14.3-1.4.0-rc" - const val recycler_view = "1.0.0" + const val kotlinx_coroutines_core_jvm: String = "1.3.8-1.4.0-rc" - const val coroutines = "1.3.8-1.4.0-rc" + const val kotlinx_coroutines_core: String = "1.3.8-1.4.0-rc" - const val atomicFu = "0.14.3-1.4.0-rc" + const val kotlinx_coroutines_test: String = "1.3.8-1.4.0-rc" + + const val org_spekframework_spek2: String = "2.1.0-alpha.0.11+d97ef33" + // available: "2.1.0-alpha.0.24+0fdeb6e" /** * * See issue 19: How to update Gradle itself? * https://github.com/jmfayard/buildSrcVersions/issues/19 */ - const val gradleLatestVersion: String = "5.6.1" + const val gradleLatestVersion: String = "6.5.1" - const val gradleCurrentVersion: String = "5.6.1" + const val gradleCurrentVersion: String = "6.5" } /** diff --git a/examples/counter/common/build.gradle.kts b/examples/counter/common/build.gradle.kts index 59aebc5..eadf568 100644 --- a/examples/counter/common/build.gradle.kts +++ b/examples/counter/common/build.gradle.kts @@ -23,15 +23,8 @@ kotlin { } } - iosArm64("ios") - iosX64("iosSim") - macosX64("macos") - mingwX64("win") - wasm32("wasm") - linuxArm32Hfp("linArm32") - linuxMips32("linMips32") - linuxMipsel32("linMipsel32") - linuxX64("lin64") + iosArm64() + iosX64() sourceSets { commonMain { @@ -44,20 +37,20 @@ kotlin { dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) - implementation("org.spekframework.spek2:spek-dsl-metadata:${Versions.spek}") - implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll-common:${Versions.atrium}") - implementation("io.mockk:mockk-common:${Versions.mockk}") + implementation("org.spekframework.spek2:spek-dsl-metadata:${Versions.org_spekframework_spek2}") + implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll-common:${Versions.org_spekframework_spek2}") + implementation("io.mockk:mockk-common:${Versions.io_mockk}") } } val jvmTest by getting { dependencies { implementation(kotlin("test")) implementation(kotlin("test-junit")) - implementation("org.spekframework.spek2:spek-dsl-jvm:${Versions.spek}") - implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll:${Versions.atrium}") - implementation("io.mockk:mockk:${Versions.mockk}") + implementation("org.spekframework.spek2:spek-dsl-jvm:${Versions.org_spekframework_spek2}") + implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll:${Versions.ch_tutteli_atrium}") + implementation("io.mockk:mockk:${Versions.ch_tutteli_atrium}") - runtimeOnly("org.spekframework.spek2:spek-runner-junit5:${Versions.spek}") + runtimeOnly("org.spekframework.spek2:spek-runner-junit5:${Versions.org_spekframework_spek2}") runtimeOnly("org.jetbrains.kotlin:kotlin-reflect") } } @@ -67,11 +60,6 @@ kotlin { implementation(kotlin("stdlib-js")) } } - - val iosMain by getting - val iosTest by getting - val iosSimMain by getting { dependsOn(iosMain) } - val iosSimTest by getting { dependsOn(iosTest) } } } diff --git a/examples/todos/android/build.gradle.kts b/examples/todos/android/build.gradle.kts index 2a2de10..f53d36b 100644 --- a/examples/todos/android/build.gradle.kts +++ b/examples/todos/android/build.gradle.kts @@ -39,8 +39,8 @@ android { dependencies { implementation(Libs.kotlin_stdlib_jdk8) implementation(Libs.appcompat) - implementation(Libs.constraintLayout) - implementation(Libs.recyclerView) + implementation(Libs.constraintlayout) + implementation(Libs.recyclerview) implementation(project(":examples:todos:common")) implementation(project(":redux-kotlin-threadsafe")) diff --git a/examples/todos/common/build.gradle.kts b/examples/todos/common/build.gradle.kts index 6c8f0b6..80ab576 100644 --- a/examples/todos/common/build.gradle.kts +++ b/examples/todos/common/build.gradle.kts @@ -8,7 +8,9 @@ repositories { } kotlin { - jvm() + iosArm32() + iosArm64() + iosX64() js(IR) { binaries.executable() browser() @@ -22,16 +24,7 @@ kotlin { } } } - - iosArm64("ios") - iosX64("iosSim") - macosX64("macos") - mingwX64("win") - wasm32("wasm") - linuxArm32Hfp("linArm32") - linuxMips32("linMips32") - linuxMipsel32("linMipsel32") - linuxX64("lin64") + jvm() sourceSets { commonMain { @@ -44,20 +37,20 @@ kotlin { dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) - implementation("org.spekframework.spek2:spek-dsl-metadata:${Versions.spek}") - implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll-common:${Versions.atrium}") - implementation("io.mockk:mockk-common:${Versions.mockk}") + implementation("org.spekframework.spek2:spek-dsl-metadata:${Versions.org_spekframework_spek2}") + implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll-common:${Versions.ch_tutteli_atrium}") + implementation("io.mockk:mockk-common:${Versions.io_mockk}") } } val jvmTest by getting { dependencies { implementation(kotlin("test")) implementation(kotlin("test-junit")) - implementation("org.spekframework.spek2:spek-dsl-jvm:${Versions.spek}") - implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll:${Versions.atrium}") - implementation("io.mockk:mockk:${Versions.mockk}") + implementation("org.spekframework.spek2:spek-dsl-jvm:${Versions.org_spekframework_spek2}") + implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll:${Versions.ch_tutteli_atrium}") + implementation("io.mockk:mockk:${Versions.io_mockk}") - runtimeOnly("org.spekframework.spek2:spek-runner-junit5:${Versions.spek}") + runtimeOnly("org.spekframework.spek2:spek-runner-junit5:${Versions.org_spekframework_spek2}") runtimeOnly("org.jetbrains.kotlin:kotlin-reflect") } } @@ -67,11 +60,6 @@ kotlin { implementation(kotlin("stdlib-js")) } } - - val iosMain by getting - val iosTest by getting - val iosSimMain by getting { dependsOn(iosMain) } - val iosSimTest by getting { dependsOn(iosTest) } } } diff --git a/redux-kotlin-threadsafe/build.gradle.kts b/redux-kotlin-threadsafe/build.gradle.kts index c70b295..4cd4b30 100644 --- a/redux-kotlin-threadsafe/build.gradle.kts +++ b/redux-kotlin-threadsafe/build.gradle.kts @@ -1,111 +1,116 @@ plugins { - java - kotlin("multiplatform") - id("kotlinx-atomicfu") + java + kotlin("multiplatform") + id("kotlinx-atomicfu") } repositories { - maven("https://dl.bintray.com/spekframework/spek-dev") + maven("https://dl.bintray.com/spekframework/spek-dev") } kotlin { - jvm() - js(BOTH) { - browser() - nodejs() +// androidNativeArm32() +// androidNativeArm64() +// iosArm32() + iosArm64() + iosX64() + js(BOTH) { + browser() + nodejs() - listOf(compilations["main"], compilations["test"]).forEach { - with(it.kotlinOptions) { - moduleKind = "umd" - sourceMap = true - sourceMapEmbedSources = "always" - metaInfo = true - } + listOf(compilations["main"], compilations["test"]).forEach { + with(it.kotlinOptions) { + moduleKind = "umd" + sourceMap = true + sourceMapEmbedSources = "always" + metaInfo = true + } + } } - } + jvm() + linuxX64() + macosX64() + mingwX64() + mingwX86() + tvosArm64() + tvosX64() + watchosArm32() + watchosArm64() + watchosX86() - iosArm64("ios") - iosX64("iosSim") - macosX64("macos") - mingwX64("win") - //below are currently not supported by atomicfu - //wasm32("wasm") - //linuxArm32Hfp("linArm32") - //linuxMips32("linMips32") - //linuxMipsel32("linMipsel32") - linuxX64("lin64") + //below are currently not supported by atomicfu + //wasm32("wasm") + //linuxArm32Hfp("linArm32") + //linuxMips32("linMips32") + //linuxMipsel32("linMipsel32") + //linuxArm64() - sourceSets { - commonMain { - dependencies { - api(project(":redux-kotlin")) - } - } - commonTest { - dependencies { - implementation(kotlin("test-common")) - implementation(kotlin("test-annotations-common")) - implementation(Libs.spek_dsl_metadata) - implementation(Libs.atrium_cc_en_gb_robstoll_common) - implementation(Libs.mockk_common) - implementation(Libs.kotlin_coroutines) - } - } - val jvmTest by getting { - dependencies { - implementation(kotlin("test")) - implementation(kotlin("test-junit")) - implementation(Libs.kotlin_coroutines_test) - implementation(Libs.kotlin_coroutines_jvm) - implementation(Libs.spek_dsl_jvm) - implementation(Libs.atrium_cc_en_gb_robstoll) - implementation(Libs.mockk) + sourceSets { + commonMain { + dependencies { + api(project(":redux-kotlin")) + } + } + commonTest { + dependencies { + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + implementation(Libs.spek_dsl_metadata) + implementation(Libs.atrium_cc_en_gb_robstoll_common) + implementation(Libs.mockk_common) + implementation(Libs.kotlinx_coroutines_core) + } + } + val jvmTest by getting { + dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-junit")) + implementation(Libs.kotlinx_coroutines_test) + implementation(Libs.kotlinx_coroutines_core_jvm) + implementation(Libs.spek_dsl_jvm) + implementation(Libs.atrium_cc_en_gb_robstoll) + implementation(Libs.mockk) - runtimeOnly(Libs.spek_runner_junit5) - runtimeOnly(Libs.kotlin_reflect) + runtimeOnly(Libs.spek_runner_junit5) + runtimeOnly(Libs.kotlin_reflect) - } - } - val jsTest by getting { - dependencies { - implementation(kotlin("test-js")) - implementation(kotlin("stdlib-js")) - } + } + } + val jsTest by getting { + dependencies { + implementation(kotlin("test-js")) + implementation(kotlin("stdlib-js")) + } + } } - - val iosMain by getting - val iosTest by getting - val iosSimMain by getting { dependsOn(iosMain) } - val iosSimTest by getting { dependsOn(iosTest) } - } } afterEvaluate { - tasks { - val jvmTest by getting(Test::class) { - useJUnitPlatform { - includeEngines("spek2") - } - } + tasks { + val jvmTest by getting(Test::class) { + useJUnitPlatform { + includeEngines("spek2") + } + } - // Alias the task names we use elsewhere to the new task names. - create("installMP").dependsOn("publishKotlinMultiplatformPublicationToMavenLocal") - create("installLocally") { - dependsOn("publishKotlinMultiplatformPublicationToTestRepository") - dependsOn("publishJvmPublicationToTestRepository") - dependsOn("publishJsPublicationToTestRepository") - dependsOn("publishMetadataPublicationToTestRepository") - } - create("installIosLocally") { - dependsOn("publishKotlinMultiplatformPublicationToTestRepository") - dependsOn("publishIosArm32PublicationToTestRepository") - dependsOn("publishIosArm64PublicationToTestRepository") - dependsOn("publishIosX64PublicationToTestRepository") - dependsOn("publishMetadataPublicationToTestRepository") + // Alias the task names we use elsewhere to the new task names. + create("installMP").dependsOn("publishKotlinMultiplatformPublicationToMavenLocal") + create("installLocally") { + dependsOn("publishKotlinMultiplatformPublicationToTestRepository") + dependsOn("publishJvmPublicationToTestRepository") + dependsOn("publishJsPublicationToTestRepository") + dependsOn("publishMetadataPublicationToTestRepository") + } + create("installIosLocally") { + dependsOn("publishKotlinMultiplatformPublicationToTestRepository") + dependsOn("publishIosArm32PublicationToTestRepository") + dependsOn("publishIosArm64PublicationToTestRepository") + dependsOn("publishIosX64PublicationToTestRepository") + dependsOn("publishMetadataPublicationToTestRepository") + } + // NOTE: We do not alias uploadArchives because CI runs it on Linux and we only want to run it on Mac OS. + //tasks.create("uploadArchives").dependsOn("publishKotlinMultiplatformPublicationToMavenRepository") } - // NOTE: We do not alias uploadArchives because CI runs it on Linux and we only want to run it on Mac OS. - //tasks.create("uploadArchives").dependsOn("publishKotlinMultiplatformPublicationToMavenRepository") - } } apply(from = rootProject.file("gradle/publish.gradle")) \ No newline at end of file diff --git a/redux-kotlin/build.gradle.kts b/redux-kotlin/build.gradle.kts index 2e8d47d..1f8129f 100644 --- a/redux-kotlin/build.gradle.kts +++ b/redux-kotlin/build.gradle.kts @@ -1,121 +1,134 @@ plugins { - java - kotlin("multiplatform") + java + kotlin("multiplatform") } repositories { - maven("https://dl.bintray.com/spekframework/spek-dev") + maven("https://dl.bintray.com/spekframework/spek-dev") } kotlin { - jvm() - js(BOTH) { - browser() - nodejs() + androidNativeArm32() + androidNativeArm64() + iosArm32() + iosArm64() + iosX64() + js(BOTH) { + browser() + nodejs() - listOf(compilations["main"], compilations["test"]).forEach { - with(it.kotlinOptions) { - moduleKind = "umd" - sourceMap = true - sourceMapEmbedSources = "always" - metaInfo = true - } + listOf(compilations["main"], compilations["test"]).forEach { + with(it.kotlinOptions) { + moduleKind = "umd" + sourceMap = true + sourceMapEmbedSources = "always" + metaInfo = true + } + } } - } + jvm() + linuxArm32Hfp() + linuxArm64() + linuxMips32() + linuxMipsel32() + linuxX64() + macosX64() + mingwX64() + mingwX86() + tvosArm64() + tvosX64() + wasm32() + watchosArm32() + watchosArm64() + watchosX86() - iosArm64("ios") - iosX64("iosSim") - macosX64("macos") - mingwX64("win") - wasm32("wasm") - linuxArm32Hfp("linArm32") - linuxMips32("linMips32") - linuxMipsel32("linMipsel32") - linuxX64("lin64") + sourceSets { + commonTest { + dependencies { + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + implementation(Libs.spek_dsl_metadata) + implementation(Libs.atrium_cc_en_gb_robstoll_common) + implementation(Libs.mockk_common) + } + } - sourceSets { - commonTest { - dependencies { - implementation(kotlin("test-common")) - implementation(kotlin("test-annotations-common")) - implementation(Libs.spek_dsl_metadata) - implementation(Libs.atrium_cc_en_gb_robstoll_common) - implementation(Libs.mockk_common) - } - } - val jvmTest by getting { - dependencies { - implementation(kotlin("test")) - implementation(kotlin("test-junit")) - implementation(Libs.kotlin_coroutines_test) - implementation(Libs.kotlin_coroutines_jvm) - implementation(Libs.spek_dsl_jvm) - implementation(Libs.atrium_cc_en_gb_robstoll) - implementation(Libs.mockk) + val fallback: (org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet.() -> Unit) = { + kotlin.srcDir("src/fallbackMain") + } + val ios: (org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet.() -> Unit) = { + kotlin.srcDir("src/iosMain") + } + val androidNativeArm32Main by getting(fallback) + val androidNativeArm64Main by getting(fallback) + val iosArm32Main by getting(ios) + val iosArm32Test by getting(ios) + val iosArm64Main by getting(ios) + val iosArm64Test by getting(ios) + val tvosArm64Main by getting(ios) + val tvosX64Main by getting(ios) + val watchosArm32Main by getting(ios) + val watchosArm64Main by getting(ios) + val watchosX86Main by getting(ios) + val iosX64Main by getting { dependsOn(iosArm32Main) } + val iosX64Test by getting { dependsOn(iosArm32Test) } + val linuxArm32HfpMain by getting(fallback) + val linuxArm64Main by getting(fallback) + val linuxMips32Main by getting(fallback) + val linuxMipsel32Main by getting(fallback) + val linuxX64Main by getting(fallback) + val jsTest by getting { + dependencies { + implementation(kotlin("test-js")) + } + } + val jvmTest by getting { + dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-junit")) + implementation(Libs.kotlinx_coroutines_test) + implementation(Libs.kotlinx_coroutines_core_jvm) + implementation(Libs.spek_dsl_jvm) + implementation(Libs.atrium_cc_en_gb_robstoll) + implementation(Libs.mockk) - runtimeOnly(Libs.spek_runner_junit5) - runtimeOnly(Libs.kotlin_reflect) - } - } - val jsTest by getting { - dependencies { - implementation(kotlin("test-js")) - } - } - val winMain by getting { - kotlin.srcDir("src/fallbackMain") - } - val wasmMain by getting { - kotlin.srcDir("src/fallbackMain") - } - val linArm32Main by getting { - kotlin.srcDir("src/fallbackMain") - } - val linMips32Main by getting { - kotlin.srcDir("src/fallbackMain") + runtimeOnly(Libs.spek_runner_junit5) + runtimeOnly(Libs.kotlin_reflect) + } + } + val mingwX64Main by getting(fallback) + val mingwX86Main by getting(fallback) + val wasm32Main by getting(fallback) } - val linMipsel32Main by getting { - kotlin.srcDir("src/fallbackMain") - } - val lin64Main by getting { - kotlin.srcDir("src/fallbackMain") - } - - val iosMain by getting - val iosTest by getting - val iosSimMain by getting { dependsOn(iosMain) } - val iosSimTest by getting { dependsOn(iosTest) } - } } - afterEvaluate { - tasks { - val jvmTest by getting(Test::class) { - useJUnitPlatform { - includeEngines("spek2") - } - } + tasks { + val jvmTest by getting(Test::class) { + useJUnitPlatform { + includeEngines("spek2") + } + } - // Alias the task names we use elsewhere to the new task names. - create("installMP").dependsOn("publishKotlinMultiplatformPublicationToMavenLocal") - create("installLocally") { - dependsOn("publishKotlinMultiplatformPublicationToTestRepository") - dependsOn("publishJvmPublicationToTestRepository") - dependsOn("publishJsPublicationToTestRepository") - dependsOn("publishMetadataPublicationToTestRepository") - } - create("installIosLocally") { - dependsOn("publishKotlinMultiplatformPublicationToTestRepository") - dependsOn("publishIosArm32PublicationToTestRepository") - dependsOn("publishIosArm64PublicationToTestRepository") - dependsOn("publishIosX64PublicationToTestRepository") - dependsOn("publishMetadataPublicationToTestRepository") + // Alias the task names we use elsewhere to the new task names. + create("installMP").dependsOn("publishKotlinMultiplatformPublicationToMavenLocal") + create("installLocally") { + dependsOn("publishKotlinMultiplatformPublicationToTestRepository") + dependsOn("publishJvmPublicationToTestRepository") + dependsOn("publishJsPublicationToTestRepository") + dependsOn("publishMetadataPublicationToTestRepository") + } + create("installIosLocally") { + dependsOn("publishKotlinMultiplatformPublicationToTestRepository") + dependsOn("publishIosArm32PublicationToTestRepository") + dependsOn("publishIosArm64PublicationToTestRepository") + dependsOn("publishIosX64PublicationToTestRepository") + dependsOn("publishMetadataPublicationToTestRepository") + } + // NOTE: We do not alias uploadArchives because CI runs it on Linux and we only want to run it on Mac OS. + //tasks.create("uploadArchives").dependsOn("publishKotlinMultiplatformPublicationToMavenRepository") } - // NOTE: We do not alias uploadArchives because CI runs it on Linux and we only want to run it on Mac OS. - //tasks.create("uploadArchives").dependsOn("publishKotlinMultiplatformPublicationToMavenRepository") - } } apply(from = rootProject.file("gradle/publish.gradle")) diff --git a/redux-kotlin/src/macosMain/kotlin/org/reduxkotlin/utils/ThreadUtilMacOs.kt b/redux-kotlin/src/macosX64Main/kotlin/org/reduxkotlin/utils/ThreadUtilMacOs.kt similarity index 100% rename from redux-kotlin/src/macosMain/kotlin/org/reduxkotlin/utils/ThreadUtilMacOs.kt rename to redux-kotlin/src/macosX64Main/kotlin/org/reduxkotlin/utils/ThreadUtilMacOs.kt From ad73c51dde2da4ae5c2b6299eb614f806045d8ac Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Sun, 2 Aug 2020 20:52:46 -0400 Subject: [PATCH 12/19] bump version to 0.5.5 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 8082345..cc7642a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,7 +23,7 @@ kotlin.native.ignoreDisabledTargets=true kotlin.mpp.enableGranularSourceSetsMetadata=true GROUP=org.reduxkotlin -VERSION_NAME=0.5.4 +VERSION_NAME=0.5.5 POM_ARTIFACT_ID=reduxkotlin POM_DESCRIPTION=Redux implementation for Kotlin. Mulitiplatform supported. From f4fe0777b35700f08383865a7bcd5942c8324f7e Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Sun, 2 Aug 2020 20:53:19 -0400 Subject: [PATCH 13/19] disable mingwX86 for redux-kotlin-threadsafe --- redux-kotlin-threadsafe/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redux-kotlin-threadsafe/build.gradle.kts b/redux-kotlin-threadsafe/build.gradle.kts index 4cd4b30..aeef615 100644 --- a/redux-kotlin-threadsafe/build.gradle.kts +++ b/redux-kotlin-threadsafe/build.gradle.kts @@ -30,7 +30,7 @@ kotlin { linuxX64() macosX64() mingwX64() - mingwX86() +// mingwX86() tvosArm64() tvosX64() watchosArm32() From d8b6a81f0d585ebfe86cd0167449815a2e7223d9 Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Thu, 6 Aug 2020 08:47:06 -0400 Subject: [PATCH 14/19] remove spek and atrium assert lib. --- build.gradle.kts | 1 - buildSrc/src/main/kotlin/Libs.kt | 21 -- buildSrc/src/main/kotlin/Versions.kt | 5 - examples/counter/android/build.gradle.kts | 1 - examples/counter/common/build.gradle.kts | 20 -- .../examples/counter/ReducerTest.kt | 34 ++- examples/todos/android/build.gradle.kts | 1 - examples/todos/common/build.gradle.kts | 20 +- .../examples/todos/TodosReducerSpec.kt | 154 ++++++------ redux-kotlin-threadsafe/build.gradle.kts | 16 -- .../util/CreateThreadSafeStoreSpec.kt | 48 ++-- redux-kotlin/build.gradle.kts | 34 +-- .../org/reduxkotlin/ApplyMiddlewareTest.kt | 103 ++++---- .../kotlin/org/reduxkotlin/CreateStoreSpec.kt | 194 +++++++-------- .../util/CreateSameThreadEnforcedStoreSpec.kt | 228 +++++++++--------- 15 files changed, 389 insertions(+), 491 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d245f60..5c3eb6d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,7 +26,6 @@ allprojects { jcenter() maven("https://kotlin.bintray.com/kotlinx") maven("https://oss.sonatype.org/content/repositories/snapshots") - maven("https://dl.bintray.com/spekframework/spek-dev") mavenCentral() } diff --git a/buildSrc/src/main/kotlin/Libs.kt b/buildSrc/src/main/kotlin/Libs.kt index 0253863..b131fe6 100644 --- a/buildSrc/src/main/kotlin/Libs.kt +++ b/buildSrc/src/main/kotlin/Libs.kt @@ -23,18 +23,6 @@ object Libs { */ const val recyclerview: String = "androidx.recyclerview:recyclerview:" + Versions.recyclerview - /** - * https://github.com/robstoll/atrium - */ - const val atrium_cc_en_gb_robstoll_common: String = - "ch.tutteli.atrium:atrium-cc-en_GB-robstoll-common:" + Versions.ch_tutteli_atrium - - /** - * https://github.com/robstoll/atrium - */ - const val atrium_cc_en_gb_robstoll: String = "ch.tutteli.atrium:atrium-cc-en_GB-robstoll:" + - Versions.ch_tutteli_atrium - /** * https://developer.android.com/studio */ @@ -192,13 +180,4 @@ object Libs { */ const val kotlinx_coroutines_test: String = "org.jetbrains.kotlinx:kotlinx-coroutines-test:" + Versions.kotlinx_coroutines_test - - const val spek_dsl_jvm: String = "org.spekframework.spek2:spek-dsl-jvm:" + - Versions.org_spekframework_spek2 - - const val spek_dsl_metadata: String = "org.spekframework.spek2:spek-dsl-metadata:" + - Versions.org_spekframework_spek2 - - const val spek_runner_junit5: String = "org.spekframework.spek2:spek-runner-junit5:" + - Versions.org_spekframework_spek2 } diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index a2370ee..76c4e13 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -18,8 +18,6 @@ object Versions { const val recyclerview: String = "1.0.0" // available: "1.1.0" - const val ch_tutteli_atrium: String = "0.9.2" // available: "0.12.0" - const val aapt2: String = "3.6.0-6040484" // available: "4.0.1-6197926" const val com_android_tools_build_gradle: String = "3.6.0" // available: "4.0.1" @@ -44,9 +42,6 @@ object Versions { const val kotlinx_coroutines_test: String = "1.3.8-1.4.0-rc" - const val org_spekframework_spek2: String = "2.1.0-alpha.0.11+d97ef33" - // available: "2.1.0-alpha.0.24+0fdeb6e" - /** * * See issue 19: How to update Gradle itself? diff --git a/examples/counter/android/build.gradle.kts b/examples/counter/android/build.gradle.kts index 39ab5d9..3f40e81 100644 --- a/examples/counter/android/build.gradle.kts +++ b/examples/counter/android/build.gradle.kts @@ -34,7 +34,6 @@ android { } } - dependencies { implementation(Libs.kotlin_stdlib_jdk8) implementation(Libs.appcompat) diff --git a/examples/counter/common/build.gradle.kts b/examples/counter/common/build.gradle.kts index eadf568..cdb600f 100644 --- a/examples/counter/common/build.gradle.kts +++ b/examples/counter/common/build.gradle.kts @@ -3,10 +3,6 @@ plugins { kotlin("multiplatform") } -repositories { - maven("https://dl.bintray.com/spekframework/spek-dev") -} - kotlin { jvm() js(IR) { @@ -33,12 +29,9 @@ kotlin { } } commonTest { - kotlin.srcDir("src/test/kotlin") dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) - implementation("org.spekframework.spek2:spek-dsl-metadata:${Versions.org_spekframework_spek2}") - implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll-common:${Versions.org_spekframework_spek2}") implementation("io.mockk:mockk-common:${Versions.io_mockk}") } } @@ -46,11 +39,6 @@ kotlin { dependencies { implementation(kotlin("test")) implementation(kotlin("test-junit")) - implementation("org.spekframework.spek2:spek-dsl-jvm:${Versions.org_spekframework_spek2}") - implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll:${Versions.ch_tutteli_atrium}") - implementation("io.mockk:mockk:${Versions.ch_tutteli_atrium}") - - runtimeOnly("org.spekframework.spek2:spek-runner-junit5:${Versions.org_spekframework_spek2}") runtimeOnly("org.jetbrains.kotlin:kotlin-reflect") } } @@ -62,11 +50,3 @@ kotlin { } } } - -tasks { - val jvmTest by getting(Test::class) { - useJUnitPlatform { - includeEngines("spek2") - } - } -} diff --git a/examples/counter/common/src/test/kotlin/org/reduxkotlin/examples/counter/ReducerTest.kt b/examples/counter/common/src/test/kotlin/org/reduxkotlin/examples/counter/ReducerTest.kt index 3d1c5f8..ce9188d 100644 --- a/examples/counter/common/src/test/kotlin/org/reduxkotlin/examples/counter/ReducerTest.kt +++ b/examples/counter/common/src/test/kotlin/org/reduxkotlin/examples/counter/ReducerTest.kt @@ -1,26 +1,22 @@ package org.reduxkotlin.examples.counter -import ch.tutteli.atrium.api.cc.en_GB.toBe -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe -import ch.tutteli.atrium.verbs.expect +import kotlin.test.Test +import kotlin.test.expect +class CounterTest { -object CounterSpek : Spek({ - - describe("reducers") { - describe("counter") { - it("should handle INCREMENT action") { - expect(reducer(1, Increment())).toBe(2) - } + @Test + fun shouldHandleINCREMENTAction() { + expect(2) { reducer(1, Increment()) } + } - it("should handle DECREMENT action") { - expect(reducer(1, Decrement())).toBe(0) - } + @Test + fun shouldHandleDECREMENTAction() { + expect(0) { reducer(1, Decrement()) } + } - it("should ignore unknown actions") { - expect(reducer(1, Any())).toBe(1) - } - } + @Test + fun shouldIgnoreUnknownActions() { + expect(1) { reducer(1, Any()) } } -}) +} diff --git a/examples/todos/android/build.gradle.kts b/examples/todos/android/build.gradle.kts index f53d36b..7a4b5b0 100644 --- a/examples/todos/android/build.gradle.kts +++ b/examples/todos/android/build.gradle.kts @@ -35,7 +35,6 @@ android { } } - dependencies { implementation(Libs.kotlin_stdlib_jdk8) implementation(Libs.appcompat) diff --git a/examples/todos/common/build.gradle.kts b/examples/todos/common/build.gradle.kts index 80ab576..f449f9b 100644 --- a/examples/todos/common/build.gradle.kts +++ b/examples/todos/common/build.gradle.kts @@ -3,10 +3,6 @@ plugins { kotlin("multiplatform") } -repositories { - maven("https://dl.bintray.com/spekframework/spek-dev") -} - kotlin { iosArm32() iosArm64() @@ -29,16 +25,13 @@ kotlin { sourceSets { commonMain { dependencies { - implementation(project(":redux-kotlin-threadsafe")) + implementation(project(":redux-kotlin")) } } commonTest { - kotlin.srcDir("src/test/kotlin") dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) - implementation("org.spekframework.spek2:spek-dsl-metadata:${Versions.org_spekframework_spek2}") - implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll-common:${Versions.ch_tutteli_atrium}") implementation("io.mockk:mockk-common:${Versions.io_mockk}") } } @@ -46,11 +39,8 @@ kotlin { dependencies { implementation(kotlin("test")) implementation(kotlin("test-junit")) - implementation("org.spekframework.spek2:spek-dsl-jvm:${Versions.org_spekframework_spek2}") - implementation("ch.tutteli.atrium:atrium-cc-en_GB-robstoll:${Versions.ch_tutteli_atrium}") implementation("io.mockk:mockk:${Versions.io_mockk}") - runtimeOnly("org.spekframework.spek2:spek-runner-junit5:${Versions.org_spekframework_spek2}") runtimeOnly("org.jetbrains.kotlin:kotlin-reflect") } } @@ -62,11 +52,3 @@ kotlin { } } } - -tasks { - val jvmTest by getting(Test::class) { - useJUnitPlatform { - includeEngines("spek2") - } - } -} diff --git a/examples/todos/common/src/test/kotlin/org/reduxkotlin/examples/todos/TodosReducerSpec.kt b/examples/todos/common/src/test/kotlin/org/reduxkotlin/examples/todos/TodosReducerSpec.kt index c0255ac..cdf3a6a 100644 --- a/examples/todos/common/src/test/kotlin/org/reduxkotlin/examples/todos/TodosReducerSpec.kt +++ b/examples/todos/common/src/test/kotlin/org/reduxkotlin/examples/todos/TodosReducerSpec.kt @@ -1,72 +1,53 @@ package org.reduxkotlin.examples.todos -import ch.tutteli.atrium.api.cc.en_GB.toBe -import ch.tutteli.atrium.verbs.expect -import io.mockk.impl.log.Logger -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe +import kotlin.test.Test +import kotlin.test.assertEquals -object TodosReducerSpec : Spek({ - describe("todos reducer") { - it("should handle AddToDo") { - expect( - todosReducer( - emptyList(), - AddTodo(text = "Run the tests") - ) - ).toBe( - listOf( - Todo( - text = "Run the tests", - completed = false, - id = 0 - ) +class TodosReducerSpec { + + @Test + fun shouldHandleAddToDo() { + assertEquals( + todosReducer( + emptyList(), + AddTodo(text = "Run the tests") + ), + listOf( + Todo( + text = "Run the tests", + completed = false, + id = 0 ) ) + ) - expect( - todosReducer( - listOf( - Todo( - text = "Run the tests", - completed = false, - id = 0 - ) - ), - AddTodo(text = "Use Redux") - ) - ).toBe( + assertEquals( + todosReducer( listOf( Todo( text = "Run the tests", completed = false, id = 0 - ), - Todo( - text = "Use Redux", - completed = false, - id = 1 ) + ), + AddTodo(text = "Use Redux") + ), + listOf( + Todo( + text = "Run the tests", + completed = false, + id = 0 + ), + Todo( + text = "Use Redux", + completed = false, + id = 1 ) ) + ) - expect( - todosReducer( - listOf( - Todo( - text = "Run the tests", - completed = false, - id = 0 - ), - Todo( - text = "Use Redux", - completed = false, - id = 1 - ) - ), - AddTodo(text = "Fix the tests") - ) - ).toBe( + assertEquals( + todosReducer( listOf( Todo( text = "Run the tests", @@ -77,37 +58,38 @@ object TodosReducerSpec : Spek({ text = "Use Redux", completed = false, id = 1 - ), - Todo( - text = "Fix the tests", - completed = false, - id = 2 ) + ), + AddTodo(text = "Fix the tests") + ), + listOf( + Todo( + text = "Run the tests", + completed = false, + id = 0 + ), + Todo( + text = "Use Redux", + completed = false, + id = 1 + ), + Todo( + text = "Fix the tests", + completed = false, + id = 2 ) ) - } + ) + } - it("should handle ToggleTodo") { - expect( - todosReducer( - listOf( - Todo( - text = "Run the tests", - completed = false, - id = 0 - ), - Todo( - text = "Use Redux", - completed = false, - id = 1 - ) - ), ToggleTodo(index = 0) - ) - ).toBe( + @Test + fun shouldHandleToggleTodo() { + assertEquals( + todosReducer( listOf( Todo( text = "Run the tests", - completed = true, + completed = false, id = 0 ), Todo( @@ -115,8 +97,20 @@ object TodosReducerSpec : Spek({ completed = false, id = 1 ) + ), ToggleTodo(index = 0) + ), + listOf( + Todo( + text = "Run the tests", + completed = true, + id = 0 + ), + Todo( + text = "Use Redux", + completed = false, + id = 1 ) ) - } + ) } -}) +} diff --git a/redux-kotlin-threadsafe/build.gradle.kts b/redux-kotlin-threadsafe/build.gradle.kts index aeef615..046f0db 100644 --- a/redux-kotlin-threadsafe/build.gradle.kts +++ b/redux-kotlin-threadsafe/build.gradle.kts @@ -3,9 +3,6 @@ plugins { kotlin("multiplatform") id("kotlinx-atomicfu") } -repositories { - maven("https://dl.bintray.com/spekframework/spek-dev") -} kotlin { // androidNativeArm32() @@ -54,8 +51,6 @@ kotlin { dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) - implementation(Libs.spek_dsl_metadata) - implementation(Libs.atrium_cc_en_gb_robstoll_common) implementation(Libs.mockk_common) implementation(Libs.kotlinx_coroutines_core) } @@ -66,13 +61,9 @@ kotlin { implementation(kotlin("test-junit")) implementation(Libs.kotlinx_coroutines_test) implementation(Libs.kotlinx_coroutines_core_jvm) - implementation(Libs.spek_dsl_jvm) - implementation(Libs.atrium_cc_en_gb_robstoll) implementation(Libs.mockk) - runtimeOnly(Libs.spek_runner_junit5) runtimeOnly(Libs.kotlin_reflect) - } } val jsTest by getting { @@ -84,15 +75,8 @@ kotlin { } } - afterEvaluate { tasks { - val jvmTest by getting(Test::class) { - useJUnitPlatform { - includeEngines("spek2") - } - } - // Alias the task names we use elsewhere to the new task names. create("installMP").dependsOn("publishKotlinMultiplatformPublicationToMavenLocal") create("installLocally") { diff --git a/redux-kotlin-threadsafe/src/jvmTest/kotlin/org/reduxkotlin/util/CreateThreadSafeStoreSpec.kt b/redux-kotlin-threadsafe/src/jvmTest/kotlin/org/reduxkotlin/util/CreateThreadSafeStoreSpec.kt index 391ffa4..6b816f5 100644 --- a/redux-kotlin-threadsafe/src/jvmTest/kotlin/org/reduxkotlin/util/CreateThreadSafeStoreSpec.kt +++ b/redux-kotlin-threadsafe/src/jvmTest/kotlin/org/reduxkotlin/util/CreateThreadSafeStoreSpec.kt @@ -1,44 +1,42 @@ package org.reduxkotlin.util import kotlinx.coroutines.* +import org.junit.Test import org.reduxkotlin.createThreadSafeStore -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe import kotlin.system.measureTimeMillis import kotlin.test.assertEquals -object MultiThreadedSpec : Spek({ - describe("createStore") { - it("multithreaded increments massively") { - suspend fun massiveRun(action: suspend () -> Unit) { - val n = 100 // number of coroutines to launch - val k = 1000 // times an action is repeated by each coroutine - val time = measureTimeMillis { - coroutineScope { - // scope for coroutines - repeat(n) { - launch { - repeat(k) { action() } - } +class MultiThreadedClass { + @Test + fun multithreadedIncrementsMassively() { + suspend fun massiveRun(action: suspend () -> Unit) { + val n = 100 // number of coroutines to launch + val k = 1000 // times an action is repeated by each coroutine + val time = measureTimeMillis { + coroutineScope { + // scope for coroutines + repeat(n) { + launch { + repeat(k) { action() } } } } - println("Completed ${n * k} actions in $time ms") } + println("Completed ${n * k} actions in $time ms") + } - //NOTE: changing this to createStore() breaks the tests - val store = createThreadSafeStore(counterReducer, TestCounterState()) - runBlocking { - withContext(Dispatchers.Default) { - massiveRun { - store.dispatch(Increment()) - } + //NOTE: changing this to createStore() breaks the tests + val store = createThreadSafeStore(counterReducer, TestCounterState()) + runBlocking { + withContext(Dispatchers.Default) { + massiveRun { + store.dispatch(Increment()) } - assertEquals(100000, store.state.counter) } + assertEquals(100000, store.state.counter) } } -}) +} class Increment diff --git a/redux-kotlin/build.gradle.kts b/redux-kotlin/build.gradle.kts index 1f8129f..7ca0eed 100644 --- a/redux-kotlin/build.gradle.kts +++ b/redux-kotlin/build.gradle.kts @@ -3,11 +3,6 @@ plugins { kotlin("multiplatform") } -repositories { - maven("https://dl.bintray.com/spekframework/spek-dev") -} - - kotlin { androidNativeArm32() androidNativeArm64() @@ -48,8 +43,6 @@ kotlin { dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) - implementation(Libs.spek_dsl_metadata) - implementation(Libs.atrium_cc_en_gb_robstoll_common) implementation(Libs.mockk_common) } } @@ -58,21 +51,16 @@ kotlin { kotlin.srcDir("src/fallbackMain") } val ios: (org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet.() -> Unit) = { - kotlin.srcDir("src/iosMain") + kotlin.srcDir("src/iosMain/kotlin") } + val androidNativeArm32Main by getting(fallback) val androidNativeArm64Main by getting(fallback) val iosArm32Main by getting(ios) val iosArm32Test by getting(ios) val iosArm64Main by getting(ios) val iosArm64Test by getting(ios) - val tvosArm64Main by getting(ios) - val tvosX64Main by getting(ios) - val watchosArm32Main by getting(ios) - val watchosArm64Main by getting(ios) - val watchosX86Main by getting(ios) - val iosX64Main by getting { dependsOn(iosArm32Main) } - val iosX64Test by getting { dependsOn(iosArm32Test) } + val iosX64Main by getting(ios) val linuxArm32HfpMain by getting(fallback) val linuxArm64Main by getting(fallback) val linuxMips32Main by getting(fallback) @@ -89,28 +77,24 @@ kotlin { implementation(kotlin("test-junit")) implementation(Libs.kotlinx_coroutines_test) implementation(Libs.kotlinx_coroutines_core_jvm) - implementation(Libs.spek_dsl_jvm) - implementation(Libs.atrium_cc_en_gb_robstoll) implementation(Libs.mockk) - - runtimeOnly(Libs.spek_runner_junit5) runtimeOnly(Libs.kotlin_reflect) } } + val mingwX64Main by getting(fallback) val mingwX86Main by getting(fallback) + val tvosArm64Main by getting(ios) + val tvosX64Main by getting(ios) val wasm32Main by getting(fallback) + val watchosArm32Main by getting(ios) + val watchosArm64Main by getting(ios) + val watchosX86Main by getting(ios) } } afterEvaluate { tasks { - val jvmTest by getting(Test::class) { - useJUnitPlatform { - includeEngines("spek2") - } - } - // Alias the task names we use elsewhere to the new task names. create("installMP").dependsOn("publishKotlinMultiplatformPublicationToMavenLocal") create("installLocally") { diff --git a/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt b/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt index 04a014d..32509f4 100644 --- a/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt +++ b/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt @@ -1,61 +1,56 @@ package org.reduxkotlin -import ch.tutteli.atrium.api.cc.en_GB.toThrow -import ch.tutteli.atrium.verbs.expect -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe - - -object ApplyMiddlewareSpec : Spek({ - describe("applyMiddleware") { - it("warns when dispatching during middleware setup") { - fun dispatchingMiddleware(store: Store): (next: Dispatcher) -> (action: Any) -> Any { - store.dispatch(AddTodo("1", "Dont dispatch in middleware setup")) - return { next -> - { action -> - { - next(action) - } +import kotlin.test.assertFails +import kotlin.test.* + +class ApplyMiddlewareSpec { + @Test + fun warnsWhenDispatchingDuringMiddlewareSetup() { + fun dispatchingMiddleware(store: Store): (next: Dispatcher) -> (action: Any) -> Any { + store.dispatch(AddTodo("1", "Dont dispatch in middleware setup")) + return { next -> + { action -> + { + next(action) } } } + } - expect { - val storeEnhancer: StoreEnhancer = applyMiddleware(::dispatchingMiddleware) - createStore(todos, TestState(), storeEnhancer) - }.toThrow {} + assertFails { + val storeEnhancer: StoreEnhancer = applyMiddleware(::dispatchingMiddleware) + createStore(todos, TestState(), storeEnhancer) } + } - /* - it("wraps dispatch method with middleware once") { - fun test(spyOnMethods) { - return methods => { - spyOnMethods(methods) - return next => action => next(action) - } + /* + it("wraps dispatch method with middleware once") { + fun test(spyOnMethods) { + return methods => { + spyOnMethods(methods) + return next => action => next(action) } + } - val spy = jest.fn() - val store = applyMiddleware (test(spy), thunk)(createStore)(reducers.todos) + val spy = jest.fn() + val store = applyMiddleware (test(spy), thunk)(createStore)(reducers.todos) + store.dispatch(AddTodo("Use Redux")) + store.dispatch(AddTodo("Flux FTW!")) - store.dispatch(AddTodo("Use Redux")) - store.dispatch(AddTodo("Flux FTW!")) + expect(spy.mock.calls.length).toBe(1) - expect(spy.mock.calls.length).toBe(1) + expect(spy.mock.calls[0][0]).toHaveProperty("getState") + expect(spy.mock.calls[0][0]).toHaveProperty("dispatch") - expect(spy.mock.calls[0][0]).toHaveProperty("getState") - expect(spy.mock.calls[0][0]).toHaveProperty("dispatch") + expect(store.getState()).toEqual([ + { id: 1, text: "Use Redux" }, + { id: 2, text: "Flux FTW!" } + ]) + }) - expect(store.getState()).toEqual([ - { id: 1, text: "Use Redux" }, - { id: 2, text: "Flux FTW!" } - ]) - }) + */ - */ - - } -}) +} /************** Test Reducer & actions - tobe moved into example app *********/ @@ -66,16 +61,16 @@ data class Todo(val id: String, val text: String, val completed: Boolean = false data class TestState(val todos: List = listOf()) val todos = { state: TestState, action: Any -> - when (action) { - is AddTodo -> state.copy(todos = state.todos.plus(Todo(action.id, action.text, false))) - is ToggleTodo -> state.copy(todos = state.todos.map { - if (it.id == action.id) { - it.copy(completed = !it.completed) - } else { - it - } - }) - else -> state - } + when (action) { + is AddTodo -> state.copy(todos = state.todos.plus(Todo(action.id, action.text, false))) + is ToggleTodo -> state.copy(todos = state.todos.map { + if (it.id == action.id) { + it.copy(completed = !it.completed) + } else { + it + } + }) + else -> state } +} diff --git a/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/CreateStoreSpec.kt b/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/CreateStoreSpec.kt index f63fe13..a778453 100644 --- a/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/CreateStoreSpec.kt +++ b/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/CreateStoreSpec.kt @@ -1,125 +1,127 @@ package org.reduxkotlin -import ch.tutteli.atrium.api.fluent.en_GB.toBe -import ch.tutteli.atrium.creating.Assert -import ch.tutteli.atrium.domain.builders.migration.asAssert -import ch.tutteli.atrium.domain.builders.migration.asExpect -import ch.tutteli.atrium.verbs.expect -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe +import kotlin.test.assertEquals +import kotlin.test.Test -object CreateStoreSpec : Spek({ - describe("createStore") { - it("passes the initial state") { - val store = createStore( - todos, TestState( - listOf( - Todo( - id = "1", - text = "Hello" - ) +class CreateStoreSpec { + @Test + fun passesTheInitialState() { + val store = createStore( + todos, TestState( + listOf( + Todo( + id = "1", + text = "Hello" ) ) ) + ) - expect(store.getState()).asExpect>().toBe( - TestState( - listOf( - Todo( - id = "1", - text = "Hello" - ) + assertEquals( + store.getState(), + TestState( + listOf( + Todo( + id = "1", + text = "Hello" ) ) - ).asAssert() - } - it("applies the reducer to the previous state") { - val store = createStore(todos, TestState()) - expect(store.getState()).asExpect>().toBe(TestState()).asAssert() + ) + ) + } + + @Test + fun appliesTheReducerToThePreviousState() { + val store = createStore(todos, TestState()) + assertEquals(store.getState(), TestState()) - store.dispatch(Any()) - expect(store.getState()).asExpect>().toBe(TestState()).asAssert() + store.dispatch(Any()) + assertEquals(store.getState(), TestState()) - store.dispatch(AddTodo("1", "Hello")) - expect(store.getState()).asExpect>().toBe( - TestState( - listOf( - Todo( - id = "1", - text = "Hello" - ) + store.dispatch(AddTodo("1", "Hello")) + assertEquals( + store.getState(), + TestState( + listOf( + Todo( + id = "1", + text = "Hello" ) ) - ).asAssert() + ) + ) - //TODO are ids autoincrement? - store.dispatch(AddTodo("2", "World")) - expect(store.getState()).asExpect>().toBe( - TestState( - listOf( - Todo( - id = "1", - text = "Hello" - ), - Todo( - id = "2", - text = "World" - ) + //TODO are ids autoincrement? + store.dispatch(AddTodo("2", "World")) + assertEquals( + store.getState(), + TestState( + listOf( + Todo( + id = "1", + text = "Hello" + ), + Todo( + id = "2", + text = "World" ) ) - ).asAssert() - } + ) + ) + } - it("applies the reducer to the initial state") { - val store = createStore( - todos, TestState( - listOf( - Todo( - id = "1", - text = "Hello" - ) + @Test + fun appliesTheReducerToTheInitialState() { + val store = createStore( + todos, TestState( + listOf( + Todo( + id = "1", + text = "Hello" ) ) ) - expect(store.getState()).asExpect>().toBe( - TestState( - listOf( - Todo( - id = "1", - text = "Hello" - ) + ) + assertEquals( + store.getState(), + TestState( + listOf( + Todo( + id = "1", + text = "Hello" ) ) - ).asAssert() + ) + ) - store.dispatch(Any()) - expect(store.getState()).asExpect>().toBe( - TestState( - listOf( - Todo( - id = "1", - text = "Hello" - ) + store.dispatch(Any()) + assertEquals( + store.getState(), + TestState( + listOf( + Todo( + id = "1", + text = "Hello" ) ) - ).asAssert() + ) + ) - store.dispatch(AddTodo("2", "World")) - expect(store.getState()).asExpect>().toBe( - TestState( - listOf( - Todo( - id = "1", - text = "Hello" - ), - Todo( - id = "2", - text = "World" - ) + store.dispatch(AddTodo("2", "World")) + assertEquals( + store.getState(), + TestState( + listOf( + Todo( + id = "1", + text = "Hello" + ), + Todo( + id = "2", + text = "World" ) ) - ).asAssert() - } - + ) + ) } -}) +} diff --git a/redux-kotlin/src/jvmTest/kotlin/org/reduxkotlin/util/CreateSameThreadEnforcedStoreSpec.kt b/redux-kotlin/src/jvmTest/kotlin/org/reduxkotlin/util/CreateSameThreadEnforcedStoreSpec.kt index ff3e4ec..deab5ff 100644 --- a/redux-kotlin/src/jvmTest/kotlin/org/reduxkotlin/util/CreateSameThreadEnforcedStoreSpec.kt +++ b/redux-kotlin/src/jvmTest/kotlin/org/reduxkotlin/util/CreateSameThreadEnforcedStoreSpec.kt @@ -5,20 +5,21 @@ import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.flow import kotlinx.coroutines.test.setMain import org.reduxkotlin.* -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe import java.util.concurrent.CountDownLatch import java.util.concurrent.Executors import kotlin.IllegalStateException import kotlin.system.measureTimeMillis import kotlin.test.* -object CreateSameThreadEnforcedStoreSpec : Spek({ - val mainThreadSurrogate = Executors.newSingleThreadExecutor().asCoroutineDispatcher() - Dispatchers.setMain(mainThreadSurrogate) +class CreateSameThreadEnforcedStoreSpec { + lateinit var store: Store - describe("createStore") { - val store = createSameThreadEnforcedStore( + @BeforeTest + fun before() { + val mainThreadSurrogate = Executors.newSingleThreadExecutor().asCoroutineDispatcher() + Dispatchers.setMain(mainThreadSurrogate) + + store = createSameThreadEnforcedStore( todos, TestState( listOf( Todo( @@ -28,132 +29,143 @@ object CreateSameThreadEnforcedStoreSpec : Spek({ ) ) ) + } - it("ensure same thread on getState") { - ensureSameThread { store.getState() } - } - it("ensure same thread on dispatch") { - ensureSameThread { store.dispatch(Any()) } - } - it("ensure same thread on replaceReducer") { - ensureSameThread { store.replaceReducer { state, action -> state } } - } - it("ensure same thread on subscribe") { - ensureSameThread { store.subscribe { } } - } - it("enforces same thread when thread name appends coroutine name") { - val middleware = TestMiddleware() - - runBlocking { - CoroutineScope(Dispatchers.Main).async { - val store = createSameThreadEnforcedStore( - testReducer, - TestState(), - applyMiddleware(middleware.middleware) - ) + @Test + fun ensureSameThreadOnGetState() { + ensureSameThread { store.getState() } + } - store.dispatch(Any()) - }.await() - Thread.sleep(2000) - assertFalse(middleware.failed) - } + @Test + fun ensureSameThreadOnDispatch() { + ensureSameThread { store.dispatch(Any()) } + } + + @Test + fun ensureSameThreadOnReplaceReducer() { + ensureSameThread { store.replaceReducer { state, action -> state } } + } + + @Test + fun ensureSameThreadOnSubscribe() { + ensureSameThread { store.subscribe { } } + } + + @Test + fun enforcesSameThreadWhenThreadNameAppendsCoroutineName() { + val middleware = TestMiddleware() + + runBlocking { + CoroutineScope(Dispatchers.Main).async { + val store = createSameThreadEnforcedStore( + testReducer, + TestState(), + applyMiddleware(middleware.middleware) + ) + + store.dispatch(Any()) + }.await() + Thread.sleep(2000) + assertFalse(middleware.failed) } - it("increments massively") { - suspend fun massiveRun(action: suspend () -> Unit) { - val n = 100 // number of coroutines to launch - val k = 1000 // times an action is repeated by each coroutine - val time = measureTimeMillis { - coroutineScope { - // scope for coroutines - repeat(n) { - launch { - repeat(k) { action() } - } + } + + @Test + fun incrementsMassively() { + suspend fun massiveRun(action: suspend () -> Unit) { + val n = 100 // number of coroutines to launch + val k = 1000 // times an action is repeated by each coroutine + val time = measureTimeMillis { + coroutineScope { + // scope for coroutines + repeat(n) { + launch { + repeat(k) { action() } } } } - println("Completed ${n * k} actions in $time ms") } + println("Completed ${n * k} actions in $time ms") + } - val counterContext = newSingleThreadContext("CounterContext") + val counterContext = newSingleThreadContext("CounterContext") - lateinit var store: Store - runBlocking { - withContext(counterContext) { - store = createSameThreadEnforcedStore(counterReducer, TestCounterState()) - } + lateinit var store: Store + runBlocking { + withContext(counterContext) { + store = createSameThreadEnforcedStore(counterReducer, TestCounterState()) } - runBlocking { - withContext(counterContext) { - massiveRun { - store.dispatch(Increment()) - } - } - withContext(counterContext) { - assertEquals(100000, store.state.counter) + } + runBlocking { + withContext(counterContext) { + massiveRun { + store.dispatch(Increment()) } } + withContext(counterContext) { + assertEquals(100000, store.state.counter) + } } } -}) +} -private fun ensureSameThread(testFun: () -> Any) { - val latch = CountDownLatch(1) - var exception: java.lang.IllegalStateException? = null - var state: Any? = null + private fun ensureSameThread(testFun: () -> Any) { + val latch = CountDownLatch(1) + var exception: java.lang.IllegalStateException? = null + var state: Any? = null - val newThread = Thread { - state = testFun() - } + val newThread = Thread { + state = testFun() + } - newThread.setUncaughtExceptionHandler { thread, throwable -> - exception = throwable as IllegalStateException - latch.countDown() - } - newThread.start() + newThread.setUncaughtExceptionHandler { thread, throwable -> + exception = throwable as IllegalStateException + latch.countDown() + } + newThread.start() - latch.await() + latch.await() - assertNotNull(exception) - assertNull(state) -} + assertNotNull(exception) + assertNull(state) + } -val testReducer: Reducer = { state, action -> state } - -/** - * Used as a test for when Thread.currentThread.name returns the - * thread name + '@coroutine#'. - * See issue #38 https://github.com/reduxkotlin/redux-kotlin/issues/38 - */ -class TestMiddleware { - var failed = false - val middleware = middleware { store, next, action -> - CoroutineScope(Dispatchers.Main).launch { - flow { - delay(1000) // simulate api call - emit("Text Response") - }.collect { response -> - store.dispatch("") + val testReducer: Reducer = { state, action -> state } + + /** + * Used as a test for when Thread.currentThread.name returns the + * thread name + '@coroutine#'. + * See issue #38 https://github.com/reduxkotlin/redux-kotlin/issues/38 + */ + class TestMiddleware { + var failed = false + val middleware = middleware { store, next, action -> + CoroutineScope(Dispatchers.Main).launch { + flow { + delay(1000) // simulate api call + emit("Text Response") + }.collect { response -> + store.dispatch("") + } + } + try { + next(action) + } catch (e: Exception) { + e.printStackTrace() + failed = true + Unit } - } - try { - next(action) - } catch (e: Exception) { - e.printStackTrace() - failed = true - Unit } } -} -class Increment + class Increment -data class TestCounterState(val counter: Int = 0) + data class TestCounterState(val counter: Int = 0) -val counterReducer = { state: TestCounterState, action: Any -> - when (action) { - is Increment -> state.copy(counter = state.counter + 1) - else -> state + val counterReducer = { state: TestCounterState, action: Any -> + when (action) { + is Increment -> state.copy(counter = state.counter + 1) + else -> state + } } -} From 99c8c4269577eb95739979f3b19460a724a3df23 Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Thu, 6 Aug 2020 08:48:36 -0400 Subject: [PATCH 15/19] update test.yml to use allTest --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 96b23f1..7ae5d59 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v2 - name: Test - run: ./gradlew jvmTest + run: ./gradlew allTest - name: Archive redux-kotlin Test Reports uses: actions/upload-artifact@v1 From 3fd07aac2fa5a866eee022ded70da6851d7cc6f9 Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Thu, 6 Aug 2020 08:55:11 -0400 Subject: [PATCH 16/19] run github actions on all platforms --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7ae5d59..6186d96 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,10 @@ on: jobs: test: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] steps: - uses: actions/checkout@v2 From b269f6fa568803fff8516a6ea7a6bab412a81c94 Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Fri, 7 Aug 2020 09:48:05 -0400 Subject: [PATCH 17/19] fix all ktlint failures --- build.gradle.kts | 57 +-- buildSrc/src/main/kotlin/Libs.kt | 347 +++++++++--------- buildSrc/src/main/kotlin/Plugins.kt | 2 +- buildSrc/src/main/kotlin/Versions.kt | 50 +-- .../example/counter/MainActivity.kt | 14 +- examples/counter/common/build.gradle.kts | 84 ++--- .../reduxkotlin/examples/counter/Reducer.kt | 3 +- .../examples/counter/ReducerTest.kt | 2 +- .../reduxkotlin/example/todos/MainActivity.kt | 11 +- .../reduxkotlin/example/todos/TodoAdapter.kt | 10 +- .../reduxkotlin/examples/todos/AppState.kt | 1 - .../examples/todos/TodosReducerSpec.kt | 3 +- redux-kotlin-threadsafe/build.gradle.kts | 17 +- .../util/CreateThreadSafeStoreSpec.kt | 10 +- redux-kotlin/build.gradle.kts | 2 +- .../reduxkotlin/{Action.kt => ActionTypes.kt} | 1 - .../kotlin/org/reduxkotlin/ApplyMiddleware.kt | 3 +- .../kotlin/org/reduxkotlin/Compose.kt | 4 +- .../kotlin/org/reduxkotlin/CreateStore.kt | 1 - .../kotlin/org/reduxkotlin/Definitions.kt | 3 - .../org/reduxkotlin/utils/IsPlainObject.kt | 2 +- .../org/reduxkotlin/utils/ThreadUtil.kt | 2 +- .../org/reduxkotlin/ApplyMiddlewareTest.kt | 18 +- .../kotlin/org/reduxkotlin/CreateStoreSpec.kt | 10 +- .../org/reduxkotlin/utils/ThreadUtil.kt | 2 +- .../util/CreateSameThreadEnforcedStoreSpec.kt | 128 ++++--- 26 files changed, 408 insertions(+), 379 deletions(-) rename redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/{Action.kt => ActionTypes.kt} (99%) diff --git a/build.gradle.kts b/build.gradle.kts index 5c3eb6d..77907c5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,37 +1,38 @@ + buildscript { - repositories { - google() - mavenCentral() - maven("https://dl.bintray.com/jetbrains/kotlin-native-dependencies") - maven("https://plugins.gradle.org/m2/") - maven("https://oss.sonatype.org/content/repositories/snapshots") - jcenter() - } + repositories { + google() + mavenCentral() + maven("https://dl.bintray.com/jetbrains/kotlin-native-dependencies") + maven("https://plugins.gradle.org/m2/") + maven("https://oss.sonatype.org/content/repositories/snapshots") + jcenter() + } - dependencies { - classpath(Plugins.kotlin) - classpath(Plugins.dokka) - classpath(Plugins.android) - classpath(Plugins.atomicFu) - } + dependencies { + classpath(Plugins.kotlin) + classpath(Plugins.dokka) + classpath(Plugins.android) + classpath(Plugins.atomicFu) + } } plugins { - id("de.fayard.buildSrcVersions") version "0.4.2" + id("de.fayard.buildSrcVersions") version "0.4.2" } allprojects { - repositories { - google() - jcenter() - maven("https://kotlin.bintray.com/kotlinx") - maven("https://oss.sonatype.org/content/repositories/snapshots") - mavenCentral() - } + repositories { + google() + jcenter() + maven("https://kotlin.bintray.com/kotlinx") + maven("https://oss.sonatype.org/content/repositories/snapshots") + mavenCentral() + } - group = project.properties["GROUP"]!! - version = project.properties["VERSION_NAME"]!! - if (hasProperty("SNAPSHOT") || System.getenv("SNAPSHOT") != null) { - version = "$version-SNAPSHOT" - } -} \ No newline at end of file + group = project.properties["GROUP"]!! + version = project.properties["VERSION_NAME"]!! + if (hasProperty("SNAPSHOT") || System.getenv("SNAPSHOT") != null) { + version = "$version-SNAPSHOT" + } +} diff --git a/buildSrc/src/main/kotlin/Libs.kt b/buildSrc/src/main/kotlin/Libs.kt index b131fe6..6cf8563 100644 --- a/buildSrc/src/main/kotlin/Libs.kt +++ b/buildSrc/src/main/kotlin/Libs.kt @@ -7,177 +7,178 @@ import kotlin.String * `$ ./gradlew buildSrcVersions` */ object Libs { - /** - * https://developer.android.com/jetpack/androidx - */ - const val appcompat: String = "androidx.appcompat:appcompat:" + Versions.appcompat - - /** - * http://tools.android.com - */ - const val constraintlayout: String = "androidx.constraintlayout:constraintlayout:" + - Versions.constraintlayout - - /** - * https://developer.android.com/jetpack/androidx - */ - const val recyclerview: String = "androidx.recyclerview:recyclerview:" + Versions.recyclerview - - /** - * https://developer.android.com/studio - */ - const val aapt2: String = "com.android.tools.build:aapt2:" + Versions.aapt2 - - /** - * https://developer.android.com/studio - */ - const val com_android_tools_build_gradle: String = "com.android.tools.build:gradle:" + - Versions.com_android_tools_build_gradle - - /** - * https://developer.android.com/studio - */ - const val lint_gradle: String = "com.android.tools.lint:lint-gradle:" + Versions.lint_gradle - - const val de_fayard_buildsrcversions_gradle_plugin: String = - "de.fayard.buildSrcVersions:de.fayard.buildSrcVersions.gradle.plugin:" + - Versions.de_fayard_buildsrcversions_gradle_plugin - - /** - * http://mockk.io - */ - const val mockk_common: String = "io.mockk:mockk-common:" + Versions.io_mockk - - /** - * http://mockk.io - */ - const val mockk: String = "io.mockk:mockk:" + Versions.io_mockk - - const val dokka_gradle_plugin: String = "org.jetbrains.dokka:dokka-gradle-plugin:" + - Versions.dokka_gradle_plugin - - /** - * https://kotlinlang.org/ - */ - const val kotlin_android_extensions_runtime: String = - "org.jetbrains.kotlin:kotlin-android-extensions-runtime:" + Versions.org_jetbrains_kotlin - - /** - * https://kotlinlang.org/ - */ - const val kotlin_android_extensions: String = "org.jetbrains.kotlin:kotlin-android-extensions:" + - Versions.org_jetbrains_kotlin - - /** - * https://kotlinlang.org/ - */ - const val kotlin_annotation_processing_gradle: String = - "org.jetbrains.kotlin:kotlin-annotation-processing-gradle:" + Versions.org_jetbrains_kotlin - - const val kotlin_compiler_embeddable: String = - "org.jetbrains.kotlin:kotlin-compiler-embeddable:" + Versions.org_jetbrains_kotlin - - /** - * https://kotlinlang.org/ - */ - const val kotlin_gradle_plugin: String = "org.jetbrains.kotlin:kotlin-gradle-plugin:" + - Versions.org_jetbrains_kotlin - - const val kotlin_klib_commonizer_embeddable: String = - "org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:" + Versions.org_jetbrains_kotlin - - /** - * https://kotlinlang.org/ - */ - const val kotlin_reflect: String = "org.jetbrains.kotlin:kotlin-reflect:" + - Versions.org_jetbrains_kotlin - - /** - * https://kotlinlang.org/ - */ - const val kotlin_scripting_compiler_embeddable: String = - "org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:" + Versions.org_jetbrains_kotlin - - /** - * 1.3.72 - */ - const val kotlin_stdlib_common: String = "org.jetbrains.kotlin:kotlin-stdlib-common:" + - Versions.org_jetbrains_kotlin - - /** - * https://kotlinlang.org/ - */ - const val kotlin_stdlib_jdk8: String = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:" + - Versions.org_jetbrains_kotlin - - /** - * 1.3.72 - */ - const val kotlin_stdlib_js: String = "org.jetbrains.kotlin:kotlin-stdlib-js:" + - Versions.org_jetbrains_kotlin - - /** - * 1.3.72 - */ - const val kotlin_stdlib: String = "org.jetbrains.kotlin:kotlin-stdlib:" + - Versions.org_jetbrains_kotlin - - /** - * https://kotlinlang.org/ - */ - const val kotlin_test_annotations_common: String = - "org.jetbrains.kotlin:kotlin-test-annotations-common:" + Versions.org_jetbrains_kotlin - - /** - * https://kotlinlang.org/ - */ - const val kotlin_test_common: String = "org.jetbrains.kotlin:kotlin-test-common:" + - Versions.org_jetbrains_kotlin - - /** - * https://kotlinlang.org/ - */ - const val kotlin_test_js: String = "org.jetbrains.kotlin:kotlin-test-js:" + - Versions.org_jetbrains_kotlin - - /** - * https://kotlinlang.org/ - */ - const val kotlin_test_junit: String = "org.jetbrains.kotlin:kotlin-test-junit:" + - Versions.org_jetbrains_kotlin - - /** - * https://kotlinlang.org/ - */ - const val kotlin_test: String = "org.jetbrains.kotlin:kotlin-test:" + - Versions.org_jetbrains_kotlin - - /** - * https://github.com/Kotlin/atomicfu - */ - const val atomicfu_gradle_plugin: String = "org.jetbrains.kotlinx:atomicfu-gradle-plugin:" + - Versions.atomicfu_gradle_plugin - - /** - * https://github.com/Kotlin/atomicfu - */ - const val atomicfu: String = "org.jetbrains.kotlinx:atomicfu:" + Versions.atomicfu - - /** - * https://github.com/Kotlin/kotlinx.coroutines - */ - const val kotlinx_coroutines_core_jvm: String = - "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:" + Versions.kotlinx_coroutines_core_jvm - - /** - * https://github.com/Kotlin/kotlinx.coroutines - */ - const val kotlinx_coroutines_core: String = "org.jetbrains.kotlinx:kotlinx-coroutines-core:" + - Versions.kotlinx_coroutines_core - - /** - * https://github.com/Kotlin/kotlinx.coroutines - */ - const val kotlinx_coroutines_test: String = "org.jetbrains.kotlinx:kotlinx-coroutines-test:" + - Versions.kotlinx_coroutines_test + /** + * https://developer.android.com/jetpack/androidx + */ + const val appcompat: String = "androidx.appcompat:appcompat:" + Versions.appcompat + + /** + * http://tools.android.com + */ + const val constraintlayout: String = "androidx.constraintlayout:constraintlayout:" + + Versions.constraintlayout + + /** + * https://developer.android.com/jetpack/androidx + */ + const val recyclerview: String = "androidx.recyclerview:recyclerview:" + Versions.recyclerview + + /** + * https://developer.android.com/studio + */ + const val aapt2: String = "com.android.tools.build:aapt2:" + Versions.aapt2 + + /** + * https://developer.android.com/studio + */ + const val com_android_tools_build_gradle: String = "com.android.tools.build:gradle:" + + Versions.com_android_tools_build_gradle + + /** + * https://developer.android.com/studio + */ + const val lint_gradle: String = "com.android.tools.lint:lint-gradle:" + Versions.lint_gradle + + const val de_fayard_buildsrcversions_gradle_plugin: String = + "de.fayard.buildSrcVersions:de.fayard.buildSrcVersions.gradle.plugin:" + + Versions.de_fayard_buildsrcversions_gradle_plugin + + /** + * http://mockk.io + */ + const val mockk_common: String = "io.mockk:mockk-common:" + Versions.io_mockk + + /** + * http://mockk.io + */ + const val mockk: String = "io.mockk:mockk:" + Versions.io_mockk + + const val dokka_gradle_plugin: String = "org.jetbrains.dokka:dokka-gradle-plugin:" + + Versions.dokka_gradle_plugin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_android_extensions_runtime: String = + "org.jetbrains.kotlin:kotlin-android-extensions-runtime:" + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_android_extensions: String = + "org.jetbrains.kotlin:kotlin-android-extensions:" + + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_annotation_processing_gradle: String = + "org.jetbrains.kotlin:kotlin-annotation-processing-gradle:" + Versions.org_jetbrains_kotlin + + const val kotlin_compiler_embeddable: String = + "org.jetbrains.kotlin:kotlin-compiler-embeddable:" + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_gradle_plugin: String = "org.jetbrains.kotlin:kotlin-gradle-plugin:" + + Versions.org_jetbrains_kotlin + + const val kotlin_klib_commonizer_embeddable: String = + "org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:" + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_reflect: String = "org.jetbrains.kotlin:kotlin-reflect:" + + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_scripting_compiler_embeddable: String = + "org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:" + Versions.org_jetbrains_kotlin + + /** + * 1.3.72 + */ + const val kotlin_stdlib_common: String = "org.jetbrains.kotlin:kotlin-stdlib-common:" + + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_stdlib_jdk8: String = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:" + + Versions.org_jetbrains_kotlin + + /** + * 1.3.72 + */ + const val kotlin_stdlib_js: String = "org.jetbrains.kotlin:kotlin-stdlib-js:" + + Versions.org_jetbrains_kotlin + + /** + * 1.3.72 + */ + const val kotlin_stdlib: String = "org.jetbrains.kotlin:kotlin-stdlib:" + + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_test_annotations_common: String = + "org.jetbrains.kotlin:kotlin-test-annotations-common:" + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_test_common: String = "org.jetbrains.kotlin:kotlin-test-common:" + + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_test_js: String = "org.jetbrains.kotlin:kotlin-test-js:" + + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_test_junit: String = "org.jetbrains.kotlin:kotlin-test-junit:" + + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_test: String = "org.jetbrains.kotlin:kotlin-test:" + + Versions.org_jetbrains_kotlin + + /** + * https://github.com/Kotlin/atomicfu + */ + const val atomicfu_gradle_plugin: String = "org.jetbrains.kotlinx:atomicfu-gradle-plugin:" + + Versions.atomicfu_gradle_plugin + + /** + * https://github.com/Kotlin/atomicfu + */ + const val atomicfu: String = "org.jetbrains.kotlinx:atomicfu:" + Versions.atomicfu + + /** + * https://github.com/Kotlin/kotlinx.coroutines + */ + const val kotlinx_coroutines_core_jvm: String = + "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:" + Versions.kotlinx_coroutines_core_jvm + + /** + * https://github.com/Kotlin/kotlinx.coroutines + */ + const val kotlinx_coroutines_core: String = "org.jetbrains.kotlinx:kotlinx-coroutines-core:" + + Versions.kotlinx_coroutines_core + + /** + * https://github.com/Kotlin/kotlinx.coroutines + */ + const val kotlinx_coroutines_test: String = "org.jetbrains.kotlinx:kotlinx-coroutines-test:" + + Versions.kotlinx_coroutines_test } diff --git a/buildSrc/src/main/kotlin/Plugins.kt b/buildSrc/src/main/kotlin/Plugins.kt index 03f2559..f718653 100644 --- a/buildSrc/src/main/kotlin/Plugins.kt +++ b/buildSrc/src/main/kotlin/Plugins.kt @@ -1,6 +1,6 @@ object Plugins { const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.org_jetbrains_kotlin}" - const val dokka = "org.jetbrains.dokka:dokka-gradle-plugin:${Versions.dokka_gradle_plugin}" + const val dokka = "org.jetbrains.dokka:dokka-gradle-plugin:${Versions.dokka_gradle_plugin}" const val android = "com.android.tools.build:gradle:${Versions.com_android_tools_build_gradle}" const val atomicFu = "org.jetbrains.kotlinx:atomicfu-gradle-plugin:${Versions.atomicfu}" } diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 76c4e13..8063399 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -1,6 +1,6 @@ -import kotlin.String import org.gradle.plugin.use.PluginDependenciesSpec import org.gradle.plugin.use.PluginDependencySpec +import kotlin.String /** * Generated by https://github.com/jmfayard/buildSrcVersions @@ -12,44 +12,44 @@ import org.gradle.plugin.use.PluginDependencySpec * YOU are responsible for updating manually the dependency version. */ object Versions { - const val appcompat: String = "1.1.0-rc01" // available: "1.1.0" + const val appcompat: String = "1.1.0-rc01" // available: "1.1.0" - const val constraintlayout: String = "1.1.3" + const val constraintlayout: String = "1.1.3" - const val recyclerview: String = "1.0.0" // available: "1.1.0" + const val recyclerview: String = "1.0.0" // available: "1.1.0" - const val aapt2: String = "3.6.0-6040484" // available: "4.0.1-6197926" + const val aapt2: String = "3.6.0-6040484" // available: "4.0.1-6197926" - const val com_android_tools_build_gradle: String = "3.6.0" // available: "4.0.1" + const val com_android_tools_build_gradle: String = "3.6.0" // available: "4.0.1" - const val lint_gradle: String = "26.6.0" // available: "27.0.1" + const val lint_gradle: String = "26.6.0" // available: "27.0.1" - const val de_fayard_buildsrcversions_gradle_plugin: String = "0.4.2" // available: "0.7.0" + const val de_fayard_buildsrcversions_gradle_plugin: String = "0.4.2" // available: "0.7.0" - const val io_mockk: String = "1.9.3" // available: "1.10.0" + const val io_mockk: String = "1.9.3" // available: "1.10.0" - const val dokka_gradle_plugin: String = "0.9.17" // available: "0.11.0-dev-59" + const val dokka_gradle_plugin: String = "0.9.17" // available: "0.11.0-dev-59" - const val org_jetbrains_kotlin: String = "1.4.0-rc" + const val org_jetbrains_kotlin: String = "1.4.0-rc" - const val atomicfu_gradle_plugin: String = "0.14.3-1.4.0-rc" + const val atomicfu_gradle_plugin: String = "0.14.3-1.4.0-rc" - const val atomicfu: String = "0.14.3-1.4.0-rc" + const val atomicfu: String = "0.14.3-1.4.0-rc" - const val kotlinx_coroutines_core_jvm: String = "1.3.8-1.4.0-rc" + const val kotlinx_coroutines_core_jvm: String = "1.3.8-1.4.0-rc" - const val kotlinx_coroutines_core: String = "1.3.8-1.4.0-rc" + const val kotlinx_coroutines_core: String = "1.3.8-1.4.0-rc" - const val kotlinx_coroutines_test: String = "1.3.8-1.4.0-rc" + const val kotlinx_coroutines_test: String = "1.3.8-1.4.0-rc" - /** - * - * See issue 19: How to update Gradle itself? - * https://github.com/jmfayard/buildSrcVersions/issues/19 - */ - const val gradleLatestVersion: String = "6.5.1" + /** + * + * See issue 19: How to update Gradle itself? + * https://github.com/jmfayard/buildSrcVersions/issues/19 + */ + const val gradleLatestVersion: String = "6.5.1" - const val gradleCurrentVersion: String = "6.5" + const val gradleCurrentVersion: String = "6.5" } /** @@ -57,5 +57,5 @@ object Versions { * https://github.com/jmfayard/buildSrcVersions/issues/47 */ val PluginDependenciesSpec.buildSrcVersions: PluginDependencySpec - inline get() = - id("de.fayard.buildSrcVersions").version(Versions.de_fayard_buildsrcversions_gradle_plugin) + inline get() = + id("de.fayard.buildSrcVersions").version(Versions.de_fayard_buildsrcversions_gradle_plugin) diff --git a/examples/counter/android/src/main/java/org/reduxkotlin/example/counter/MainActivity.kt b/examples/counter/android/src/main/java/org/reduxkotlin/example/counter/MainActivity.kt index e3d7bcd..a02db3f 100644 --- a/examples/counter/android/src/main/java/org/reduxkotlin/example/counter/MainActivity.kt +++ b/examples/counter/android/src/main/java/org/reduxkotlin/example/counter/MainActivity.kt @@ -15,10 +15,9 @@ import org.reduxkotlin.examples.counter.reducer * This is NOT best practice for structuring a multiplatform App. */ - val store = createThreadSafeStore(reducer, 0) -class MainActivity: AppCompatActivity() { +class MainActivity : AppCompatActivity() { lateinit var storeSubscription: StoreSubscription override fun onCreate(savedInstanceState: Bundle?) { @@ -42,8 +41,11 @@ class MainActivity: AppCompatActivity() { } private fun incrementAsync() { - Handler().postDelayed({ - store.dispatch(Increment()) - }, 1000) + Handler().postDelayed( + { + store.dispatch(Increment()) + }, + 1000 + ) } -} \ No newline at end of file +} diff --git a/examples/counter/common/build.gradle.kts b/examples/counter/common/build.gradle.kts index cdb600f..2ff0a18 100644 --- a/examples/counter/common/build.gradle.kts +++ b/examples/counter/common/build.gradle.kts @@ -1,52 +1,52 @@ plugins { - java - kotlin("multiplatform") + java + kotlin("multiplatform") } kotlin { - jvm() - js(IR) { - browser() - binaries.executable() + jvm() + js(IR) { + browser() + binaries.executable() - listOf(compilations["main"], compilations["test"]).forEach { - with(it.kotlinOptions) { - moduleKind = "umd" - sourceMap = true - sourceMapEmbedSources = "always" - metaInfo = true - } + listOf(compilations["main"], compilations["test"]).forEach { + with(it.kotlinOptions) { + moduleKind = "umd" + sourceMap = true + sourceMapEmbedSources = "always" + metaInfo = true + } + } } - } - iosArm64() - iosX64() + iosArm64() + iosX64() - sourceSets { - commonMain { - dependencies { - implementation(project(":redux-kotlin")) - } + sourceSets { + commonMain { + dependencies { + implementation(project(":redux-kotlin")) + } + } + commonTest { + dependencies { + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + implementation("io.mockk:mockk-common:${Versions.io_mockk}") + } + } + val jvmTest by getting { + dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-junit")) + runtimeOnly("org.jetbrains.kotlin:kotlin-reflect") + } + } + val jsTest by getting { + dependencies { + implementation(kotlin("test-js")) + implementation(kotlin("stdlib-js")) + } + } } - commonTest { - dependencies { - implementation(kotlin("test-common")) - implementation(kotlin("test-annotations-common")) - implementation("io.mockk:mockk-common:${Versions.io_mockk}") - } - } - val jvmTest by getting { - dependencies { - implementation(kotlin("test")) - implementation(kotlin("test-junit")) - runtimeOnly("org.jetbrains.kotlin:kotlin-reflect") - } - } - val jsTest by getting { - dependencies { - implementation(kotlin("test-js")) - implementation(kotlin("stdlib-js")) - } - } - } } diff --git a/examples/counter/common/src/commonMain/kotlin/org/reduxkotlin/examples/counter/Reducer.kt b/examples/counter/common/src/commonMain/kotlin/org/reduxkotlin/examples/counter/Reducer.kt index a03912c..649d023 100644 --- a/examples/counter/common/src/commonMain/kotlin/org/reduxkotlin/examples/counter/Reducer.kt +++ b/examples/counter/common/src/commonMain/kotlin/org/reduxkotlin/examples/counter/Reducer.kt @@ -2,7 +2,6 @@ package org.reduxkotlin.examples.counter import org.reduxkotlin.Reducer - class Increment class Decrement @@ -23,4 +22,4 @@ val reducer: Reducer = { state, action -> is Decrement -> state - 1 else -> state } -} \ No newline at end of file +} diff --git a/examples/counter/common/src/test/kotlin/org/reduxkotlin/examples/counter/ReducerTest.kt b/examples/counter/common/src/test/kotlin/org/reduxkotlin/examples/counter/ReducerTest.kt index ce9188d..704b85f 100644 --- a/examples/counter/common/src/test/kotlin/org/reduxkotlin/examples/counter/ReducerTest.kt +++ b/examples/counter/common/src/test/kotlin/org/reduxkotlin/examples/counter/ReducerTest.kt @@ -3,7 +3,7 @@ package org.reduxkotlin.examples.counter import kotlin.test.Test import kotlin.test.expect -class CounterTest { +class ReducerTest { @Test fun shouldHandleINCREMENTAction() { diff --git a/examples/todos/android/src/main/java/org/reduxkotlin/example/todos/MainActivity.kt b/examples/todos/android/src/main/java/org/reduxkotlin/example/todos/MainActivity.kt index bbc6a30..12c07bd 100644 --- a/examples/todos/android/src/main/java/org/reduxkotlin/example/todos/MainActivity.kt +++ b/examples/todos/android/src/main/java/org/reduxkotlin/example/todos/MainActivity.kt @@ -5,17 +5,20 @@ import androidx.appcompat.app.AppCompatActivity import kotlinx.android.synthetic.main.activity_main.* import org.reduxkotlin.StoreSubscription import org.reduxkotlin.createThreadSafeStore -import org.reduxkotlin.examples.todos.* +import org.reduxkotlin.examples.todos.AddTodo +import org.reduxkotlin.examples.todos.AppState +import org.reduxkotlin.examples.todos.SetVisibilityFilter +import org.reduxkotlin.examples.todos.VisibilityFilter +import org.reduxkotlin.examples.todos.rootReducer /** * This is a sample of basic redux behavior. * This is NOT best practice for structuring a multiplatform App. */ - val store = createThreadSafeStore(::rootReducer, AppState()) -class MainActivity: AppCompatActivity() { +class MainActivity : AppCompatActivity() { private lateinit var storeSubscription: StoreSubscription private var adapter = TodoAdapter() @@ -60,4 +63,4 @@ class MainActivity: AppCompatActivity() { btnActive.isSelected = false } } -} \ No newline at end of file +} diff --git a/examples/todos/android/src/main/java/org/reduxkotlin/example/todos/TodoAdapter.kt b/examples/todos/android/src/main/java/org/reduxkotlin/example/todos/TodoAdapter.kt index ab38bbf..7911b51 100644 --- a/examples/todos/android/src/main/java/org/reduxkotlin/example/todos/TodoAdapter.kt +++ b/examples/todos/android/src/main/java/org/reduxkotlin/example/todos/TodoAdapter.kt @@ -1,15 +1,15 @@ package org.reduxkotlin.example.todos +import android.graphics.Paint.STRIKE_THRU_TEXT_FLAG import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import kotlinx.android.synthetic.main.item_todo.view.* import org.reduxkotlin.examples.todos.Todo import org.reduxkotlin.examples.todos.ToggleTodo -import android.graphics.Paint.STRIKE_THRU_TEXT_FLAG -import androidx.recyclerview.widget.DiffUtil -import androidx.recyclerview.widget.ListAdapter class TodoAdapter : ListAdapter(DiffCallback()) { @@ -33,7 +33,7 @@ class TodoViewHolder(view: View) : RecyclerView.ViewHolder(view) { } itemView.tvTodo.text = "• ${todo.text}" - itemView.setOnClickListener { store.dispatch(ToggleTodo(adapterPosition))} + itemView.setOnClickListener { store.dispatch(ToggleTodo(adapterPosition)) } } } @@ -45,4 +45,4 @@ class DiffCallback : DiffUtil.ItemCallback() { override fun areContentsTheSame(oldItem: Todo, newItem: Todo): Boolean { return oldItem == newItem } -} \ No newline at end of file +} diff --git a/examples/todos/common/src/commonMain/kotlin/org/reduxkotlin/examples/todos/AppState.kt b/examples/todos/common/src/commonMain/kotlin/org/reduxkotlin/examples/todos/AppState.kt index 336be0c..e88cfe6 100644 --- a/examples/todos/common/src/commonMain/kotlin/org/reduxkotlin/examples/todos/AppState.kt +++ b/examples/todos/common/src/commonMain/kotlin/org/reduxkotlin/examples/todos/AppState.kt @@ -1,6 +1,5 @@ package org.reduxkotlin.examples.todos - /** * Entire state tree for the app. */ diff --git a/examples/todos/common/src/test/kotlin/org/reduxkotlin/examples/todos/TodosReducerSpec.kt b/examples/todos/common/src/test/kotlin/org/reduxkotlin/examples/todos/TodosReducerSpec.kt index cdf3a6a..b24c49e 100644 --- a/examples/todos/common/src/test/kotlin/org/reduxkotlin/examples/todos/TodosReducerSpec.kt +++ b/examples/todos/common/src/test/kotlin/org/reduxkotlin/examples/todos/TodosReducerSpec.kt @@ -97,7 +97,8 @@ class TodosReducerSpec { completed = false, id = 1 ) - ), ToggleTodo(index = 0) + ), + ToggleTodo(index = 0) ), listOf( Todo( diff --git a/redux-kotlin-threadsafe/build.gradle.kts b/redux-kotlin-threadsafe/build.gradle.kts index 046f0db..6d71e38 100644 --- a/redux-kotlin-threadsafe/build.gradle.kts +++ b/redux-kotlin-threadsafe/build.gradle.kts @@ -1,3 +1,4 @@ + plugins { java kotlin("multiplatform") @@ -34,12 +35,12 @@ kotlin { watchosArm64() watchosX86() - //below are currently not supported by atomicfu - //wasm32("wasm") - //linuxArm32Hfp("linArm32") - //linuxMips32("linMips32") - //linuxMipsel32("linMipsel32") - //linuxArm64() +// below are currently not supported by atomicfu +// wasm32("wasm") +// linuxArm32Hfp("linArm32") +// linuxMips32("linMips32") +// linuxMipsel32("linMipsel32") +// linuxArm64() sourceSets { commonMain { @@ -93,8 +94,8 @@ afterEvaluate { dependsOn("publishMetadataPublicationToTestRepository") } // NOTE: We do not alias uploadArchives because CI runs it on Linux and we only want to run it on Mac OS. - //tasks.create("uploadArchives").dependsOn("publishKotlinMultiplatformPublicationToMavenRepository") + // tasks.create("uploadArchives").dependsOn("publishKotlinMultiplatformPublicationToMavenRepository") } } -apply(from = rootProject.file("gradle/publish.gradle")) \ No newline at end of file +apply(from = rootProject.file("gradle/publish.gradle")) diff --git a/redux-kotlin-threadsafe/src/jvmTest/kotlin/org/reduxkotlin/util/CreateThreadSafeStoreSpec.kt b/redux-kotlin-threadsafe/src/jvmTest/kotlin/org/reduxkotlin/util/CreateThreadSafeStoreSpec.kt index 6b816f5..6057d97 100644 --- a/redux-kotlin-threadsafe/src/jvmTest/kotlin/org/reduxkotlin/util/CreateThreadSafeStoreSpec.kt +++ b/redux-kotlin-threadsafe/src/jvmTest/kotlin/org/reduxkotlin/util/CreateThreadSafeStoreSpec.kt @@ -1,6 +1,10 @@ package org.reduxkotlin.util -import kotlinx.coroutines.* +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.withContext import org.junit.Test import org.reduxkotlin.createThreadSafeStore import kotlin.system.measureTimeMillis @@ -10,7 +14,7 @@ class MultiThreadedClass { @Test fun multithreadedIncrementsMassively() { suspend fun massiveRun(action: suspend () -> Unit) { - val n = 100 // number of coroutines to launch + val n = 100 // number of coroutines to launch val k = 1000 // times an action is repeated by each coroutine val time = measureTimeMillis { coroutineScope { @@ -25,7 +29,7 @@ class MultiThreadedClass { println("Completed ${n * k} actions in $time ms") } - //NOTE: changing this to createStore() breaks the tests + // NOTE: changing this to createStore() breaks the tests val store = createThreadSafeStore(counterReducer, TestCounterState()) runBlocking { withContext(Dispatchers.Default) { diff --git a/redux-kotlin/build.gradle.kts b/redux-kotlin/build.gradle.kts index 7ca0eed..0de1cd4 100644 --- a/redux-kotlin/build.gradle.kts +++ b/redux-kotlin/build.gradle.kts @@ -111,7 +111,7 @@ afterEvaluate { dependsOn("publishMetadataPublicationToTestRepository") } // NOTE: We do not alias uploadArchives because CI runs it on Linux and we only want to run it on Mac OS. - //tasks.create("uploadArchives").dependsOn("publishKotlinMultiplatformPublicationToMavenRepository") + // tasks.create("uploadArchives").dependsOn("publishKotlinMultiplatformPublicationToMavenRepository") } } diff --git a/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/Action.kt b/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/ActionTypes.kt similarity index 99% rename from redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/Action.kt rename to redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/ActionTypes.kt index 0ead87f..5fd5bb8 100644 --- a/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/Action.kt +++ b/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/ActionTypes.kt @@ -10,4 +10,3 @@ object ActionTypes { */ object REPLACE } - diff --git a/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/ApplyMiddleware.kt b/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/ApplyMiddleware.kt index 0399493..f5c118b 100644 --- a/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/ApplyMiddleware.kt +++ b/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/ApplyMiddleware.kt @@ -24,7 +24,8 @@ fun applyMiddleware(vararg middlewares: Middleware): StoreEnhance val dispatch: Dispatcher = { throw Exception( """Dispatching while constructing your middleware is not allowed. - Other middleware would not be applied to this dispatch.""") + Other middleware would not be applied to this dispatch.""" + ) } store.dispatch = dispatch val chain = middlewares.map { middleware -> middleware(store) } diff --git a/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/Compose.kt b/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/Compose.kt index dbd278d..e72ba90 100644 --- a/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/Compose.kt +++ b/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/Compose.kt @@ -4,7 +4,7 @@ package org.reduxkotlin * Composes a list of single argument functions from right to left. */ fun compose(vararg functions: (T) -> T): (T) -> T = - { x -> functions.foldRight(x, { f, composed -> f(composed) }) } + { x -> functions.foldRight(x, { f, composed -> f(composed) }) } fun compose(functions: List<(T) -> T>): (T) -> T = - { x -> functions.foldRight(x, { f, composed -> f(composed) }) } + { x -> functions.foldRight(x, { f, composed -> f(composed) }) } diff --git a/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/CreateStore.kt b/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/CreateStore.kt index b07945d..ade9f22 100644 --- a/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/CreateStore.kt +++ b/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/CreateStore.kt @@ -241,6 +241,5 @@ fun createStore( override var dispatch: Dispatcher = ::dispatch override val subscribe = ::subscribe override val replaceReducer = ::replaceReducer - } } diff --git a/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/Definitions.kt b/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/Definitions.kt index f218998..2443067 100644 --- a/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/Definitions.kt +++ b/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/Definitions.kt @@ -1,6 +1,5 @@ package org.reduxkotlin - /** * See also https://github.com/reactjs/redux/blob/master/docs/Glossary.md#reducer */ @@ -34,7 +33,6 @@ typealias StoreEnhancer = (StoreCreator) -> StoreCreator */ typealias Middleware = (store: Store) -> (next: Dispatcher) -> (action: Any) -> Any - interface Store { val getState: GetState var dispatch: Dispatcher @@ -58,7 +56,6 @@ fun middleware(dispatch: (Store, next: Dispatcher, action: Any) - } } - /** * Convenience function for creating a [ReducerForActionType] * usage: diff --git a/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/utils/IsPlainObject.kt b/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/utils/IsPlainObject.kt index 980901e..dde90c4 100644 --- a/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/utils/IsPlainObject.kt +++ b/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/utils/IsPlainObject.kt @@ -1,3 +1,3 @@ package org.reduxkotlin.utils -fun isPlainObject(obj: Any) = obj !is Function<*> \ No newline at end of file +fun isPlainObject(obj: Any) = obj !is Function<*> diff --git a/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/utils/ThreadUtil.kt b/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/utils/ThreadUtil.kt index 700a6da..1d7f695 100644 --- a/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/utils/ThreadUtil.kt +++ b/redux-kotlin/src/commonMain/kotlin/org/reduxkotlin/utils/ThreadUtil.kt @@ -14,5 +14,5 @@ expect fun getThreadName(): String fun stripCoroutineName(threadName: String): String { val lastIndex = threadName.lastIndexOf('@') return if (lastIndex < 0) threadName - else threadName.substring(0, lastIndex) + else threadName.substring(0, lastIndex) } diff --git a/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt b/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt index 32509f4..faf1d0f 100644 --- a/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt +++ b/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/ApplyMiddlewareTest.kt @@ -1,7 +1,7 @@ package org.reduxkotlin +import kotlin.test.Test import kotlin.test.assertFails -import kotlin.test.* class ApplyMiddlewareSpec { @Test @@ -49,7 +49,6 @@ class ApplyMiddlewareSpec { }) */ - } /************** Test Reducer & actions - tobe moved into example app *********/ @@ -63,14 +62,15 @@ data class TestState(val todos: List = listOf()) val todos = { state: TestState, action: Any -> when (action) { is AddTodo -> state.copy(todos = state.todos.plus(Todo(action.id, action.text, false))) - is ToggleTodo -> state.copy(todos = state.todos.map { - if (it.id == action.id) { - it.copy(completed = !it.completed) - } else { - it + is ToggleTodo -> state.copy( + todos = state.todos.map { + if (it.id == action.id) { + it.copy(completed = !it.completed) + } else { + it + } } - }) + ) else -> state } } - diff --git a/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/CreateStoreSpec.kt b/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/CreateStoreSpec.kt index a778453..9423be4 100644 --- a/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/CreateStoreSpec.kt +++ b/redux-kotlin/src/commonTest/kotlin/org/reduxkotlin/CreateStoreSpec.kt @@ -1,13 +1,14 @@ package org.reduxkotlin -import kotlin.test.assertEquals import kotlin.test.Test +import kotlin.test.assertEquals class CreateStoreSpec { @Test fun passesTheInitialState() { val store = createStore( - todos, TestState( + todos, + TestState( listOf( Todo( id = "1", @@ -51,7 +52,7 @@ class CreateStoreSpec { ) ) - //TODO are ids autoincrement? + // TODO are ids autoincrement? store.dispatch(AddTodo("2", "World")) assertEquals( store.getState(), @@ -73,7 +74,8 @@ class CreateStoreSpec { @Test fun appliesTheReducerToTheInitialState() { val store = createStore( - todos, TestState( + todos, + TestState( listOf( Todo( id = "1", diff --git a/redux-kotlin/src/jsMain/kotlin/org/reduxkotlin/utils/ThreadUtil.kt b/redux-kotlin/src/jsMain/kotlin/org/reduxkotlin/utils/ThreadUtil.kt index 8603350..d81cf43 100644 --- a/redux-kotlin/src/jsMain/kotlin/org/reduxkotlin/utils/ThreadUtil.kt +++ b/redux-kotlin/src/jsMain/kotlin/org/reduxkotlin/utils/ThreadUtil.kt @@ -1,3 +1,3 @@ package org.reduxkotlin.utils -actual fun getThreadName() = "main" \ No newline at end of file +actual fun getThreadName() = "main" diff --git a/redux-kotlin/src/jvmTest/kotlin/org/reduxkotlin/util/CreateSameThreadEnforcedStoreSpec.kt b/redux-kotlin/src/jvmTest/kotlin/org/reduxkotlin/util/CreateSameThreadEnforcedStoreSpec.kt index deab5ff..768f294 100644 --- a/redux-kotlin/src/jvmTest/kotlin/org/reduxkotlin/util/CreateSameThreadEnforcedStoreSpec.kt +++ b/redux-kotlin/src/jvmTest/kotlin/org/reduxkotlin/util/CreateSameThreadEnforcedStoreSpec.kt @@ -1,15 +1,35 @@ package org.reduxkotlin.util -import kotlinx.coroutines.* +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.asCoroutineDispatcher +import kotlinx.coroutines.async +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.launch +import kotlinx.coroutines.newSingleThreadContext +import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.setMain -import org.reduxkotlin.* +import kotlinx.coroutines.withContext +import org.junit.Test +import org.reduxkotlin.Reducer +import org.reduxkotlin.Store +import org.reduxkotlin.TestState +import org.reduxkotlin.Todo +import org.reduxkotlin.applyMiddleware +import org.reduxkotlin.createSameThreadEnforcedStore +import org.reduxkotlin.middleware +import org.reduxkotlin.todos import java.util.concurrent.CountDownLatch import java.util.concurrent.Executors -import kotlin.IllegalStateException import kotlin.system.measureTimeMillis -import kotlin.test.* +import kotlin.test.BeforeTest +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNotNull +import kotlin.test.assertNull class CreateSameThreadEnforcedStoreSpec { lateinit var store: Store @@ -20,7 +40,8 @@ class CreateSameThreadEnforcedStoreSpec { Dispatchers.setMain(mainThreadSurrogate) store = createSameThreadEnforcedStore( - todos, TestState( + todos, + TestState( listOf( Todo( id = "1", @@ -73,7 +94,7 @@ class CreateSameThreadEnforcedStoreSpec { @Test fun incrementsMassively() { suspend fun massiveRun(action: suspend () -> Unit) { - val n = 100 // number of coroutines to launch + val n = 100 // number of coroutines to launch val k = 1000 // times an action is repeated by each coroutine val time = measureTimeMillis { coroutineScope { @@ -88,7 +109,6 @@ class CreateSameThreadEnforcedStoreSpec { println("Completed ${n * k} actions in $time ms") } - val counterContext = newSingleThreadContext("CounterContext") lateinit var store: Store @@ -110,62 +130,62 @@ class CreateSameThreadEnforcedStoreSpec { } } - private fun ensureSameThread(testFun: () -> Any) { - val latch = CountDownLatch(1) - var exception: java.lang.IllegalStateException? = null - var state: Any? = null +private fun ensureSameThread(testFun: () -> Any) { + val latch = CountDownLatch(1) + var exception: java.lang.IllegalStateException? = null + var state: Any? = null - val newThread = Thread { - state = testFun() - } + val newThread = Thread { + state = testFun() + } - newThread.setUncaughtExceptionHandler { thread, throwable -> - exception = throwable as IllegalStateException - latch.countDown() - } - newThread.start() + newThread.setUncaughtExceptionHandler { thread, throwable -> + exception = throwable as IllegalStateException + latch.countDown() + } + newThread.start() - latch.await() + latch.await() - assertNotNull(exception) - assertNull(state) - } + assertNotNull(exception) + assertNull(state) +} - val testReducer: Reducer = { state, action -> state } - - /** - * Used as a test for when Thread.currentThread.name returns the - * thread name + '@coroutine#'. - * See issue #38 https://github.com/reduxkotlin/redux-kotlin/issues/38 - */ - class TestMiddleware { - var failed = false - val middleware = middleware { store, next, action -> - CoroutineScope(Dispatchers.Main).launch { - flow { - delay(1000) // simulate api call - emit("Text Response") - }.collect { response -> - store.dispatch("") - } - } - try { - next(action) - } catch (e: Exception) { - e.printStackTrace() - failed = true - Unit +val testReducer: Reducer = { state, action -> state } + +/** + * Used as a test for when Thread.currentThread.name returns the + * thread name + '@coroutine#'. + * See issue #38 https://github.com/reduxkotlin/redux-kotlin/issues/38 + */ +class TestMiddleware { + var failed = false + val middleware = middleware { store, next, action -> + CoroutineScope(Dispatchers.Main).launch { + flow { + delay(1000) // simulate api call + emit("Text Response") + }.collect { response -> + store.dispatch("") } } + try { + next(action) + } catch (e: Exception) { + e.printStackTrace() + failed = true + Unit + } } +} - class Increment +class Increment - data class TestCounterState(val counter: Int = 0) +data class TestCounterState(val counter: Int = 0) - val counterReducer = { state: TestCounterState, action: Any -> - when (action) { - is Increment -> state.copy(counter = state.counter + 1) - else -> state - } +val counterReducer = { state: TestCounterState, action: Any -> + when (action) { + is Increment -> state.copy(counter = state.counter + 1) + else -> state } +} From b50ef72ea213a4ce77f9bbbfba9b0707ab4755b2 Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Fri, 7 Aug 2020 10:00:24 -0400 Subject: [PATCH 18/19] add ktlint to .guthub/pull_request.yml --- .github/workflows/{test.yml => pull_request.yml} | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) rename .github/workflows/{test.yml => pull_request.yml} (80%) diff --git a/.github/workflows/test.yml b/.github/workflows/pull_request.yml similarity index 80% rename from .github/workflows/test.yml rename to .github/workflows/pull_request.yml index 6186d96..c076f19 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/pull_request.yml @@ -1,4 +1,4 @@ -name: Test +name: PR on: pull_request: @@ -7,7 +7,16 @@ on: - '*.md' jobs: + ktlint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Ktlint + uses: "vroy/gha-kotlin-linter@v1" test: + needs: ktlint runs-on: ${{ matrix.os }} strategy: matrix: From 10d3efefb9157799743349a4a459d70d6fe5c5a9 Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Sat, 15 Aug 2020 18:05:17 -0400 Subject: [PATCH 19/19] Kotlint 1.4.0 final & 6.6 (#66) * update to kotlin 1.4.0 and gradle 6.6 --- buildSrc/src/main/kotlin/Versions.kt | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 8063399..18a7463 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -30,7 +30,7 @@ object Versions { const val dokka_gradle_plugin: String = "0.9.17" // available: "0.11.0-dev-59" - const val org_jetbrains_kotlin: String = "1.4.0-rc" + const val org_jetbrains_kotlin: String = "1.4.0" const val atomicfu_gradle_plugin: String = "0.14.3-1.4.0-rc" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 50b57bf..8e9e2e9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip