diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-09-28 13:08:57 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-09-28 13:08:57 +0200 |
commit | 1c021517808829418ac9bc8443e6b2653c869812 (patch) | |
tree | f9b626f24a2969f669ab2d939b6cd31a0d063d32 | |
parent | a3bfbe7f072217288c14e3f2c734bb5918564c33 (diff) | |
download | kvision-1c021517808829418ac9bc8443e6b2653c869812.tar.gz kvision-1c021517808829418ac9bc8443e6b2653c869812.tar.bz2 kvision-1c021517808829418ac9bc8443e6b2653c869812.zip |
Migration to Kotlin 1.3
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | build.gradle | 3 | ||||
-rw-r--r-- | gradle.properties | 8 | ||||
-rw-r--r-- | kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt | 2 | ||||
-rw-r--r-- | kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt | 13 | ||||
-rw-r--r-- | kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt | 4 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/form/Form.kt | 32 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/modal/Dialog.kt | 3 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt | 4 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/remote/Security.kt | 4 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt | 4 |
12 files changed, 33 insertions, 47 deletions
@@ -3,6 +3,7 @@ build/ out/ *.iml /build-mvn.sh +/build-mvnlocal.sh /upload.sh /src/main/kotlin/pl/treksoft/kvision/KVision.kt /src/main/kotlin/pl/treksoft/kvision/Main.kt diff --git a/build.gradle b/build.gradle index e8b8960f..b3c1da3a 100644 --- a/build.gradle +++ b/build.gradle @@ -12,10 +12,10 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}" + classpath "org.jetbrains.kotlin:kotlin-serialization:${kotlinVersion}" classpath "org.jetbrains.kotlin:kotlin-frontend-plugin:${frontendPluginVersion}" classpath "gradle.plugin.io.gitlab.arturbosch.detekt:detekt-gradle-plugin:${detektVersion}" classpath "org.jetbrains.dokka:dokka-gradle-plugin:${dokkaVersion}" - classpath "org.jetbrains.kotlinx:kotlinx-gradle-serialization-plugin:${serializationVersion}" classpath "io.spring.gradle:dependency-management-plugin:${dependencyManagementPluginVersion}" } } @@ -33,6 +33,7 @@ allprojects { repositories { jcenter() + maven { url = "https://dl.bintray.com/kotlin/kotlin-eap" } maven { url = 'https://kotlin.bintray.com/kotlinx' } maven { url = 'https://dl.bintray.com/gbaldeck/kotlin' } maven { url = 'https://dl.bintray.com/rjaros/kotlin' } diff --git a/gradle.properties b/gradle.properties index 4102a5fb..8bbe74bd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ group=pl.treksoft -version=0.0.17 -kotlinVersion=1.2.61 +version=0.0.18 +kotlinVersion=1.3.0-rc-116 javaVersion=1.8 -coroutinesVersion=0.24.0 -serializationVersion=0.6.1 +coroutinesVersion=0.26.1-eap13 +serializationVersion=0.8.1-rc13 frontendPluginVersion=0.0.37 dokkaVersion=0.9.17 detektVersion=1.0.0.RC8 diff --git a/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt b/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt index 1f31dec0..8225a785 100644 --- a/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt +++ b/kvision-common/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt @@ -21,7 +21,7 @@ */ package pl.treksoft.kvision.remote -import kotlinx.coroutines.experimental.Deferred +import kotlinx.coroutines.Deferred enum class RpcHttpMethod { POST, diff --git a/kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt b/kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt index 57fe1c36..928892a2 100644 --- a/kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt +++ b/kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/Jooby.kt @@ -24,13 +24,14 @@ package pl.treksoft.kvision.remote import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import kotlinx.coroutines.experimental.Deferred -import kotlinx.coroutines.experimental.Unconfined +import kotlinx.coroutines.Deferred +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope import org.jooby.Kooby import org.jooby.Session import org.jooby.json.Jackson import org.pac4j.core.profile.CommonProfile -import kotlinx.coroutines.experimental.async as coroutinesAsync +import kotlinx.coroutines.async as coroutinesAsync /** * A Jooby based server. @@ -63,7 +64,7 @@ actual typealias Profile = CommonProfile * A helper extension function for asynchronous request processing. */ fun <RESP> Request?.async(block: (Request) -> RESP): Deferred<RESP> = this?.let { req -> - coroutinesAsync(Unconfined) { + GlobalScope.coroutinesAsync(Dispatchers.Unconfined) { block(req) } } ?: throw IllegalStateException("Request not set!") @@ -73,7 +74,7 @@ fun <RESP> Request?.async(block: (Request) -> RESP): Deferred<RESP> = this?.let */ fun <RESP> Request?.async(block: (Request, Session) -> RESP): Deferred<RESP> = this?.let { req -> val session = req.session() - coroutinesAsync(Unconfined) { + GlobalScope.coroutinesAsync(Dispatchers.Unconfined) { block(req, session) } } ?: throw IllegalStateException("Request not set!") @@ -84,7 +85,7 @@ fun <RESP> Request?.async(block: (Request, Session) -> RESP): Deferred<RESP> = t fun <RESP> Request?.async(block: (Request, Session, Profile) -> RESP): Deferred<RESP> = this?.let { req -> val session = req.session() val profile = req.require(CommonProfile::class.java) - coroutinesAsync(Unconfined) { + GlobalScope.coroutinesAsync(Dispatchers.Unconfined) { block(req, session, profile) } } ?: throw IllegalStateException("Request not set!") diff --git a/kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt b/kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt index 0ff01d04..edaa9ba3 100644 --- a/kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt +++ b/kvision-server/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt @@ -22,8 +22,8 @@ package pl.treksoft.kvision.remote import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import kotlinx.coroutines.experimental.Deferred -import kotlinx.coroutines.experimental.runBlocking +import kotlinx.coroutines.Deferred +import kotlinx.coroutines.runBlocking import org.jooby.Response import org.jooby.Status import org.slf4j.Logger diff --git a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt index 62d22de9..323d0e1e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt @@ -23,6 +23,7 @@ package pl.treksoft.kvision.form import kotlinx.serialization.KSerializer import kotlinx.serialization.Mapper +import kotlinx.serialization.decode import kotlinx.serialization.json.JSON import kotlinx.serialization.serializer import pl.treksoft.kvision.form.upload.Upload @@ -44,27 +45,6 @@ internal data class FieldParams<in F : FormControl>( ) /** - * A wrapper for a Map with a custom containsKey method implementation. - * Used with kotlinx.serialization Mapper. - */ -private class FormMapWrapper<out V>(private val map: Map<String, V>) : Map<String, V> { - override fun equals(other: Any?): Boolean = map == other - override fun hashCode(): Int = map.hashCode() - override fun toString(): String = map.toString() - override val size: Int get() = map.size - override fun isEmpty(): Boolean = map.isEmpty() - override fun containsKey(key: String): Boolean = - if (key.indexOf('.') != -1) map.containsKey(key) else - !(map.containsKey("$key.time") || map.containsKey("$key.size")) - - override fun containsValue(value: @UnsafeVariance V): Boolean = map.containsValue(value) - override fun get(key: String): V? = map[key] - override val keys: Set<String> get() = map.keys - override val values: Collection<V> get() = map.values - override val entries: Set<Map.Entry<String, V>> get() = map.entries -} - -/** * The form definition class. Can be used directly or indirectly inside a [FormPanel]. * * @constructor Creates a form with a given modelFactory function @@ -94,9 +74,9 @@ class Form<K : Any>(private val panel: FormPanel<K>? = null, private val seriali listOf(entry.key to entry.value, "${entry.key}.size" to list.size) + list.mapIndexed { index, kFile -> listOf( - "${entry.key}.${index + 1}.name" to kFile.name, - "${entry.key}.${index + 1}.size" to kFile.size, - "${entry.key}.${index + 1}.content" to kFile.content + "${entry.key}.${index}.name" to kFile.name, + "${entry.key}.${index}.size" to kFile.size, + "${entry.key}.${index}.content" to kFile.content ) }.flatten() } ?: listOf() @@ -104,8 +84,8 @@ class Form<K : Any>(private val panel: FormPanel<K>? = null, private val seriali else -> listOf(entry.key to entry.value) } }.toMap() - val mapper = Mapper.InNullableMapper(FormMapWrapper(map)) - mapper.read(serializer) + val mapper = Mapper.InNullableMapper(map) + mapper.decode(serializer) } } diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Dialog.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Dialog.kt index 0890d5a1..d5695db3 100644 --- a/src/main/kotlin/pl/treksoft/kvision/modal/Dialog.kt +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Dialog.kt @@ -21,8 +21,9 @@ */ package pl.treksoft.kvision.modal -import kotlinx.coroutines.experimental.suspendCancellableCoroutine +import kotlinx.coroutines.suspendCancellableCoroutine import pl.treksoft.kvision.core.Widget +import kotlin.coroutines.resume /** * Modal window with a result. diff --git a/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt b/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt index c7103200..25c20445 100644 --- a/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt +++ b/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt @@ -21,8 +21,8 @@ */ package pl.treksoft.kvision.remote -import kotlinx.coroutines.experimental.Deferred -import kotlinx.coroutines.experimental.asDeferred +import kotlinx.coroutines.Deferred +import kotlinx.coroutines.asDeferred import kotlinx.serialization.KSerializer import kotlinx.serialization.internal.ArrayListSerializer import kotlinx.serialization.internal.BooleanSerializer diff --git a/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt b/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt index 2d4ab9eb..56141f5e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt +++ b/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt @@ -21,8 +21,8 @@ */ package pl.treksoft.kvision.remote -import kotlinx.coroutines.experimental.Deferred -import kotlinx.coroutines.experimental.asDeferred +import kotlinx.coroutines.Deferred +import kotlinx.coroutines.asDeferred import kotlinx.serialization.Serializable import pl.treksoft.kvision.utils.obj diff --git a/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt b/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt index 0b2bba23..961bf176 100644 --- a/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt +++ b/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt @@ -21,7 +21,7 @@ */ package pl.treksoft.kvision.remote -import kotlinx.coroutines.experimental.Deferred +import kotlinx.coroutines.Deferred /** * Multiplatform service manager. diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt index 203fac98..e5f608c2 100644 --- a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt +++ b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt @@ -24,13 +24,15 @@ package pl.treksoft.kvision.utils import com.lightningkite.kotlin.observable.list.ObservableList -import kotlinx.coroutines.experimental.suspendCancellableCoroutine +import kotlinx.coroutines.suspendCancellableCoroutine import org.w3c.files.File import org.w3c.files.FileReader import pl.treksoft.kvision.KVManager import pl.treksoft.kvision.core.CssSize import pl.treksoft.kvision.core.UNIT import kotlin.browser.window +import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException import kotlin.js.Date /** |