From d9c05f38d2b2425e38c2737ccfd96383a30be2de Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 25 Apr 2023 12:23:08 +0600 Subject: [PATCH 01/13] start 0.18.0 --- CHANGELOG.md | 2 ++ gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2584b79624b..0340b7a3372 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.18.0 + ## 0.17.8 * `Versions`: diff --git a/gradle.properties b/gradle.properties index 1a2aae47273..5db53e2a94f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,5 +14,5 @@ crypto_js_version=4.1.1 # Project data group=dev.inmo -version=0.17.8 -android_code_version=190 +version=0.18.0 +android_code_version=191 From 4bbe7e5a80cc663685ae9cd4e891cc79a55da82f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 25 Apr 2023 12:23:53 +0600 Subject: [PATCH 02/13] update build tools version --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 644de2f1e94..59dde185223 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -36,7 +36,7 @@ android-test = "1.1.5" android-props-minSdk = "21" android-props-compileSdk = "33" -android-props-buildTools = "33.0.1" +android-props-buildTools = "33.0.2" [libraries] From aa7cc503f24309cfe325969ddce38de5aeadcdb9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 25 Apr 2023 13:14:12 +0600 Subject: [PATCH 03/13] improvements in query parameters getting --- CHANGELOG.md | 4 ++++ .../ktor/server/QueryParameters.kt | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0340b7a3372..e195ed81c18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.18.0 +* `Ktor`: + * `Server`: + * Now it is possible to take query parameters as list + ## 0.17.8 * `Versions`: diff --git a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/QueryParameters.kt b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/QueryParameters.kt index 053d316c631..241adfb6290 100644 --- a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/QueryParameters.kt +++ b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/QueryParameters.kt @@ -12,10 +12,22 @@ suspend fun ApplicationCall.getParameterOrSendError( } } +suspend fun ApplicationCall.getParametersOrSendError( + field: String +) = parameters.getAll(field).also { + if (it == null) { + respond(HttpStatusCode.BadRequest, "Request must contains $field") + } +} + fun ApplicationCall.getQueryParameter( field: String ) = request.queryParameters[field] +fun ApplicationCall.getQueryParameters( + field: String +) = request.queryParameters.getAll(field) + suspend fun ApplicationCall.getQueryParameterOrSendError( field: String ) = getQueryParameter(field).also { @@ -23,3 +35,11 @@ suspend fun ApplicationCall.getQueryParameterOrSendError( respond(HttpStatusCode.BadRequest, "Request query parameters must contains $field") } } + +suspend fun ApplicationCall.getQueryParametersOrSendError( + field: String +) = getQueryParameters(field).also { + if (it == null) { + respond(HttpStatusCode.BadRequest, "Request query parameters must contains $field") + } +} From 315a7cb29e41db7df0fa23b4f5ba9d2eeaa483f5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 25 Apr 2023 17:23:47 +0600 Subject: [PATCH 04/13] Rename full caching factories functions to fullyCached --- CHANGELOG.md | 3 +++ .../micro_utils/repos/cache/full/FullCRUDCacheRepo.kt | 9 ++++++++- .../repos/cache/full/FullKeyValueCacheRepo.kt | 8 +++++++- .../repos/cache/full/FullKeyValuesCacheRepo.kt | 6 ++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e195ed81c18..60a3ef5c9c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ * `Ktor`: * `Server`: * Now it is possible to take query parameters as list +* `Repos`: + * `Cache`: + * Rename full caching factories functions to `fullyCached` ## 0.17.8 diff --git a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullCRUDCacheRepo.kt b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullCRUDCacheRepo.kt index 7d8c236c6ad..080a5a00a46 100644 --- a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullCRUDCacheRepo.kt +++ b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullCRUDCacheRepo.kt @@ -102,8 +102,15 @@ open class FullCRUDCacheRepo( } } -fun CRUDRepo.cached( +fun CRUDRepo.fullyCached( kvCache: FullKVCache, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), idGetter: (ObjectType) -> IdType ) = FullCRUDCacheRepo(this, kvCache, scope, idGetter) + +@Deprecated("Renamed", ReplaceWith("this.fullyCached(kvCache, scope, idGetter)", "dev.inmo.micro_utils.repos.cache.full.fullyCached")) +fun CRUDRepo.cached( + kvCache: FullKVCache, + scope: CoroutineScope = CoroutineScope(Dispatchers.Default), + idGetter: (ObjectType) -> IdType +) = fullyCached(kvCache, scope, idGetter) diff --git a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValueCacheRepo.kt b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValueCacheRepo.kt index 8a985d017be..4b976b75e29 100644 --- a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValueCacheRepo.kt +++ b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValueCacheRepo.kt @@ -117,7 +117,13 @@ open class FullKeyValueCacheRepo( } } -fun KeyValueRepo.cached( +fun KeyValueRepo.fullyCached( kvCache: FullKVCache, scope: CoroutineScope = CoroutineScope(Dispatchers.Default) ) = FullKeyValueCacheRepo(this, kvCache, scope) + +@Deprecated("Renamed", ReplaceWith("this.fullyCached(kvCache, scope)", "dev.inmo.micro_utils.repos.cache.full.fullyCached")) +fun KeyValueRepo.cached( + kvCache: FullKVCache, + scope: CoroutineScope = CoroutineScope(Dispatchers.Default) +) = fullyCached(kvCache, scope) diff --git a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValuesCacheRepo.kt b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValuesCacheRepo.kt index fc4bf34db0b..ae2e6be1cf0 100644 --- a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValuesCacheRepo.kt +++ b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValuesCacheRepo.kt @@ -159,6 +159,12 @@ open class FullKeyValuesCacheRepo( } } +fun KeyValuesRepo.fullyCached( + kvCache: FullKVCache>, + scope: CoroutineScope = CoroutineScope(Dispatchers.Default) +) = FullKeyValuesCacheRepo(this, kvCache, scope) + +@Deprecated("Renamed", ReplaceWith("this.fullyCached(kvCache, scope)", "dev.inmo.micro_utils.repos.cache.full.fullyCached")) fun KeyValuesRepo.caching( kvCache: FullKVCache>, scope: CoroutineScope = CoroutineScope(Dispatchers.Default) From 4e97ce86aaeef7bd47d7f458bdb6260f326b69b3 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 25 Apr 2023 17:39:14 +0600 Subject: [PATCH 05/13] add defauult value to kvCache in fullyCached --- .../dev/inmo/micro_utils/repos/cache/full/FullCRUDCacheRepo.kt | 2 +- .../inmo/micro_utils/repos/cache/full/FullKeyValueCacheRepo.kt | 2 +- .../inmo/micro_utils/repos/cache/full/FullKeyValuesCacheRepo.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullCRUDCacheRepo.kt b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullCRUDCacheRepo.kt index 080a5a00a46..f5b55e92148 100644 --- a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullCRUDCacheRepo.kt +++ b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullCRUDCacheRepo.kt @@ -103,7 +103,7 @@ open class FullCRUDCacheRepo( } fun CRUDRepo.fullyCached( - kvCache: FullKVCache, + kvCache: FullKVCache = FullKVCache(), scope: CoroutineScope = CoroutineScope(Dispatchers.Default), idGetter: (ObjectType) -> IdType ) = FullCRUDCacheRepo(this, kvCache, scope, idGetter) diff --git a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValueCacheRepo.kt b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValueCacheRepo.kt index 4b976b75e29..39e96edc1a8 100644 --- a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValueCacheRepo.kt +++ b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValueCacheRepo.kt @@ -118,7 +118,7 @@ open class FullKeyValueCacheRepo( } fun KeyValueRepo.fullyCached( - kvCache: FullKVCache, + kvCache: FullKVCache = FullKVCache(), scope: CoroutineScope = CoroutineScope(Dispatchers.Default) ) = FullKeyValueCacheRepo(this, kvCache, scope) diff --git a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValuesCacheRepo.kt b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValuesCacheRepo.kt index ae2e6be1cf0..c2ecb6679d3 100644 --- a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValuesCacheRepo.kt +++ b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValuesCacheRepo.kt @@ -160,7 +160,7 @@ open class FullKeyValuesCacheRepo( } fun KeyValuesRepo.fullyCached( - kvCache: FullKVCache>, + kvCache: FullKVCache> = FullKVCache(), scope: CoroutineScope = CoroutineScope(Dispatchers.Default) ) = FullKeyValuesCacheRepo(this, kvCache, scope) From 5f231c22129f6c2de92c0541202f1e894a77e28e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 25 Apr 2023 19:14:38 +0600 Subject: [PATCH 06/13] ReadKeyValuesRepo#removeWithValue --- CHANGELOG.md | 2 ++ .../AutoRecacheWriteKeyValuesRepo.kt | 16 +++++++++- .../cache/full/FullKeyValuesCacheRepo.kt | 4 +++ .../inmo/micro_utils/repos/KeyValuesRepo.kt | 30 +++++++++++++++++++ .../repos/mappers/OneToManyKeyValueMappers.kt | 2 ++ .../kvs/KeyValuesFromKeyValueRepo.kt | 19 ++++++++++++ .../repos/onetomany/OneToManyAndroidRepo.kt | 14 +++++++++ .../exposed/onetomany/ExposedKeyValuesRepo.kt | 28 +++++++++++++++++ .../micro_utils/repos/MapKeyValuesRepo.kt | 18 +++++++++-- .../values/KtorWriteKeyValuesRepoClient.kt | 11 +++++++ .../common/one_to_many/OneToManyRoutes.kt | 1 + .../values/KtorWriteKeyValuesRepoRoutes.kt | 5 ++++ 12 files changed, 147 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60a3ef5c9c2..9ff14ecf7e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ * `Server`: * Now it is possible to take query parameters as list * `Repos`: + * `Common`: + * New `WriteKeyValuesRepo.removeWithValue` * `Cache`: * Rename full caching factories functions to `fullyCached` diff --git a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/keyvalues/AutoRecacheWriteKeyValuesRepo.kt b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/keyvalues/AutoRecacheWriteKeyValuesRepo.kt index 73cf0551472..86ca7c71c85 100644 --- a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/keyvalues/AutoRecacheWriteKeyValuesRepo.kt +++ b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/keyvalues/AutoRecacheWriteKeyValuesRepo.kt @@ -7,6 +7,7 @@ import dev.inmo.micro_utils.pagination.utils.doForAllWithNextPaging import dev.inmo.micro_utils.repos.WriteKeyValuesRepo import dev.inmo.micro_utils.repos.cache.cache.FullKVCache import dev.inmo.micro_utils.repos.cache.FallbackCacheRepo +import dev.inmo.micro_utils.repos.pagination.maxPagePagination import dev.inmo.micro_utils.repos.set import dev.inmo.micro_utils.repos.unset import kotlinx.coroutines.CoroutineScope @@ -50,7 +51,7 @@ open class AutoRecacheWriteKeyValuesRepo( override suspend fun clearWithValue(v: RegisteredObject) { originalRepo.clearWithValue(v) - doForAllWithNextPaging(FirstPagePagination(kvCache.count().takeIf { it < Int.MAX_VALUE } ?.toInt() ?: Int.MAX_VALUE)) { + doForAllWithNextPaging(kvCache.maxPagePagination()) { kvCache.keys(it).also { it.results.forEach { id -> kvCache.get(id) ?.takeIf { it.contains(v) } ?.let { @@ -73,6 +74,19 @@ open class AutoRecacheWriteKeyValuesRepo( } } + override suspend fun removeWithValue(v: RegisteredObject) { + originalRepo.removeWithValue(v) + doForAllWithNextPaging(kvCache.maxPagePagination()) { + kvCache.keys(it).also { + it.results.forEach { id -> + kvCache.get(id) ?.takeIf { it.contains(v) } ?.let { + kvCache.set(id, it - v) + } + } + } + } + } + override suspend fun add(toAdd: Map>) { originalRepo.add(toAdd) toAdd.forEach { (k, v) -> diff --git a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValuesCacheRepo.kt b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValuesCacheRepo.kt index c2ecb6679d3..0946cb5c8fe 100644 --- a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValuesCacheRepo.kt +++ b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/full/FullKeyValuesCacheRepo.kt @@ -157,6 +157,10 @@ open class FullKeyValuesCacheRepo( override suspend fun invalidate() { kvCache.actualizeAll(parentRepo) } + + override suspend fun removeWithValue(v: Value) { + super.removeWithValue(v) + } } fun KeyValuesRepo.fullyCached( diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/KeyValuesRepo.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/KeyValuesRepo.kt index 1754abb70b8..57e8a6331c9 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/KeyValuesRepo.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/KeyValuesRepo.kt @@ -1,6 +1,7 @@ package dev.inmo.micro_utils.repos import dev.inmo.micro_utils.pagination.* +import dev.inmo.micro_utils.pagination.utils.doForAllWithNextPaging import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging import kotlinx.coroutines.flow.Flow @@ -44,9 +45,23 @@ interface WriteKeyValuesRepo : Repo { suspend fun add(toAdd: Map>) + /** + * Removes [Value]s by passed [Key]s without full clear of all data by [Key] + */ suspend fun remove(toRemove: Map>) + /** + * Removes [v] without full clear of all data by [Key]s with [v] + */ + suspend fun removeWithValue(v: Value) + + /** + * Fully clear all data by [k] + */ suspend fun clear(k: Key) + /** + * Clear [v] **with** full clear of all data by [Key]s with [v] + */ suspend fun clearWithValue(v: Value) suspend fun set(toSet: Map>) { @@ -100,6 +115,21 @@ interface KeyValuesRepo : ReadKeyValuesRepo, WriteKeyVal keysResult.currentPageIfNotEmpty() } } + suspend override fun removeWithValue(v: Value) { + val toRemove = mutableMapOf>() + + doForAllWithNextPaging { + keys(it).also { + it.results.forEach { + if (contains(it, v)) { + toRemove[it] = listOf(v) + } + } + } + } + + remove(toRemove) + } } typealias OneToManyKeyValueRepo = KeyValuesRepo diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt index 93b165e4c58..fbedd977906 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt @@ -97,6 +97,8 @@ open class MapperWriteKeyValuesRepo( }.toMap() ) + override suspend fun removeWithValue(v: FromValue) = to.removeWithValue(v.toOutValue()) + override suspend fun set(toSet: Map>) { to.set( toSet.map { (k, vs) -> k.toOutKey() to vs.map { v -> v.toOutValue() } }.toMap() diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/transforms/kvs/KeyValuesFromKeyValueRepo.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/transforms/kvs/KeyValuesFromKeyValueRepo.kt index 7473599f14f..8248959b704 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/transforms/kvs/KeyValuesFromKeyValueRepo.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/transforms/kvs/KeyValuesFromKeyValueRepo.kt @@ -4,6 +4,7 @@ import dev.inmo.micro_utils.pagination.FirstPagePagination import dev.inmo.micro_utils.pagination.utils.doForAllWithNextPaging import dev.inmo.micro_utils.repos.KeyValueRepo import dev.inmo.micro_utils.repos.KeyValuesRepo +import dev.inmo.micro_utils.repos.set import dev.inmo.micro_utils.repos.unset import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow @@ -60,6 +61,24 @@ open class KeyValuesFromKeyValueRepo>() + + doForAllWithNextPaging { + original.keys(it).also { + it.results.forEach { + val data = original.get(it) ?: return@forEach + + if (v in data) { + toRemove[it] = listOf(v) + } + } + } + } + + remove(toRemove) + } + override suspend fun add(toAdd: Map>) { original.set( toAdd.mapNotNull { (k, adding) -> diff --git a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt index 11a29614c39..b923563760b 100644 --- a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt +++ b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt @@ -6,6 +6,7 @@ import dev.inmo.micro_utils.common.mapNotNullA import dev.inmo.micro_utils.pagination.* import dev.inmo.micro_utils.pagination.utils.reverse import dev.inmo.micro_utils.repos.* +import dev.inmo.micro_utils.repos.crud.asId import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow @@ -260,6 +261,19 @@ class OneToManyAndroidRepo( _onValueRemoved.emit(k to v) } } + + override suspend fun removeWithValue(v: Value) { + helper.blockingWritableTransaction { + val keys = select(tableName, idColumnArray, "$valueColumnName=?", arrayOf(v.valueAsString())).map { + it.asId.keyFromString() + } + keys.filter { + delete(tableName, "$idColumnName=? AND $valueColumnName=?", arrayOf(it.keyAsString(), v.valueAsString())) > 0 + } + }.forEach { k -> + _onValueRemoved.emit(k to v) + } + } } fun OneToManyAndroidRepo( diff --git a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedKeyValuesRepo.kt b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedKeyValuesRepo.kt index 9b79231c8bc..456f2c3106d 100644 --- a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedKeyValuesRepo.kt +++ b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedKeyValuesRepo.kt @@ -5,6 +5,7 @@ import dev.inmo.micro_utils.repos.exposed.ColumnAllocator import kotlinx.coroutines.flow.* import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq +import org.jetbrains.exposed.sql.SqlExpressionBuilder.inList import org.jetbrains.exposed.sql.transactions.transaction typealias ExposedOneToManyKeyValueRepo1 = ExposedKeyValuesRepo @@ -66,9 +67,36 @@ open class ExposedKeyValuesRepo( } } + override suspend fun removeWithValue(v: Value) { + transaction(database) { + val keys = select { selectByValue(v) }.map { it.asKey } + deleteWhere { SqlExpressionBuilder.selectByValue(v) } + keys + }.forEach { + _onValueRemoved.emit(it to v) + } + } + override suspend fun clear(k: Key) { transaction(database) { deleteWhere { keyColumn.eq(k) } }.also { _onDataCleared.emit(k) } } + + override suspend fun clearWithValue(v: Value) { + transaction(database) { + val toClear = select { selectByValue(v) } + .asSequence() + .map { it.asKey to it.asObject } + .groupBy { it.first } + .mapValues { it.value.map { it.second } } + deleteWhere { keyColumn.inList(toClear.keys) } + toClear + }.forEach { + it.value.forEach { v -> + _onValueRemoved.emit(it.key to v) + } + _onDataCleared.emit(it.key) + } + } } diff --git a/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValuesRepo.kt b/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValuesRepo.kt index cfe8dff41e8..48acbabd108 100644 --- a/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValuesRepo.kt +++ b/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValuesRepo.kt @@ -87,13 +87,27 @@ class MapWriteKeyValuesRepo( } } + override suspend fun removeWithValue(v: Value) { + map.forEach { (k, values) -> + if (values.remove(v)) { + _onValueRemoved.emit(k to v) + } + } + } + override suspend fun clear(k: Key) { map.remove(k) ?.also { _onDataCleared.emit(k) } } override suspend fun clearWithValue(v: Value) { - map.forEach { (k, values) -> - if (values.remove(v)) _onValueRemoved.emit(k to v) + map.filter { (_, values) -> + values.contains(v) + }.forEach { + map.remove(it.key) ?.onEach { v -> + _onValueRemoved.emit(it.key to v) + } ?.also { _ -> + _onDataCleared.emit(it.key) + } } } } diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key/values/KtorWriteKeyValuesRepoClient.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key/values/KtorWriteKeyValuesRepoClient.kt index 37f14d66b49..5fe28f0a7af 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key/values/KtorWriteKeyValuesRepoClient.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key/values/KtorWriteKeyValuesRepoClient.kt @@ -47,6 +47,17 @@ class KtorWriteKeyValuesRepoClient( }.throwOnUnsuccess { "Unable to remove $toRemove" } } + @OptIn(InternalAPI::class) + override suspend fun removeWithValue(v: Value) { + httpClient.post( + buildStandardUrl(baseUrl, removeWithValueRoute) + ) { + body = v + bodyType = valueTypeInfo + contentType(contentType) + }.throwOnUnsuccess { "Unable to remove $v" } + } + @OptIn(InternalAPI::class) override suspend fun clear(k: Key) { httpClient.post( diff --git a/repos/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/common/one_to_many/OneToManyRoutes.kt b/repos/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/common/one_to_many/OneToManyRoutes.kt index 3bd568bb3a4..00b895d6cbe 100644 --- a/repos/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/common/one_to_many/OneToManyRoutes.kt +++ b/repos/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/common/one_to_many/OneToManyRoutes.kt @@ -13,6 +13,7 @@ const val onDataClearedRoute = "onDataCleared" const val addRoute = "add" const val removeRoute = "remove" +const val removeWithValueRoute = "removeWithValue" const val clearRoute = "clear" const val clearWithValueRoute = "clearWithValue" const val setRoute = "set" diff --git a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/key/values/KtorWriteKeyValuesRepoRoutes.kt b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/key/values/KtorWriteKeyValuesRepoRoutes.kt index 0a37c28f67c..3f78ca0a7be 100644 --- a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/key/values/KtorWriteKeyValuesRepoRoutes.kt +++ b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/key/values/KtorWriteKeyValuesRepoRoutes.kt @@ -46,6 +46,11 @@ inline fun Route.configureWriteKeyValue call.respond(HttpStatusCode.OK) } + post(removeWithValueRoute) { + originalRepo.removeWithValue(call.receive()) + call.respond(HttpStatusCode.OK) + } + post(clearRoute) { originalRepo.clear(call.receive()) call.respond(HttpStatusCode.OK) From 46c1887cbe9a576f9c48ef1b313583905a7cbd56 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 27 Apr 2023 12:06:50 +0600 Subject: [PATCH 07/13] remove usage of cache updates flows in autorecached repos --- .../repos/cache/fallback/crud/AutoRecacheWriteCRUDRepo.kt | 4 ++-- .../cache/fallback/keyvalue/AutoRecacheWriteKeyValueRepo.kt | 4 ++-- .../cache/fallback/keyvalues/AutoRecacheWriteKeyValuesRepo.kt | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/crud/AutoRecacheWriteCRUDRepo.kt b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/crud/AutoRecacheWriteCRUDRepo.kt index ca15411096e..f3ff4c15ff2 100644 --- a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/crud/AutoRecacheWriteCRUDRepo.kt +++ b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/crud/AutoRecacheWriteCRUDRepo.kt @@ -21,9 +21,9 @@ open class AutoRecacheWriteCRUDRepo( protected val idGetter: (RegisteredObject) -> Id ) : WriteCRUDRepo, FallbackCacheRepo { override val deletedObjectsIdsFlow: Flow - get() = (originalRepo.deletedObjectsIdsFlow + kvCache.onValueRemoved).distinctUntilChanged() + get() = (originalRepo.deletedObjectsIdsFlow).distinctUntilChanged() override val newObjectsFlow: Flow - get() = (originalRepo.newObjectsFlow + kvCache.onNewValue.map { it.second }).distinctUntilChanged() + get() = (originalRepo.newObjectsFlow).distinctUntilChanged() override val updatedObjectsFlow: Flow get() = originalRepo.updatedObjectsFlow diff --git a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/keyvalue/AutoRecacheWriteKeyValueRepo.kt b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/keyvalue/AutoRecacheWriteKeyValueRepo.kt index 8a725629b36..68f18b5391e 100644 --- a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/keyvalue/AutoRecacheWriteKeyValueRepo.kt +++ b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/keyvalue/AutoRecacheWriteKeyValueRepo.kt @@ -17,10 +17,10 @@ open class AutoRecacheWriteKeyValueRepo( protected val kvCache: FullKVCache = FullKVCache() ) : WriteKeyValueRepo, FallbackCacheRepo { override val onValueRemoved: Flow - get() = (originalRepo.onValueRemoved + kvCache.onValueRemoved).distinctUntilChanged() + get() = (originalRepo.onValueRemoved).distinctUntilChanged() override val onNewValue: Flow> - get() = (originalRepo.onNewValue + kvCache.onNewValue).distinctUntilChanged() + get() = (originalRepo.onNewValue).distinctUntilChanged() private val onRemovingUpdatesListeningJob = originalRepo.onValueRemoved.subscribeSafelyWithoutExceptions(scope) { kvCache.unset(it) diff --git a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/keyvalues/AutoRecacheWriteKeyValuesRepo.kt b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/keyvalues/AutoRecacheWriteKeyValuesRepo.kt index 86ca7c71c85..cd34593ec3c 100644 --- a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/keyvalues/AutoRecacheWriteKeyValuesRepo.kt +++ b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/fallback/keyvalues/AutoRecacheWriteKeyValuesRepo.kt @@ -25,7 +25,7 @@ open class AutoRecacheWriteKeyValuesRepo( override val onNewValue: Flow> get() = originalRepo.onNewValue override val onDataCleared: Flow - get() = (originalRepo.onDataCleared + kvCache.onValueRemoved).distinctUntilChanged() + get() = (originalRepo.onDataCleared).distinctUntilChanged() private val onDataClearedListeningJob = originalRepo.onDataCleared.subscribeSafelyWithoutExceptions(scope) { kvCache.unset(it) From 0f0d0b5d58022ac69e1ba31f1dbe4dab1c0f6c4d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 27 Apr 2023 12:16:48 +0600 Subject: [PATCH 08/13] update android fragments dependency --- CHANGELOG.md | 2 ++ gradle/libs.versions.toml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ff14ecf7e6..e60ffdc7e4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.18.0 +* `Versions`: + * `Android Fragments`: `1.5.6` -> `1.5.7` * `Ktor`: * `Server`: * Now it is possible to take query parameters as list diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 59dde185223..250c3e379c5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -30,7 +30,7 @@ dexcount = "4.0.0" android-coreKtx = "1.10.0" android-recyclerView = "1.3.0" android-appCompat = "1.6.1" -android-fragment = "1.5.6" +android-fragment = "1.5.7" android-espresso = "3.5.1" android-test = "1.1.5" From 5edb0e1331cc99e575cc821351339296be35bc31 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 27 Apr 2023 14:15:45 +0600 Subject: [PATCH 09/13] trying to update up to gradle wrapper 8.1.1 --- crypto/build.gradle | 8 ------ defaultAndroidSettings.gradle | 1 + dokka/build.gradle | 24 ---------------- gradle.properties | 1 + gradle/libs.versions.toml | 7 ++--- gradle/wrapper/gradle-wrapper.properties | 2 +- jvm.publish.gradle | 36 +++++++++++++----------- koin/generator/build.gradle | 9 ++++++ language_codes/generator/build.gradle | 4 +++ publish.gradle | 3 +- repos/generator/build.gradle | 9 ++++++ settings.gradle | 2 -- 12 files changed, 49 insertions(+), 57 deletions(-) diff --git a/crypto/build.gradle b/crypto/build.gradle index 686093b86f0..18da1fa2ddf 100644 --- a/crypto/build.gradle +++ b/crypto/build.gradle @@ -21,11 +21,3 @@ kotlin { } } } - -android { - sourceSets { - main { - java.srcDirs += [ "src/jvmMain/kotlin" ] - } - } -} diff --git a/defaultAndroidSettings.gradle b/defaultAndroidSettings.gradle index 267a33409e6..5d62eac2348 100644 --- a/defaultAndroidSettings.gradle +++ b/defaultAndroidSettings.gradle @@ -1,6 +1,7 @@ apply plugin: 'com.getkeepsafe.dexcount' android { + namespace "${group}.${project.name}" compileSdkVersion libs.versions.android.props.compileSdk.get().toInteger() buildToolsVersion libs.versions.android.props.buildTools.get() diff --git a/dokka/build.gradle b/dokka/build.gradle index 045902ca9fa..06c51c8fd01 100644 --- a/dokka/build.gradle +++ b/dokka/build.gradle @@ -13,10 +13,6 @@ repositories { kotlin { jvm() -// js(IR) { -// browser() -// nodejs() -// } android {} sourceSets { @@ -38,22 +34,6 @@ kotlin { } } } -// jsMain { -// dependencies { -// implementation kotlin('stdlib') - -// project.parent.subprojects.forEach { -// if ( -// it != project -// && it.hasProperty("kotlin") -// && it.kotlin.sourceSets.any { it.name.contains("commonMain") } -// && it.kotlin.sourceSets.any { it.name.contains("jsMain") } -// ) { -// api it -// } -// } -// } -// } jvmMain { dependencies { implementation kotlin('stdlib') @@ -116,10 +96,6 @@ tasks.dokkaHtml { sourceRoots.setFrom(findSourcesWithName("commonMain")) } -// named("jsMain") { -// sourceRoots.setFrom(findSourcesWithName("jsMain", "commonMain")) -// } - named("jvmMain") { sourceRoots.setFrom(findSourcesWithName("jvmMain")) } diff --git a/gradle.properties b/gradle.properties index 5db53e2a94f..11257c615d1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,7 @@ org.gradle.parallel=true kotlin.js.generate.externals=true kotlin.incremental=true kotlin.incremental.js=true +kotlin.mpp.androidSourceSetLayoutVersion=2 android.useAndroidX=true android.enableJetifier=true org.gradle.jvmargs=-Xmx2g diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 250c3e379c5..57c71a42f2d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -42,6 +42,9 @@ android-props-buildTools = "33.0.2" kt-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kt" } kt-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kt" } +kt-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kt" } +kt-test-common = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "kt" } +kt-test-annotations-common = { module = "org.jetbrains.kotlin:kotlin-test-annotations-common", version.ref = "kt" } kt-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kt-serialization" } kt-serialization-cbor = { module = "org.jetbrains.kotlinx:kotlinx-serialization-cbor", version.ref = "kt-serialization" } @@ -85,10 +88,6 @@ android-fragment = { module = "androidx.fragment:fragment", version.ref = "andro android-espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "android-espresso" } android-test-junit = { module = "androidx.test.ext:junit", version.ref = "android-test" } - -kt-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref = "kt" } -kt-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kt" } - # ksp dependencies kotlin-poet = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlin-poet" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 774fae87671..fae08049a6f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/jvm.publish.gradle b/jvm.publish.gradle index 074de9bf513..86427b68ae6 100644 --- a/jvm.publish.gradle +++ b/jvm.publish.gradle @@ -2,11 +2,13 @@ apply plugin: 'maven-publish' task javadocJar(type: Jar) { from javadoc - classifier = 'javadoc' + archiveClassifier.convention("javadoc") + archiveClassifier.set("javadoc") } task sourcesJar(type: Jar) { from sourceSets.main.allSource - classifier = 'sources' + archiveClassifier.convention("sources") + archiveClassifier.set("sources") } publishing { @@ -30,29 +32,29 @@ publishing { } developers { - + developer { id = "InsanusMokrassar" name = "Aleksei Ovsiannikov" email = "ovsyannikov.alexey95@gmail.com" } - + developer { id = "000Sanya" name = "Syrov Aleksandr" email = "000sanya.000sanya@gmail.com" } - + } licenses { - + license { name = "Apache Software License 2.0" url = "https://github.com/InsanusMokrassar/MicroUtils/blob/master/LICENSE" } - + } } repositories { @@ -60,40 +62,40 @@ publishing { maven { name = "GithubPackages" url = uri("https://maven.pkg.github.com/InsanusMokrassar/MicroUtils") - + credentials { username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER') password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD') } - + } } if (project.hasProperty('GITEA_TOKEN') || System.getenv('GITEA_TOKEN') != null) { maven { name = "Gitea" url = uri("https://git.inmo.dev/api/packages/InsanusMokrassar/maven") - + credentials(HttpHeaderCredentials) { name = "Authorization" value = project.hasProperty('GITEA_TOKEN') ? project.property('GITEA_TOKEN') : System.getenv('GITEA_TOKEN') } - + authentication { header(HttpHeaderAuthentication) } - + } } if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) { maven { name = "sonatype" url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - + credentials { username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER') password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') } - + } } } @@ -103,13 +105,13 @@ publishing { if (project.hasProperty("signing.gnupg.keyName")) { apply plugin: 'signing' - + signing { useGpgCmd() - + sign publishing.publications } - + task signAll { tasks.withType(Sign).forEach { dependsOn(it) diff --git a/koin/generator/build.gradle b/koin/generator/build.gradle index dc08c5eb3a6..372fe9025bd 100644 --- a/koin/generator/build.gradle +++ b/koin/generator/build.gradle @@ -13,3 +13,12 @@ dependencies { api libs.kotlin.poet api libs.ksp } + +kotlin { + jvmToolchain(8) +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} diff --git a/language_codes/generator/build.gradle b/language_codes/generator/build.gradle index 4b3027381f8..f8fff532752 100644 --- a/language_codes/generator/build.gradle +++ b/language_codes/generator/build.gradle @@ -25,6 +25,10 @@ dependencies { mainClassName="MainKt" +kotlin { + jvmToolchain(8) +} + java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 diff --git a/publish.gradle b/publish.gradle index d3300addb04..d7c9a873f1e 100644 --- a/publish.gradle +++ b/publish.gradle @@ -1,7 +1,8 @@ apply plugin: 'maven-publish' task javadocsJar(type: Jar) { - classifier = 'javadoc' + archiveClassifier.convention("javadoc") + archiveClassifier.set("javadoc") } publishing { diff --git a/repos/generator/build.gradle b/repos/generator/build.gradle index 112b1af1eac..32c89100548 100644 --- a/repos/generator/build.gradle +++ b/repos/generator/build.gradle @@ -14,3 +14,12 @@ dependencies { api libs.kotlin.poet api libs.ksp } + +kotlin { + jvmToolchain(8) +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} diff --git a/settings.gradle b/settings.gradle index ec21091c550..e542629aa15 100644 --- a/settings.gradle +++ b/settings.gradle @@ -57,5 +57,3 @@ includes.each { originalName -> project.name = projectName project.projectDir = new File(projectDirectory) } - -enableFeaturePreview("VERSION_CATALOGS") From 58836359cc77004977ce46dd2d69200417cdc5d8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 27 Apr 2023 15:00:43 +0600 Subject: [PATCH 10/13] Revert "trying to update up to gradle wrapper 8.1.1" This reverts commit 5edb0e1331cc99e575cc821351339296be35bc31. --- crypto/build.gradle | 8 ++++++ defaultAndroidSettings.gradle | 1 - dokka/build.gradle | 24 ++++++++++++++++ gradle.properties | 1 - gradle/libs.versions.toml | 7 +++-- gradle/wrapper/gradle-wrapper.properties | 2 +- jvm.publish.gradle | 36 +++++++++++------------- koin/generator/build.gradle | 9 ------ language_codes/generator/build.gradle | 4 --- publish.gradle | 3 +- repos/generator/build.gradle | 9 ------ settings.gradle | 2 ++ 12 files changed, 57 insertions(+), 49 deletions(-) diff --git a/crypto/build.gradle b/crypto/build.gradle index 18da1fa2ddf..686093b86f0 100644 --- a/crypto/build.gradle +++ b/crypto/build.gradle @@ -21,3 +21,11 @@ kotlin { } } } + +android { + sourceSets { + main { + java.srcDirs += [ "src/jvmMain/kotlin" ] + } + } +} diff --git a/defaultAndroidSettings.gradle b/defaultAndroidSettings.gradle index 5d62eac2348..267a33409e6 100644 --- a/defaultAndroidSettings.gradle +++ b/defaultAndroidSettings.gradle @@ -1,7 +1,6 @@ apply plugin: 'com.getkeepsafe.dexcount' android { - namespace "${group}.${project.name}" compileSdkVersion libs.versions.android.props.compileSdk.get().toInteger() buildToolsVersion libs.versions.android.props.buildTools.get() diff --git a/dokka/build.gradle b/dokka/build.gradle index 06c51c8fd01..045902ca9fa 100644 --- a/dokka/build.gradle +++ b/dokka/build.gradle @@ -13,6 +13,10 @@ repositories { kotlin { jvm() +// js(IR) { +// browser() +// nodejs() +// } android {} sourceSets { @@ -34,6 +38,22 @@ kotlin { } } } +// jsMain { +// dependencies { +// implementation kotlin('stdlib') + +// project.parent.subprojects.forEach { +// if ( +// it != project +// && it.hasProperty("kotlin") +// && it.kotlin.sourceSets.any { it.name.contains("commonMain") } +// && it.kotlin.sourceSets.any { it.name.contains("jsMain") } +// ) { +// api it +// } +// } +// } +// } jvmMain { dependencies { implementation kotlin('stdlib') @@ -96,6 +116,10 @@ tasks.dokkaHtml { sourceRoots.setFrom(findSourcesWithName("commonMain")) } +// named("jsMain") { +// sourceRoots.setFrom(findSourcesWithName("jsMain", "commonMain")) +// } + named("jvmMain") { sourceRoots.setFrom(findSourcesWithName("jvmMain")) } diff --git a/gradle.properties b/gradle.properties index 11257c615d1..5db53e2a94f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,6 @@ org.gradle.parallel=true kotlin.js.generate.externals=true kotlin.incremental=true kotlin.incremental.js=true -kotlin.mpp.androidSourceSetLayoutVersion=2 android.useAndroidX=true android.enableJetifier=true org.gradle.jvmargs=-Xmx2g diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 57c71a42f2d..250c3e379c5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -42,9 +42,6 @@ android-props-buildTools = "33.0.2" kt-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kt" } kt-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kt" } -kt-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kt" } -kt-test-common = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "kt" } -kt-test-annotations-common = { module = "org.jetbrains.kotlin:kotlin-test-annotations-common", version.ref = "kt" } kt-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kt-serialization" } kt-serialization-cbor = { module = "org.jetbrains.kotlinx:kotlinx-serialization-cbor", version.ref = "kt-serialization" } @@ -88,6 +85,10 @@ android-fragment = { module = "androidx.fragment:fragment", version.ref = "andro android-espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "android-espresso" } android-test-junit = { module = "androidx.test.ext:junit", version.ref = "android-test" } + +kt-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref = "kt" } +kt-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kt" } + # ksp dependencies kotlin-poet = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlin-poet" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fae08049a6f..774fae87671 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/jvm.publish.gradle b/jvm.publish.gradle index 86427b68ae6..074de9bf513 100644 --- a/jvm.publish.gradle +++ b/jvm.publish.gradle @@ -2,13 +2,11 @@ apply plugin: 'maven-publish' task javadocJar(type: Jar) { from javadoc - archiveClassifier.convention("javadoc") - archiveClassifier.set("javadoc") + classifier = 'javadoc' } task sourcesJar(type: Jar) { from sourceSets.main.allSource - archiveClassifier.convention("sources") - archiveClassifier.set("sources") + classifier = 'sources' } publishing { @@ -32,29 +30,29 @@ publishing { } developers { - + developer { id = "InsanusMokrassar" name = "Aleksei Ovsiannikov" email = "ovsyannikov.alexey95@gmail.com" } - + developer { id = "000Sanya" name = "Syrov Aleksandr" email = "000sanya.000sanya@gmail.com" } - + } licenses { - + license { name = "Apache Software License 2.0" url = "https://github.com/InsanusMokrassar/MicroUtils/blob/master/LICENSE" } - + } } repositories { @@ -62,40 +60,40 @@ publishing { maven { name = "GithubPackages" url = uri("https://maven.pkg.github.com/InsanusMokrassar/MicroUtils") - + credentials { username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER') password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD') } - + } } if (project.hasProperty('GITEA_TOKEN') || System.getenv('GITEA_TOKEN') != null) { maven { name = "Gitea" url = uri("https://git.inmo.dev/api/packages/InsanusMokrassar/maven") - + credentials(HttpHeaderCredentials) { name = "Authorization" value = project.hasProperty('GITEA_TOKEN') ? project.property('GITEA_TOKEN') : System.getenv('GITEA_TOKEN') } - + authentication { header(HttpHeaderAuthentication) } - + } } if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) { maven { name = "sonatype" url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - + credentials { username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER') password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') } - + } } } @@ -105,13 +103,13 @@ publishing { if (project.hasProperty("signing.gnupg.keyName")) { apply plugin: 'signing' - + signing { useGpgCmd() - + sign publishing.publications } - + task signAll { tasks.withType(Sign).forEach { dependsOn(it) diff --git a/koin/generator/build.gradle b/koin/generator/build.gradle index 372fe9025bd..dc08c5eb3a6 100644 --- a/koin/generator/build.gradle +++ b/koin/generator/build.gradle @@ -13,12 +13,3 @@ dependencies { api libs.kotlin.poet api libs.ksp } - -kotlin { - jvmToolchain(8) -} - -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 -} diff --git a/language_codes/generator/build.gradle b/language_codes/generator/build.gradle index f8fff532752..4b3027381f8 100644 --- a/language_codes/generator/build.gradle +++ b/language_codes/generator/build.gradle @@ -25,10 +25,6 @@ dependencies { mainClassName="MainKt" -kotlin { - jvmToolchain(8) -} - java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 diff --git a/publish.gradle b/publish.gradle index d7c9a873f1e..d3300addb04 100644 --- a/publish.gradle +++ b/publish.gradle @@ -1,8 +1,7 @@ apply plugin: 'maven-publish' task javadocsJar(type: Jar) { - archiveClassifier.convention("javadoc") - archiveClassifier.set("javadoc") + classifier = 'javadoc' } publishing { diff --git a/repos/generator/build.gradle b/repos/generator/build.gradle index 32c89100548..112b1af1eac 100644 --- a/repos/generator/build.gradle +++ b/repos/generator/build.gradle @@ -14,12 +14,3 @@ dependencies { api libs.kotlin.poet api libs.ksp } - -kotlin { - jvmToolchain(8) -} - -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 -} diff --git a/settings.gradle b/settings.gradle index e542629aa15..ec21091c550 100644 --- a/settings.gradle +++ b/settings.gradle @@ -57,3 +57,5 @@ includes.each { originalName -> project.name = projectName project.projectDir = new File(projectDirectory) } + +enableFeaturePreview("VERSION_CATALOGS") From b938b2139549c8124101957f48e6bad2ef9db477 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 27 Apr 2023 15:27:53 +0600 Subject: [PATCH 11/13] Get back some functional of "trying to update up to gradle wrapper 8.1.1" --- crypto/build.gradle | 8 ------ defaultAndroidSettings.gradle | 1 + dokka/build.gradle | 24 ---------------- gradle.properties | 1 + gradle/libs.versions.toml | 7 ++--- gradle/wrapper/gradle-wrapper.properties | 2 +- jvm.publish.gradle | 36 +++++++++++++----------- koin/generator/build.gradle | 9 ++++++ language_codes/generator/build.gradle | 4 +++ publish.gradle | 3 +- repos/generator/build.gradle | 9 ++++++ settings.gradle | 2 -- 12 files changed, 49 insertions(+), 57 deletions(-) diff --git a/crypto/build.gradle b/crypto/build.gradle index 686093b86f0..18da1fa2ddf 100644 --- a/crypto/build.gradle +++ b/crypto/build.gradle @@ -21,11 +21,3 @@ kotlin { } } } - -android { - sourceSets { - main { - java.srcDirs += [ "src/jvmMain/kotlin" ] - } - } -} diff --git a/defaultAndroidSettings.gradle b/defaultAndroidSettings.gradle index 267a33409e6..5d62eac2348 100644 --- a/defaultAndroidSettings.gradle +++ b/defaultAndroidSettings.gradle @@ -1,6 +1,7 @@ apply plugin: 'com.getkeepsafe.dexcount' android { + namespace "${group}.${project.name}" compileSdkVersion libs.versions.android.props.compileSdk.get().toInteger() buildToolsVersion libs.versions.android.props.buildTools.get() diff --git a/dokka/build.gradle b/dokka/build.gradle index 045902ca9fa..06c51c8fd01 100644 --- a/dokka/build.gradle +++ b/dokka/build.gradle @@ -13,10 +13,6 @@ repositories { kotlin { jvm() -// js(IR) { -// browser() -// nodejs() -// } android {} sourceSets { @@ -38,22 +34,6 @@ kotlin { } } } -// jsMain { -// dependencies { -// implementation kotlin('stdlib') - -// project.parent.subprojects.forEach { -// if ( -// it != project -// && it.hasProperty("kotlin") -// && it.kotlin.sourceSets.any { it.name.contains("commonMain") } -// && it.kotlin.sourceSets.any { it.name.contains("jsMain") } -// ) { -// api it -// } -// } -// } -// } jvmMain { dependencies { implementation kotlin('stdlib') @@ -116,10 +96,6 @@ tasks.dokkaHtml { sourceRoots.setFrom(findSourcesWithName("commonMain")) } -// named("jsMain") { -// sourceRoots.setFrom(findSourcesWithName("jsMain", "commonMain")) -// } - named("jvmMain") { sourceRoots.setFrom(findSourcesWithName("jvmMain")) } diff --git a/gradle.properties b/gradle.properties index 5db53e2a94f..4820c726d7b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,7 @@ org.gradle.parallel=true kotlin.js.generate.externals=true kotlin.incremental=true kotlin.incremental.js=true +#kotlin.mpp.androidSourceSetLayoutVersion=2 android.useAndroidX=true android.enableJetifier=true org.gradle.jvmargs=-Xmx2g diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 250c3e379c5..57c71a42f2d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -42,6 +42,9 @@ android-props-buildTools = "33.0.2" kt-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kt" } kt-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kt" } +kt-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kt" } +kt-test-common = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "kt" } +kt-test-annotations-common = { module = "org.jetbrains.kotlin:kotlin-test-annotations-common", version.ref = "kt" } kt-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kt-serialization" } kt-serialization-cbor = { module = "org.jetbrains.kotlinx:kotlinx-serialization-cbor", version.ref = "kt-serialization" } @@ -85,10 +88,6 @@ android-fragment = { module = "androidx.fragment:fragment", version.ref = "andro android-espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "android-espresso" } android-test-junit = { module = "androidx.test.ext:junit", version.ref = "android-test" } - -kt-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref = "kt" } -kt-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kt" } - # ksp dependencies kotlin-poet = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlin-poet" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 774fae87671..fae08049a6f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/jvm.publish.gradle b/jvm.publish.gradle index 074de9bf513..86427b68ae6 100644 --- a/jvm.publish.gradle +++ b/jvm.publish.gradle @@ -2,11 +2,13 @@ apply plugin: 'maven-publish' task javadocJar(type: Jar) { from javadoc - classifier = 'javadoc' + archiveClassifier.convention("javadoc") + archiveClassifier.set("javadoc") } task sourcesJar(type: Jar) { from sourceSets.main.allSource - classifier = 'sources' + archiveClassifier.convention("sources") + archiveClassifier.set("sources") } publishing { @@ -30,29 +32,29 @@ publishing { } developers { - + developer { id = "InsanusMokrassar" name = "Aleksei Ovsiannikov" email = "ovsyannikov.alexey95@gmail.com" } - + developer { id = "000Sanya" name = "Syrov Aleksandr" email = "000sanya.000sanya@gmail.com" } - + } licenses { - + license { name = "Apache Software License 2.0" url = "https://github.com/InsanusMokrassar/MicroUtils/blob/master/LICENSE" } - + } } repositories { @@ -60,40 +62,40 @@ publishing { maven { name = "GithubPackages" url = uri("https://maven.pkg.github.com/InsanusMokrassar/MicroUtils") - + credentials { username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER') password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD') } - + } } if (project.hasProperty('GITEA_TOKEN') || System.getenv('GITEA_TOKEN') != null) { maven { name = "Gitea" url = uri("https://git.inmo.dev/api/packages/InsanusMokrassar/maven") - + credentials(HttpHeaderCredentials) { name = "Authorization" value = project.hasProperty('GITEA_TOKEN') ? project.property('GITEA_TOKEN') : System.getenv('GITEA_TOKEN') } - + authentication { header(HttpHeaderAuthentication) } - + } } if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) { maven { name = "sonatype" url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - + credentials { username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER') password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') } - + } } } @@ -103,13 +105,13 @@ publishing { if (project.hasProperty("signing.gnupg.keyName")) { apply plugin: 'signing' - + signing { useGpgCmd() - + sign publishing.publications } - + task signAll { tasks.withType(Sign).forEach { dependsOn(it) diff --git a/koin/generator/build.gradle b/koin/generator/build.gradle index dc08c5eb3a6..372fe9025bd 100644 --- a/koin/generator/build.gradle +++ b/koin/generator/build.gradle @@ -13,3 +13,12 @@ dependencies { api libs.kotlin.poet api libs.ksp } + +kotlin { + jvmToolchain(8) +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} diff --git a/language_codes/generator/build.gradle b/language_codes/generator/build.gradle index 4b3027381f8..f8fff532752 100644 --- a/language_codes/generator/build.gradle +++ b/language_codes/generator/build.gradle @@ -25,6 +25,10 @@ dependencies { mainClassName="MainKt" +kotlin { + jvmToolchain(8) +} + java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 diff --git a/publish.gradle b/publish.gradle index d3300addb04..d7c9a873f1e 100644 --- a/publish.gradle +++ b/publish.gradle @@ -1,7 +1,8 @@ apply plugin: 'maven-publish' task javadocsJar(type: Jar) { - classifier = 'javadoc' + archiveClassifier.convention("javadoc") + archiveClassifier.set("javadoc") } publishing { diff --git a/repos/generator/build.gradle b/repos/generator/build.gradle index 112b1af1eac..32c89100548 100644 --- a/repos/generator/build.gradle +++ b/repos/generator/build.gradle @@ -14,3 +14,12 @@ dependencies { api libs.kotlin.poet api libs.ksp } + +kotlin { + jvmToolchain(8) +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} diff --git a/settings.gradle b/settings.gradle index ec21091c550..e542629aa15 100644 --- a/settings.gradle +++ b/settings.gradle @@ -57,5 +57,3 @@ includes.each { originalName -> project.name = projectName project.projectDir = new File(projectDirectory) } - -enableFeaturePreview("VERSION_CATALOGS") From 2877b5532c33768749d4c0d3519734038e1c2ebf Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 27 Apr 2023 16:24:58 +0600 Subject: [PATCH 12/13] Revert "Get back some functional of "trying to update up to gradle wrapper 8.1.1"" This reverts commit b938b2139549c8124101957f48e6bad2ef9db477. --- crypto/build.gradle | 8 ++++++ defaultAndroidSettings.gradle | 1 - dokka/build.gradle | 24 ++++++++++++++++ gradle.properties | 1 - gradle/libs.versions.toml | 7 +++-- gradle/wrapper/gradle-wrapper.properties | 2 +- jvm.publish.gradle | 36 +++++++++++------------- koin/generator/build.gradle | 9 ------ language_codes/generator/build.gradle | 4 --- publish.gradle | 3 +- repos/generator/build.gradle | 9 ------ settings.gradle | 2 ++ 12 files changed, 57 insertions(+), 49 deletions(-) diff --git a/crypto/build.gradle b/crypto/build.gradle index 18da1fa2ddf..686093b86f0 100644 --- a/crypto/build.gradle +++ b/crypto/build.gradle @@ -21,3 +21,11 @@ kotlin { } } } + +android { + sourceSets { + main { + java.srcDirs += [ "src/jvmMain/kotlin" ] + } + } +} diff --git a/defaultAndroidSettings.gradle b/defaultAndroidSettings.gradle index 5d62eac2348..267a33409e6 100644 --- a/defaultAndroidSettings.gradle +++ b/defaultAndroidSettings.gradle @@ -1,7 +1,6 @@ apply plugin: 'com.getkeepsafe.dexcount' android { - namespace "${group}.${project.name}" compileSdkVersion libs.versions.android.props.compileSdk.get().toInteger() buildToolsVersion libs.versions.android.props.buildTools.get() diff --git a/dokka/build.gradle b/dokka/build.gradle index 06c51c8fd01..045902ca9fa 100644 --- a/dokka/build.gradle +++ b/dokka/build.gradle @@ -13,6 +13,10 @@ repositories { kotlin { jvm() +// js(IR) { +// browser() +// nodejs() +// } android {} sourceSets { @@ -34,6 +38,22 @@ kotlin { } } } +// jsMain { +// dependencies { +// implementation kotlin('stdlib') + +// project.parent.subprojects.forEach { +// if ( +// it != project +// && it.hasProperty("kotlin") +// && it.kotlin.sourceSets.any { it.name.contains("commonMain") } +// && it.kotlin.sourceSets.any { it.name.contains("jsMain") } +// ) { +// api it +// } +// } +// } +// } jvmMain { dependencies { implementation kotlin('stdlib') @@ -96,6 +116,10 @@ tasks.dokkaHtml { sourceRoots.setFrom(findSourcesWithName("commonMain")) } +// named("jsMain") { +// sourceRoots.setFrom(findSourcesWithName("jsMain", "commonMain")) +// } + named("jvmMain") { sourceRoots.setFrom(findSourcesWithName("jvmMain")) } diff --git a/gradle.properties b/gradle.properties index 4820c726d7b..5db53e2a94f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,6 @@ org.gradle.parallel=true kotlin.js.generate.externals=true kotlin.incremental=true kotlin.incremental.js=true -#kotlin.mpp.androidSourceSetLayoutVersion=2 android.useAndroidX=true android.enableJetifier=true org.gradle.jvmargs=-Xmx2g diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 57c71a42f2d..250c3e379c5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -42,9 +42,6 @@ android-props-buildTools = "33.0.2" kt-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kt" } kt-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kt" } -kt-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kt" } -kt-test-common = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "kt" } -kt-test-annotations-common = { module = "org.jetbrains.kotlin:kotlin-test-annotations-common", version.ref = "kt" } kt-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kt-serialization" } kt-serialization-cbor = { module = "org.jetbrains.kotlinx:kotlinx-serialization-cbor", version.ref = "kt-serialization" } @@ -88,6 +85,10 @@ android-fragment = { module = "androidx.fragment:fragment", version.ref = "andro android-espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "android-espresso" } android-test-junit = { module = "androidx.test.ext:junit", version.ref = "android-test" } + +kt-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref = "kt" } +kt-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kt" } + # ksp dependencies kotlin-poet = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlin-poet" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fae08049a6f..774fae87671 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/jvm.publish.gradle b/jvm.publish.gradle index 86427b68ae6..074de9bf513 100644 --- a/jvm.publish.gradle +++ b/jvm.publish.gradle @@ -2,13 +2,11 @@ apply plugin: 'maven-publish' task javadocJar(type: Jar) { from javadoc - archiveClassifier.convention("javadoc") - archiveClassifier.set("javadoc") + classifier = 'javadoc' } task sourcesJar(type: Jar) { from sourceSets.main.allSource - archiveClassifier.convention("sources") - archiveClassifier.set("sources") + classifier = 'sources' } publishing { @@ -32,29 +30,29 @@ publishing { } developers { - + developer { id = "InsanusMokrassar" name = "Aleksei Ovsiannikov" email = "ovsyannikov.alexey95@gmail.com" } - + developer { id = "000Sanya" name = "Syrov Aleksandr" email = "000sanya.000sanya@gmail.com" } - + } licenses { - + license { name = "Apache Software License 2.0" url = "https://github.com/InsanusMokrassar/MicroUtils/blob/master/LICENSE" } - + } } repositories { @@ -62,40 +60,40 @@ publishing { maven { name = "GithubPackages" url = uri("https://maven.pkg.github.com/InsanusMokrassar/MicroUtils") - + credentials { username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER') password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD') } - + } } if (project.hasProperty('GITEA_TOKEN') || System.getenv('GITEA_TOKEN') != null) { maven { name = "Gitea" url = uri("https://git.inmo.dev/api/packages/InsanusMokrassar/maven") - + credentials(HttpHeaderCredentials) { name = "Authorization" value = project.hasProperty('GITEA_TOKEN') ? project.property('GITEA_TOKEN') : System.getenv('GITEA_TOKEN') } - + authentication { header(HttpHeaderAuthentication) } - + } } if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) { maven { name = "sonatype" url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - + credentials { username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER') password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') } - + } } } @@ -105,13 +103,13 @@ publishing { if (project.hasProperty("signing.gnupg.keyName")) { apply plugin: 'signing' - + signing { useGpgCmd() - + sign publishing.publications } - + task signAll { tasks.withType(Sign).forEach { dependsOn(it) diff --git a/koin/generator/build.gradle b/koin/generator/build.gradle index 372fe9025bd..dc08c5eb3a6 100644 --- a/koin/generator/build.gradle +++ b/koin/generator/build.gradle @@ -13,12 +13,3 @@ dependencies { api libs.kotlin.poet api libs.ksp } - -kotlin { - jvmToolchain(8) -} - -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 -} diff --git a/language_codes/generator/build.gradle b/language_codes/generator/build.gradle index f8fff532752..4b3027381f8 100644 --- a/language_codes/generator/build.gradle +++ b/language_codes/generator/build.gradle @@ -25,10 +25,6 @@ dependencies { mainClassName="MainKt" -kotlin { - jvmToolchain(8) -} - java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 diff --git a/publish.gradle b/publish.gradle index d7c9a873f1e..d3300addb04 100644 --- a/publish.gradle +++ b/publish.gradle @@ -1,8 +1,7 @@ apply plugin: 'maven-publish' task javadocsJar(type: Jar) { - archiveClassifier.convention("javadoc") - archiveClassifier.set("javadoc") + classifier = 'javadoc' } publishing { diff --git a/repos/generator/build.gradle b/repos/generator/build.gradle index 32c89100548..112b1af1eac 100644 --- a/repos/generator/build.gradle +++ b/repos/generator/build.gradle @@ -14,12 +14,3 @@ dependencies { api libs.kotlin.poet api libs.ksp } - -kotlin { - jvmToolchain(8) -} - -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 -} diff --git a/settings.gradle b/settings.gradle index e542629aa15..ec21091c550 100644 --- a/settings.gradle +++ b/settings.gradle @@ -57,3 +57,5 @@ includes.each { originalName -> project.name = projectName project.projectDir = new File(projectDirectory) } + +enableFeaturePreview("VERSION_CATALOGS") From d81fb32fb9f264fef2b6149be9b0aac6e0ebc051 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 27 Apr 2023 16:29:08 +0600 Subject: [PATCH 13/13] remove previous deprecations --- CHANGELOG.md | 2 ++ .../coroutines/compose/FlowToMutableState.kt | 21 ---------------- .../launcher/src/commonMain/kotlin/Start.kt | 17 ------------- .../src/jsMain/kotlin/PluginsStarter.kt | 25 ------------------- 4 files changed, 2 insertions(+), 63 deletions(-) delete mode 100644 coroutines/compose/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/compose/FlowToMutableState.kt delete mode 100644 startup/launcher/src/commonMain/kotlin/Start.kt delete mode 100644 startup/launcher/src/jsMain/kotlin/PluginsStarter.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index e60ffdc7e4d..8a4f3d85761 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.18.0 +**ALL PREVIOUSLY DEPRECATED FUNCTIONALITY HAVE BEEN REMOVED** + * `Versions`: * `Android Fragments`: `1.5.6` -> `1.5.7` * `Ktor`: diff --git a/coroutines/compose/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/compose/FlowToMutableState.kt b/coroutines/compose/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/compose/FlowToMutableState.kt deleted file mode 100644 index 92fba8f2176..00000000000 --- a/coroutines/compose/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/compose/FlowToMutableState.kt +++ /dev/null @@ -1,21 +0,0 @@ -package dev.inmo.micro_utils.coroutines.compose - -import androidx.compose.runtime.MutableState -import androidx.compose.runtime.mutableStateOf -import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.StateFlow - -@Deprecated("Duplicated functionality", ReplaceWith("asMutableComposeState(initial, scope)", "dev.inmo.micro_utils.coroutines.compose.asMutableComposeState")) -fun Flow.toMutableState( - initial: T, - scope: CoroutineScope -): MutableState = asMutableComposeState(initial, scope) - -@Deprecated("Duplicated functionality", ReplaceWith("asMutableComposeState(scope)", "dev.inmo.micro_utils.coroutines.compose.asMutableComposeState")) -@Suppress("NOTHING_TO_INLINE") -inline fun StateFlow.toMutableState( - scope: CoroutineScope -): MutableState = asMutableComposeState(scope) - diff --git a/startup/launcher/src/commonMain/kotlin/Start.kt b/startup/launcher/src/commonMain/kotlin/Start.kt deleted file mode 100644 index 3c3c715f50d..00000000000 --- a/startup/launcher/src/commonMain/kotlin/Start.kt +++ /dev/null @@ -1,17 +0,0 @@ -package dev.inmo.micro_utils.startup.launcher - -import dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin.setupDI -import kotlinx.serialization.json.JsonObject -import org.koin.core.KoinApplication - -/** - * Will create [KoinApplication], init, load modules using [StartLauncherPlugin] and start plugins using the same base - * plugin - * - * @param rawConfig It is expected that this [JsonObject] will contain serialized [Config] ([StartLauncherPlugin] will - * deserialize it in its [StartLauncherPlugin.setupDI] - */ -@Deprecated("Fully replaced with StartLauncherPlugin#start", ReplaceWith("StartLauncherPlugin.start(rawConfig)", "dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin")) -suspend fun start(rawConfig: JsonObject) { - StartLauncherPlugin.start(rawConfig) -} diff --git a/startup/launcher/src/jsMain/kotlin/PluginsStarter.kt b/startup/launcher/src/jsMain/kotlin/PluginsStarter.kt deleted file mode 100644 index c0a9944becf..00000000000 --- a/startup/launcher/src/jsMain/kotlin/PluginsStarter.kt +++ /dev/null @@ -1,25 +0,0 @@ -package dev.inmo.micro_utils.startup.launcher - -import dev.inmo.kslog.common.KSLog -import dev.inmo.kslog.common.i -import kotlinx.serialization.json.JsonObject -import kotlinx.serialization.json.jsonObject - -@Deprecated("Useless due to including of the same functionality in StrtLauncherPlugin") -object PluginsStarter { - init { - KSLog.default = KSLog("Launcher") - } - - /** - * It is expected that you have registered all the [dev.inmo.micro_utils.startup.plugin.StartPlugin]s of your JS - * app inside of [dev.inmo.micro_utils.startup.plugin.StartPluginSerializer] using its - * [dev.inmo.micro_utils.startup.plugin.StartPluginSerializer.registerPlugin] method - */ - suspend fun startPlugins(json: JsonObject) = StartLauncherPlugin.start(json) - /** - * Will convert [config] to [JsonObject] with auto registration of [dev.inmo.micro_utils.startup.plugin.StartPlugin]s - * in [dev.inmo.micro_utils.startup.plugin.StartPluginSerializer] - */ - suspend fun startPlugins(config: Config) = StartLauncherPlugin.start(config) -}