From 40b9cc1f785eaae352267757ac9e091c25ed0744 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Wed, 7 Nov 2018 22:16:46 +0100 Subject: Upgrade to Kotlin 1.3.0 final. --- gradle.properties | 6 +++--- kvision-modules/kvision-server-jooby/build.gradle | 3 +++ .../src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt | 12 ++++++++---- kvision-modules/kvision-server-spring-boot/build.gradle | 1 + .../src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt | 5 ++--- src/main/kotlin/pl/treksoft/kvision/form/Form.kt | 4 +++- src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt | 2 ++ src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt | 3 +++ .../kotlin/pl/treksoft/kvision/remote/JoobyRemoteAgent.kt | 2 ++ src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt | 2 ++ .../kotlin/pl/treksoft/kvision/remote/SpringRemoteAgent.kt | 2 ++ 11 files changed, 31 insertions(+), 11 deletions(-) diff --git a/gradle.properties b/gradle.properties index c68413e7..6f669a72 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ group=pl.treksoft version=0.0.19 -kotlinVersion=1.3.0-rc-190 +kotlinVersion=1.3.0 javaVersion=1.8 -coroutinesVersion=0.30.2-eap13 -serializationVersion=0.8.1-rc13 +coroutinesVersion=1.0.0 +serializationVersion=0.9.0 frontendPluginVersion=0.0.37 dokkaVersion=0.9.17 detektVersion=1.0.0.RC9.2 diff --git a/kvision-modules/kvision-server-jooby/build.gradle b/kvision-modules/kvision-server-jooby/build.gradle index 952e9a16..b3912c2c 100644 --- a/kvision-modules/kvision-server-jooby/build.gradle +++ b/kvision-modules/kvision-server-jooby/build.gradle @@ -11,6 +11,9 @@ dependencyManagement { dependencies { expectedBy project(":kvision-modules:kvision-common") compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" + compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion" compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion" compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion" compile "org.jooby:jooby-lang-kotlin" diff --git a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt index 1e19f394..bc182467 100644 --- a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt +++ b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt @@ -22,8 +22,9 @@ package pl.treksoft.kvision.remote import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.Deferred -import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.GlobalScope import org.jooby.Kooby import org.jooby.Session @@ -64,8 +65,9 @@ actual typealias Profile = CommonProfile /** * A helper extension function for asynchronous request processing. */ +@UseExperimental(ExperimentalCoroutinesApi::class) fun Request?.async(block: (Request) -> RESP): Deferred = this?.let { req -> - GlobalScope.coroutinesAsync(Dispatchers.Unconfined) { + GlobalScope.coroutinesAsync(start = CoroutineStart.UNDISPATCHED) { block(req) } } ?: throw IllegalStateException("Request not set!") @@ -73,9 +75,10 @@ fun Request?.async(block: (Request) -> RESP): Deferred = this?.let /** * A helper extension function for asynchronous request processing with session. */ +@UseExperimental(ExperimentalCoroutinesApi::class) fun Request?.asyncSession(block: (Request, Session) -> RESP): Deferred = this?.let { req -> val session = req.session() - GlobalScope.coroutinesAsync(Dispatchers.Unconfined) { + GlobalScope.coroutinesAsync(start = CoroutineStart.UNDISPATCHED) { block(req, session) } } ?: throw IllegalStateException("Request not set!") @@ -83,11 +86,12 @@ fun Request?.asyncSession(block: (Request, Session) -> RESP): Deferred Request?.asyncAuth(block: (Request, Session, Profile) -> RESP): Deferred = this?.let { req -> val session = req.session() val profile = req.require(CommonProfile::class.java) as CommonProfile? profile?.let { - GlobalScope.coroutinesAsync(Dispatchers.Unconfined) { + GlobalScope.coroutinesAsync(start = CoroutineStart.UNDISPATCHED) { block(req, session, profile) } } diff --git a/kvision-modules/kvision-server-spring-boot/build.gradle b/kvision-modules/kvision-server-spring-boot/build.gradle index d235f214..43d8650d 100644 --- a/kvision-modules/kvision-server-spring-boot/build.gradle +++ b/kvision-modules/kvision-server-spring-boot/build.gradle @@ -6,6 +6,7 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion" compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion" + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion" compile "org.springframework.boot:spring-boot-starter:$springBootVersion" diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt index 730288a8..11b848bf 100644 --- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt +++ b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt @@ -22,7 +22,6 @@ package pl.treksoft.kvision.remote import kotlinx.coroutines.Deferred -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import org.pac4j.core.context.J2EContext import org.pac4j.core.context.session.J2ESessionStore @@ -52,7 +51,7 @@ actual typealias Profile = CommonProfile * A helper extension function for asynchronous processing. */ fun async(block: () -> RESP): Deferred = - GlobalScope.coroutinesAsync(Dispatchers.Unconfined) { + GlobalScope.coroutinesAsync { block() } @@ -69,7 +68,7 @@ fun asyncAuth(block: (Profile) -> RESP): Deferred { null } return profile?.let { - GlobalScope.coroutinesAsync(Dispatchers.Unconfined) { + GlobalScope.coroutinesAsync { block(it) } } ?: throw IllegalStateException("Profile not set!") diff --git a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt index 8f93c7ea..e2f5d730 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt @@ -21,6 +21,7 @@ */ package pl.treksoft.kvision.form +import kotlinx.serialization.ImplicitReflectionSerializer import kotlinx.serialization.KSerializer import kotlinx.serialization.Mapper import kotlinx.serialization.context.MutableSerialContextImpl @@ -106,7 +107,7 @@ class Form(private val panel: FormPanel? = null, private val seriali else -> listOf(entry.key to entry.value) } }.toMap() - val mapper = Mapper.InNullableMapper(FormMapWrapper(map)) + val mapper = Mapper().InNullableMapper(FormMapWrapper(map)) mapper.context = MutableSerialContextImpl().apply { registerSerializer(Date::class, DateSerializer) } mapper.decode(serializer) } @@ -320,6 +321,7 @@ class Form(private val panel: FormPanel? = null, private val seriali } companion object { + @UseExperimental(ImplicitReflectionSerializer::class) inline fun create( panel: FormPanel? = null, noinline init: (Form.() -> Unit)? = null diff --git a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt index 3533dee5..c9b33572 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt @@ -22,6 +22,7 @@ package pl.treksoft.kvision.form import com.github.snabbdom.VNode +import kotlinx.serialization.ImplicitReflectionSerializer import kotlinx.serialization.KSerializer import kotlinx.serialization.serializer import pl.treksoft.kvision.core.Container @@ -407,6 +408,7 @@ open class FormPanel( return formPanel } + @UseExperimental(ImplicitReflectionSerializer::class) inline fun create( method: FormMethod? = null, action: String? = null, enctype: FormEnctype? = null, type: FormType? = null, classes: Set = setOf(), diff --git a/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt b/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt index a48a6b1f..4a086e2a 100644 --- a/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt +++ b/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt @@ -21,6 +21,8 @@ */ package pl.treksoft.kvision.remote +import kotlinx.serialization.ImplicitReflectionSerializer +import kotlinx.serialization.stringify import pl.treksoft.jquery.JQueryAjaxSettings import pl.treksoft.jquery.JQueryXHR import pl.treksoft.jquery.jQuery @@ -49,6 +51,7 @@ open class CallAgent { * @param data data to be sent * @return a promise of the result */ + @UseExperimental(ImplicitReflectionSerializer::class) @Suppress("UnsafeCastFromDynamic") fun jsonRpcCall( url: String, diff --git a/src/main/kotlin/pl/treksoft/kvision/remote/JoobyRemoteAgent.kt b/src/main/kotlin/pl/treksoft/kvision/remote/JoobyRemoteAgent.kt index b4cc6c21..30d2062d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/remote/JoobyRemoteAgent.kt +++ b/src/main/kotlin/pl/treksoft/kvision/remote/JoobyRemoteAgent.kt @@ -23,6 +23,7 @@ package pl.treksoft.kvision.remote import kotlinx.coroutines.Deferred import kotlinx.coroutines.asDeferred +import kotlinx.serialization.ImplicitReflectionSerializer import kotlinx.serialization.list import kotlinx.serialization.serializer import pl.treksoft.kvision.utils.JSON @@ -34,6 +35,7 @@ import kotlin.js.JSON as NativeJSON * Client side agent for JSON-RPC remote calls with Jooby. */ @Suppress("LargeClass", "TooManyFunctions") +@UseExperimental(ImplicitReflectionSerializer::class) open class JoobyRemoteAgent(val serviceManager: JoobyServiceManager) : RemoteAgent { val callAgent = CallAgent() diff --git a/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt b/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt index b1ee4fde..cbb2978a 100644 --- a/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt +++ b/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt @@ -21,6 +21,7 @@ */ package pl.treksoft.kvision.remote +import kotlinx.serialization.ImplicitReflectionSerializer import kotlinx.serialization.KSerializer import kotlinx.serialization.internal.BooleanSerializer import kotlinx.serialization.internal.ByteSerializer @@ -52,6 +53,7 @@ interface RemoteAgent { * @suppress * Internal function */ + @UseExperimental(ImplicitReflectionSerializer::class) @Suppress("ComplexMethod", "TooGenericExceptionCaught", "NestedBlockDepth") fun trySerialize(kClass: KClass, value: Any): String { return if (value is List<*>) { diff --git a/src/main/kotlin/pl/treksoft/kvision/remote/SpringRemoteAgent.kt b/src/main/kotlin/pl/treksoft/kvision/remote/SpringRemoteAgent.kt index f1f3b473..f329d10e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/remote/SpringRemoteAgent.kt +++ b/src/main/kotlin/pl/treksoft/kvision/remote/SpringRemoteAgent.kt @@ -23,6 +23,7 @@ package pl.treksoft.kvision.remote import kotlinx.coroutines.Deferred import kotlinx.coroutines.asDeferred +import kotlinx.serialization.ImplicitReflectionSerializer import kotlinx.serialization.list import kotlinx.serialization.serializer import pl.treksoft.kvision.utils.JSON @@ -34,6 +35,7 @@ import kotlin.js.JSON as NativeJSON * Client side agent for JSON-RPC remote calls with Spring Boot. */ @Suppress("LargeClass", "TooManyFunctions") +@UseExperimental(ImplicitReflectionSerializer::class) open class SpringRemoteAgent(val serviceManager: SpringServiceManager) : RemoteAgent { val callAgent = CallAgent() -- cgit