From 3877f492781a448de14f6a0a4c1f5c119213aa14 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 5 Feb 2021 15:35:09 +0600 Subject: [PATCH 1/6] start 0.4.24 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14c2e747916..c093b531157 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.4.24 + ## 0.4.23 * `Versions`: diff --git a/gradle.properties b/gradle.properties index e74082177ec..66860867663 100644 --- a/gradle.properties +++ b/gradle.properties @@ -44,5 +44,5 @@ dokka_version=1.4.20 # Project data group=dev.inmo -version=0.4.23 +version=0.4.24 android_code_version=27 From 60dea2a5181a272492b8e105d8231ac195ee4f74 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 5 Feb 2021 15:38:20 +0600 Subject: [PATCH 2/6] DoWithFirstBuilder --- CHANGELOG.md | 4 ++ .../micro_utils/coroutines/DoWithFirst.kt | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c093b531157..4ca7ccbf0df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.4.24 +* `Coroutines`: + * New class `DoWithFirstBuilder` + * Several new extensions like `firstOf`/`first`/`invokeOnFirstOf` + ## 0.4.23 * `Versions`: diff --git a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DoWithFirst.kt b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DoWithFirst.kt index 8bc71da51cb..91f6bfd8c1b 100644 --- a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DoWithFirst.kt +++ b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DoWithFirst.kt @@ -9,6 +9,17 @@ class DeferredAction( suspend operator fun invoke() = callback(deferred.await()) } +class DoWithFirstBuilder( + private val scope: CoroutineScope +) { + private val deferreds = mutableListOf>() + operator fun plus(block: suspend CoroutineScope.() -> T) { + deferreds.add(scope.async(start = CoroutineStart.LAZY, block = block)) + } + + fun build() = deferreds.toList() +} + fun Deferred.buildAction(callback: suspend (T) -> O) = DeferredAction(this, callback) suspend fun Iterable>.invokeFirstOf( @@ -32,9 +43,41 @@ suspend fun Iterable>.invokeOnFirst( callback: suspend (T) -> O ): O = map { it.buildAction(callback) }.invokeFirstOf(scope, cancelOnResult) +suspend fun CoroutineScope.invokeOnFirstOf( + cancelOnResult: Boolean = true, + block: DoWithFirstBuilder.() -> Unit, + callback: suspend (T) -> O +) = firstOf( + DoWithFirstBuilder(this).apply(block).build(), + cancelOnResult +).let { callback(it) } + suspend fun invokeOnFirst( scope: CoroutineScope, vararg variants: Deferred, cancelOnResult: Boolean = true, callback: suspend (T) -> O ): O = variants.toList().invokeOnFirst(scope, cancelOnResult, callback) + +suspend fun CoroutineScope.firstOf( + variants: Iterable>, + cancelOnResult: Boolean = true +) = variants.invokeOnFirst(this, cancelOnResult) { it } + +suspend fun CoroutineScope.firstOf( + cancelOnResult: Boolean = true, + block: DoWithFirstBuilder.() -> Unit +) = firstOf( + DoWithFirstBuilder(this).apply(block).build(), + cancelOnResult +) + +suspend fun CoroutineScope.firstOf( + vararg variants: Deferred, + cancelOnResult: Boolean = true +) = firstOf(variants.toList(), cancelOnResult) + +suspend fun List>.first( + scope: CoroutineScope, + cancelOnResult: Boolean = true +) = scope.firstOf(this, cancelOnResult) From e2fb8bf21ee153140c9ec0cbd97138f06ad6700d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 5 Feb 2021 15:41:43 +0600 Subject: [PATCH 3/6] update depdendencies --- CHANGELOG.md | 3 +++ gradle.properties | 4 ++-- publish.gradle | 18 +----------------- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ca7ccbf0df..977e9eaf695 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.4.24 +* `Versions`: + * `Kotlin`: `1.4.21` -> `1.4.30` + * `Klock`: `2.0.4` -> `2.0.6` * `Coroutines`: * New class `DoWithFirstBuilder` * Several new extensions like `firstOf`/`first`/`invokeOnFirstOf` diff --git a/gradle.properties b/gradle.properties index 66860867663..b642f975b6a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,14 +6,14 @@ kotlin.incremental.js=true android.useAndroidX=true android.enableJetifier=true -kotlin_version=1.4.21 +kotlin_version=1.4.30 kotlin_coroutines_version=1.4.2 kotlin_serialisation_core_version=1.0.1 kotlin_exposed_version=0.29.1 ktor_version=1.5.1 -klockVersion=2.0.4 +klockVersion=2.0.6 github_release_plugin_version=2.2.12 diff --git a/publish.gradle b/publish.gradle index 778028dc545..06e7a798989 100644 --- a/publish.gradle +++ b/publish.gradle @@ -3,22 +3,6 @@ apply plugin: 'maven-publish' task javadocsJar(type: Jar) { classifier = 'javadoc' } -task sourceJar (type : Jar) { - classifier = 'sources' -} - -afterEvaluate { - project.publishing.publications.all { - // rename artifacts - groupId "${project.group}" - if (it.name.contains('kotlinMultiplatform')) { - artifactId = "${project.name}" - artifact sourceJar - } else { - artifactId = "${project.name}-$name" - } - } -} publishing { publications.all { @@ -73,4 +57,4 @@ publishing { } } -} \ No newline at end of file +} From d06bb265e52a1544eef0b27e2d304260e1c948b6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 5 Feb 2021 15:47:12 +0600 Subject: [PATCH 4/6] update publishing scripts --- pubconf.kpsb | 2 +- publish.gradle | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pubconf.kpsb b/pubconf.kpsb index 3efd784fc97..3e8437fc386 100644 --- a/pubconf.kpsb +++ b/pubconf.kpsb @@ -1 +1 @@ -{"bintrayConfig":{"repo":"MicroUtils","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/MicroUtils","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.inmo.dev/InsanusMokrassar/MicroUtils_mirror/src/master/LICENSE"}],"mavenConfig":{"name":"${project.name}","description":"","url":"https://git.inmo.dev/InsanusMokrassar/MicroUtils_mirror","vcsUrl":"ssh://git@git.inmo.dev:8322/InsanusMokrassar/MicroUtils_mirror.git","developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"},{"id":"000Sanya","name":"Syrov Aleksandr","eMail":"000sanya.000sanya@gmail.com"}]}} \ No newline at end of file +{"bintrayConfig":{"repo":"MicroUtils","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/MicroUtils","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.inmo.dev/InsanusMokrassar/MicroUtils_mirror/src/master/LICENSE"}],"mavenConfig":{"name":"${project.name}","description":"","url":"https://git.inmo.dev/InsanusMokrassar/MicroUtils_mirror","vcsUrl":"ssh://git@git.inmo.dev:8322/InsanusMokrassar/MicroUtils_mirror.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"},{"id":"000Sanya","name":"Syrov Aleksandr","eMail":"000sanya.000sanya@gmail.com"}]}} \ No newline at end of file diff --git a/publish.gradle b/publish.gradle index 06e7a798989..0d6fbea7927 100644 --- a/publish.gradle +++ b/publish.gradle @@ -1,4 +1,5 @@ apply plugin: 'maven-publish' +apply plugin: 'signing' task javadocsJar(type: Jar) { classifier = 'javadoc' @@ -58,3 +59,8 @@ publishing { } } + +signing { + useGpgCmd() + publishing.publications.forEach { sign it } +} From 012c7e9bdf978f4098acf75b0a1e7eb312a10955 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 5 Feb 2021 16:09:08 +0600 Subject: [PATCH 5/6] add inline functions in DoWithFirstBuilder --- .../kotlin/dev/inmo/micro_utils/coroutines/DoWithFirst.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DoWithFirst.kt b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DoWithFirst.kt index 91f6bfd8c1b..94891715b83 100644 --- a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DoWithFirst.kt +++ b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/DoWithFirst.kt @@ -16,6 +16,8 @@ class DoWithFirstBuilder( operator fun plus(block: suspend CoroutineScope.() -> T) { deferreds.add(scope.async(start = CoroutineStart.LAZY, block = block)) } + inline fun add(noinline block: suspend CoroutineScope.() -> T) = plus(block) + inline fun include(noinline block: suspend CoroutineScope.() -> T) = plus(block) fun build() = deferreds.toList() } From 987c6cc709392c5b2f89415b3f1b506850071772 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 5 Feb 2021 16:10:08 +0600 Subject: [PATCH 6/6] update android version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index b642f975b6a..cf79ad930cc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -45,4 +45,4 @@ dokka_version=1.4.20 group=dev.inmo version=0.4.24 -android_code_version=27 +android_code_version=28