From ce19e02655ba197347c4b5ee9819fb66fd6fc3da Mon Sep 17 00:00:00 2001 From: Ian Clarke Date: Tue, 2 Oct 2018 14:50:08 -0500 Subject: [PATCH] update to latest kotlin RC --- build.gradle | 21 ++++++++++++------- src/main/kotlin/io/kweb/Kweb.kt | 10 ++++----- .../browserConnection/KwebClientConnection.kt | 8 +++---- src/main/kotlin/io/kweb/demos/async/async.kt | 3 +-- src/main/kotlin/io/kweb/demos/todo/todoApp.kt | 9 +++++--- .../dom/element/storage/storageExtensions.kt | 4 ++-- 6 files changed, 30 insertions(+), 25 deletions(-) diff --git a/build.gradle b/build.gradle index 11e6b18c30..c16992c880 100644 --- a/build.gradle +++ b/build.gradle @@ -6,14 +6,15 @@ allprojects { maven { url "https://plugins.gradle.org/m2/" } + maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' } } } } buildscript { - ext.kotlin_version = '1.2.60' + ext.kotlin_version = '1.3.0-rc-57' ext.dokka_version = '0.9.17' - ext.ktor_version = '0.9.3' + ext.ktor_version = '0.9.5-rc13' repositories { jcenter() @@ -22,6 +23,8 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } + maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' } + } @@ -35,7 +38,7 @@ buildscript { } group 'io.kweb' -version '0.3.4' +version '0.3.5' apply plugin: 'java' @@ -68,6 +71,8 @@ repositories { } maven { url "http://dl.bintray.com/jetbrains/spek" } jcenter() + maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' } + } configurations { @@ -76,7 +81,7 @@ configurations { configurations.all { resolutionStrategy { - force 'org.jetbrains.kotlinx:kotlinx-coroutines-io:0.23.4' + // force 'org.jetbrains.kotlinx:kotlinx-coroutines-io:0.30.0-eap13' } } @@ -111,9 +116,9 @@ dependencies { ////////////////////////////// compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.23.4' - compile 'org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:0.23.4' + // compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.30.0-eap13' + compile 'org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:0.30.0-eap13' // TODO: This should be testCompile compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.+' @@ -139,7 +144,7 @@ dependencies { compile 'io.github.microutils:kotlin-logging:1.5.4' compile("org.reflections:reflections:0.9.11") - compile 'com.github.kwebio:shoebox:0.2.19' + compile 'com.github.kwebio:shoebox:0.2.20' compile 'com.github.yamamotoj:cached-property-kotlin:0.1.0' diff --git a/src/main/kotlin/io/kweb/Kweb.kt b/src/main/kotlin/io/kweb/Kweb.kt index 88bd10833b..5802b1937c 100644 --- a/src/main/kotlin/io/kweb/Kweb.kt +++ b/src/main/kotlin/io/kweb/Kweb.kt @@ -2,11 +2,11 @@ package io.kweb import com.github.salomonbrys.kotson.fromJson import io.ktor.application.* -import io.ktor.content.* import io.ktor.features.* import io.ktor.http.* import io.ktor.http.cio.websocket.Frame.Text import io.ktor.http.cio.websocket.readText +import io.ktor.http.content.* import io.ktor.request.* import io.ktor.response.respondText import io.ktor.routing.* @@ -18,8 +18,8 @@ import io.kweb.browserConnection.KwebClientConnection import io.kweb.browserConnection.KwebClientConnection.Caching import io.kweb.dev.hotswap.KwebHotswapPlugin import io.kweb.plugins.KWebPlugin -import kotlinx.coroutines.experimental.* -import kotlinx.coroutines.experimental.channels.consumeEach +import kotlinx.coroutines.* +import kotlinx.coroutines.channels.consumeEach import org.apache.commons.io.IOUtils import java.io.* import java.time.* @@ -207,7 +207,7 @@ class Kweb(val port: Int, webSocket("/ws") { - val hello = gson.fromJson((incoming.receive() as Text).readText()) + val hello = gson.fromJson((incoming as Text).readText()) if (hello.hello == null) { @@ -304,7 +304,7 @@ class Kweb(val port: Int, } } - private fun refreshAllPages() = async(CommonPool) { + private fun refreshAllPages() = launch(Dispatchers.Default) { for (client in clientState.values) { val message = Server2ClientMessage( yourId = client.id, diff --git a/src/main/kotlin/io/kweb/browserConnection/KwebClientConnection.kt b/src/main/kotlin/io/kweb/browserConnection/KwebClientConnection.kt index 43236a0923..a9b96f32aa 100644 --- a/src/main/kotlin/io/kweb/browserConnection/KwebClientConnection.kt +++ b/src/main/kotlin/io/kweb/browserConnection/KwebClientConnection.kt @@ -2,8 +2,8 @@ package io.kweb.browserConnection import io.ktor.http.cio.websocket.* import io.ktor.http.cio.websocket.Frame.Text -import kotlinx.coroutines.experimental.* -import kotlinx.coroutines.experimental.channels.* +import kotlinx.coroutines.* +import kotlinx.coroutines.channels.* import mu.KotlinLogging import java.util.concurrent.ConcurrentLinkedQueue @@ -20,18 +20,16 @@ sealed class KwebClientConnection { init { launch { - sendBuffer.consumeEach { channel.outgoing.send(it) } + sendBuffer.consumeEach { channel.send(it) } } } override fun send(message: String) { - logger.debug("Start message send: $message on channel isFull: ${channel.outgoing.isFull} isClosedForSend: ${channel.outgoing.isClosedForSend}") runBlocking { sendBuffer.send(Text(message)) } sendCount++ - logger.debug("End message send: $message") } } diff --git a/src/main/kotlin/io/kweb/demos/async/async.kt b/src/main/kotlin/io/kweb/demos/async/async.kt index af67b38977..7fcb648a3e 100644 --- a/src/main/kotlin/io/kweb/demos/async/async.kt +++ b/src/main/kotlin/io/kweb/demos/async/async.kt @@ -3,8 +3,7 @@ package io.kweb.demos.async import io.kweb.Kweb import io.kweb.dom.element.creation.tags.p import io.kweb.dom.element.new -import kotlinx.coroutines.experimental.future.await -import kotlinx.coroutines.experimental.future.future +import kotlinx.coroutines.future.* import mu.KotlinLogging /** diff --git a/src/main/kotlin/io/kweb/demos/todo/todoApp.kt b/src/main/kotlin/io/kweb/demos/todo/todoApp.kt index 8af671f6c6..1c0e8b82c6 100644 --- a/src/main/kotlin/io/kweb/demos/todo/todoApp.kt +++ b/src/main/kotlin/io/kweb/demos/todo/todoApp.kt @@ -12,10 +12,14 @@ import io.kweb.routing.* import io.kweb.state.KVar import io.kweb.state.persistent.* import io.mola.galimatias.URL -import kotlinx.coroutines.experimental.async -import kotlinx.coroutines.experimental.future.await +import kotlinx.coroutines.async +import kotlinx.coroutines.async +import kotlinx.coroutines.future.await +import kotlinx.coroutines.future.await import mu.KotlinLogging +import sun.plugin.util.PluginSysUtil.execute import java.time.Instant +import java.util.* import io.kweb.plugins.semanticUI.semantic as s private val logger = KotlinLogging.logger {} @@ -30,7 +34,6 @@ fun main(args: Array) { * */ Kweb(port = 8091, debug = true, plugins = plugins) { doc.body.new { - /** Kweb allows you to modularize your code however suits your needs best. Here I use an extension function defined elsewhere to draw some common outer page DOM elements */ diff --git a/src/main/kotlin/io/kweb/dom/element/storage/storageExtensions.kt b/src/main/kotlin/io/kweb/dom/element/storage/storageExtensions.kt index 79f06a494f..62fb4ef804 100644 --- a/src/main/kotlin/io/kweb/dom/element/storage/storageExtensions.kt +++ b/src/main/kotlin/io/kweb/dom/element/storage/storageExtensions.kt @@ -2,8 +2,8 @@ package io.kweb.dom.element.storage import io.kweb.Kweb import io.kweb.dom.Document -import kotlinx.coroutines.experimental.future.await -import kotlinx.coroutines.experimental.future.future +import kotlinx.coroutines.future.await +import kotlinx.coroutines.future.future import java.util.concurrent.CompletableFuture /**