Skip to content

Commit

Permalink
Merge pull request #275 from DRSchlaubi/kotlin-1.5
Browse files Browse the repository at this point in the history
Port to Kotlin 1.5
  • Loading branch information
BartArys authored May 5, 2021
2 parents e737212 + e140967 commit 4a2f7f1
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 28 deletions.
4 changes: 1 addition & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {

plugins {
id("org.jetbrains.kotlin.jvm") version Versions.kotlin
id("org.jetbrains.dokka") version "1.4.0"
id("org.jetbrains.dokka") version "1.4.30"
id("org.ajoberstar.git-publish") version "2.1.3"

signing
Expand All @@ -33,7 +33,6 @@ apply(plugin = "binary-compatibility-validator")

repositories {
mavenCentral()
jcenter()
mavenLocal()
}

Expand Down Expand Up @@ -219,7 +218,6 @@ tasks {
dokkaHtmlMultiModule.configure {
dependsOn(clean)
outputDirectory.set(file(dokkaOutputDir))
documentationFileName.set("DokkaDescription.md")
}


Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {
}

dependencies {
implementation(kotlin("gradle-plugin-api", version = "1.4.0"))
implementation(kotlin("gradle-plugin-api", version = "1.5.0"))
implementation(gradleApi())
implementation(localGroovy())
}
1 change: 0 additions & 1 deletion buildSrc/src/main/kotlin/Compiler.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
object CompilerArguments {
const val inlineClasses = "-XXLanguage:+InlineClasses"
const val coroutines = "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
const val time = "-Xopt-in=kotlin.time.ExperimentalTime"
const val stdLib = "-Xopt-in=kotlin.ExperimentalStdlibApi"
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ object Versions {
const val kotlin = "1.5.0"
const val kotlinxSerialization = "1.0.0"
const val ktor = "1.5.3"
const val kotlinxCoroutines = "1.4.3"
const val kotlinxCoroutines = "1.5.0-RC"
const val kotlinLogging = "2.0.4"
const val atomicFu = "0.15.2"
const val atomicFu = "0.16.1"
const val binaryCompatibilityValidator = "0.4.0"

//test deps
Expand Down
1 change: 0 additions & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = Jvm.target
freeCompilerArgs = listOf(
CompilerArguments.inlineClasses,
CompilerArguments.coroutines,
CompilerArguments.time,
CompilerArguments.optIn
Expand Down
1 change: 0 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = Jvm.target
freeCompilerArgs = listOf(
CompilerArguments.inlineClasses,
CompilerArguments.coroutines,
CompilerArguments.time,
CompilerArguments.stdLib,
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/kotlin/KordTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import java.util.concurrent.CountDownLatch
internal class KordTest {

@Test
@OptIn(KordExperimental::class)
@OptIn(KordExperimental::class, kotlinx.coroutines.DelicateCoroutinesApi::class)
fun `Kord life cycle is correctly ended on shutdown`() {
val kord = Kord.restOnly(System.getenv("KORD_TEST_TOKEN"))
val lock = CountDownLatch(1)
Expand Down
1 change: 0 additions & 1 deletion gateway/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = Jvm.target
freeCompilerArgs = listOf(
CompilerArguments.inlineClasses,
CompilerArguments.coroutines,
CompilerArguments.time,
CompilerArguments.optIn
Expand Down
1 change: 0 additions & 1 deletion gateway/src/main/kotlin/DefaultGateway.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ data class DefaultGatewayData(
/**
* The default Gateway implementation of Kord, using an [HttpClient] for the underlying webSocket
*/
@ObsoleteCoroutinesApi
class DefaultGateway(private val data: DefaultGatewayData) : Gateway {

override val coroutineContext: CoroutineContext = data.dispatcher + SupervisorJob()
Expand Down
6 changes: 4 additions & 2 deletions gateway/src/main/kotlin/handler/HeartbeatHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import kotlinx.atomicfu.atomic
import kotlinx.atomicfu.update
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlin.time.*
import kotlin.time.Duration
import kotlin.time.TimeMark
import kotlin.time.TimeSource

@ObsoleteCoroutinesApi
@OptIn(ObsoleteCoroutinesApi::class)
internal class HeartbeatHandler(
flow: Flow<Event>,
private val send: suspend (Command) -> Unit,
Expand Down
20 changes: 9 additions & 11 deletions gateway/src/samples/kotlin/EventListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@ import dev.kord.common.entity.*
import dev.kord.common.ratelimit.BucketRateLimiter
import dev.kord.gateway.*
import dev.kord.gateway.retry.LinearRetry
import io.ktor.client.HttpClient
import io.ktor.client.engine.cio.CIO
import io.ktor.client.features.json.JsonFeature
import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.client.features.json.*
import io.ktor.client.features.json.serializer.*
import io.ktor.client.features.websocket.WebSockets
import io.ktor.util.KtorExperimentalAPI
import io.ktor.client.features.websocket.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.serialization.json.Json
import java.time.Duration
import kotlin.time.Duration
import kotlin.time.ExperimentalTime
import kotlin.time.seconds
import kotlin.time.toKotlinDuration

@OptIn(DelicateCoroutinesApi::class)
@FlowPreview
@ExperimentalTime
@ExperimentalCoroutinesApi
Expand All @@ -34,8 +32,8 @@ suspend fun main(args: Array<String>) {
}
}

reconnectRetry = LinearRetry(2.seconds, 20.seconds, 10)
sendRateLimiter = BucketRateLimiter(120, Duration.ofSeconds(60).toKotlinDuration())
reconnectRetry = LinearRetry(Duration.seconds(2), Duration.seconds(20), 10)
sendRateLimiter = BucketRateLimiter(120, Duration.seconds(60))
}

gateway.events.filterIsInstance<MessageCreate>().flowOn(Dispatchers.Default).onEach {
Expand All @@ -59,7 +57,7 @@ suspend fun main(args: Array<String>) {
afk = false,
activities = listOf(
DiscordBotActivity(
"Ping is ${gateway.ping.value?.toLongMilliseconds()}",
"Ping is ${gateway.ping.value?.inWholeMilliseconds}",
ActivityType.Game
)
),
Expand Down
3 changes: 2 additions & 1 deletion gateway/src/test/kotlin/gateway/DefaultGatewayTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import kotlin.time.toKotlinDuration
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
class DefaultGatewayTest {
@OptIn(DelicateCoroutinesApi::class)
@Test
@Disabled
@ExperimentalTime
Expand Down Expand Up @@ -57,7 +58,7 @@ class DefaultGatewayTest {
"!status" -> when (words.getOrNull(1)) {
"playing" -> gateway.send(UpdateStatus(status = PresenceStatus.Online, afk = false, activities = listOf(DiscordBotActivity("Kord", ActivityType.Game)), since = null))
}
"!ping" -> gateway.send(UpdateStatus(status = PresenceStatus.Online, afk = false, activities = listOf(DiscordBotActivity("Ping is ${gateway.ping.value?.toLongMilliseconds()}", ActivityType.Game)), since = null))
"!ping" -> gateway.send(UpdateStatus(status = PresenceStatus.Online, afk = false, activities = listOf(DiscordBotActivity("Ping is ${gateway.ping.value?.inWholeMilliseconds}", ActivityType.Game)), since = null))
}
}.launchIn(GlobalScope)

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Tue Dec 31 15:02:18 CET 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
1 change: 0 additions & 1 deletion rest/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = Jvm.target
freeCompilerArgs = listOf(
CompilerArguments.inlineClasses,
CompilerArguments.coroutines,
CompilerArguments.time,
CompilerArguments.optIn
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pluginManagement {
}
repositories {
mavenLocal()
mavenCentral()
maven(url = "https://dl.bintray.com/kotlin/kotlin-dev")
gradlePluginPortal()
}
Expand Down

0 comments on commit 4a2f7f1

Please sign in to comment.