Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
* Kotlin 1.8.10 -> 1.8.21
* Ktor 2.2.4 -> 2.3.0
* kotlinx.coroutines 1.6.4 -> 1.7.0-RC
* kotlin-node 18.14.0-pre.502 -> 18.16.3-pre.546
* KSP 1.8.10-1.0.9 -> 1.8.21-1.0.11
* KotlinPoet 1.12.0 -> 1.13.1
* JUnit 5 5.9.2 -> 5.9.3
* MockK 1.13.4 -> 1.13.5
* AtomicFU 0.20.0 -> 0.20.2
* Binary compatibility validator 0.13.0 -> 0.13.1
* gradle-buildconfig-plugin 3.1.0 -> 4.0.4

Using typealiases for overriding the default Instant serializer wasn't
possible in #605 because of
Kotlin/kotlinx.serialization#1895.
Since this Bug was fixed in Kotlin 1.8.21, the typealiases
dev.kord.common.serialization.InstantInEpochMilliseconds and
dev.kord.common.serialization.InstantInEpochSeconds can now be used.

The changes in the public API are probably because of changes in the
serialization and AtomicFU plugins with Kotlin 1.8.21. However, they
are unlikely to affect anyone since only generated symbols that aren't
supposed to be accessed directly were touched.
  • Loading branch information
lukellmann committed May 2, 2023
1 parent 9126cf4 commit a62fc9a
Show file tree
Hide file tree
Showing 27 changed files with 763 additions and 375 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ out/
**/build/*
!**/build/generated/
# re-exclude BuildConfigGenerated.kt
common/build/generated/source/buildConfig/main/main/dev/kord/common/BuildConfigGenerated.kt
common/build/generated/sources/buildConfig/main/dev/kord/common/BuildConfigGenerated.kt
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Compiler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ object Jvm {
}

fun KotlinCommonCompilerOptions.applyKordCompilerOptions() {
// TODO: set to true again once https://github.com/Kotlin/kotlinx-atomicfu/issues/289 is fixed
allWarningsAsErrors = false
allWarningsAsErrors = true
freeCompilerArgs.add("-progressive")
}

fun KotlinSourceSet.applyKordOptIns() {
languageSettings {
// allow `ExperimentalCoroutinesApi` for `TestScope.currentTime`
if ("Test" in name) optIn(OptIns.coroutines)
kordOptIns.forEach(::optIn)
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/kord-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ kotlin {
jvmToolchain(Jvm.target)

sourceSets {
// allow `ExperimentalCoroutinesApi` for `runTest {}`
// allow `ExperimentalCoroutinesApi` for `TestScope.currentTime`
test { languageSettings.optIn(OptIns.coroutines) }
}
}
Expand Down
6 changes: 6 additions & 0 deletions buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ tasks {
}
}

afterEvaluate {
named("sourcesJar") {
dependsOn("kspCommonMainKotlinMetadata")
}
}

withType<AbstractDokkaLeafTask>().configureEach {
applyKordDokkaOptions()
dependsOn("kspCommonMainKotlinMetadata")
Expand Down
232 changes: 116 additions & 116 deletions common/api/common.api

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions common/src/commonMain/kotlin/entity/Data.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dev.kord.common.entity

import dev.kord.common.entity.optional.Optional
import dev.kord.common.entity.optional.OptionalSnowflake
import dev.kord.common.serialization.InstantInEpochSecondsSerializer
import dev.kord.common.serialization.InstantInEpochSeconds
import kotlinx.datetime.Instant
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand All @@ -25,7 +25,6 @@ public data class DiscordTyping(
val guildId: OptionalSnowflake = OptionalSnowflake.Missing,
@SerialName("user_id")
val userId: Snowflake,
@Serializable(with = InstantInEpochSecondsSerializer::class)
val timestamp: Instant,
val timestamp: InstantInEpochSeconds,
val member: Optional<DiscordGuildMember> = Optional.Missing()
)
10 changes: 4 additions & 6 deletions common/src/commonMain/kotlin/entity/DiscordActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ package dev.kord.common.entity
import dev.kord.common.entity.optional.Optional
import dev.kord.common.entity.optional.OptionalBoolean
import dev.kord.common.entity.optional.OptionalSnowflake
import dev.kord.common.serialization.InstantInEpochMillisecondsSerializer
import dev.kord.common.serialization.InstantInEpochMilliseconds
import dev.kord.ksp.GenerateKordEnum
import dev.kord.ksp.GenerateKordEnum.Entry
import dev.kord.ksp.GenerateKordEnum.ValueType.INT
import kotlinx.datetime.Instant
import kotlinx.serialization.*
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.builtins.serializer
Expand All @@ -41,8 +40,7 @@ public data class DiscordActivity(
val type: ActivityType,
val url: Optional<String?> = Optional.Missing(),
@SerialName("created_at")
@Serializable(with = InstantInEpochMillisecondsSerializer::class)
val createdAt: Instant,
val createdAt: InstantInEpochMilliseconds,
val timestamps: Optional<DiscordActivityTimestamps> = Optional.Missing(),
@SerialName("application_id")
val applicationId: OptionalSnowflake = OptionalSnowflake.Missing,
Expand Down Expand Up @@ -88,8 +86,8 @@ public class ActivityFlags(public val value: Int) {

@Serializable
public data class DiscordActivityTimestamps(
val start: Optional<@Serializable(with = InstantInEpochMillisecondsSerializer::class) Instant> = Optional.Missing(),
val end: Optional<@Serializable(with = InstantInEpochMillisecondsSerializer::class) Instant> = Optional.Missing(),
val start: Optional<InstantInEpochMilliseconds> = Optional.Missing(),
val end: Optional<InstantInEpochMilliseconds> = Optional.Missing(),
)

@Serializable
Expand Down
15 changes: 5 additions & 10 deletions common/src/commonMain/kotlin/serialization/InstantSerializers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dev.kord.common.serialization

import kotlinx.datetime.Instant
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationException
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
Expand Down Expand Up @@ -36,11 +37,8 @@ public object InstantInEpochMillisecondsSerializer : KSerializer<Instant> {
}
}

// TODO use this typealias instead of annotating types/properties with
// @Serializable(with = InstantInEpochMillisecondsSerializer::class) once
// https://github.com/Kotlin/kotlinx.serialization/issues/1895 is fixed
// /** An [Instant] that is [serializable][Serializable] with [InstantInEpochMillisecondsSerializer]. */
// public typealias InstantInEpochMilliseconds = @Serializable(with = InstantInEpochMillisecondsSerializer::class) Instant
/** An [Instant] that is [serializable][Serializable] with [InstantInEpochMillisecondsSerializer]. */
public typealias InstantInEpochMilliseconds = @Serializable(with = InstantInEpochMillisecondsSerializer::class) Instant


// epoch seconds
Expand All @@ -61,8 +59,5 @@ public object InstantInEpochSecondsSerializer : KSerializer<Instant> {
}
}

// TODO use this typealias instead of annotating types/properties with
// @Serializable(with = InstantInEpochSecondsSerializer::class) once
// https://github.com/Kotlin/kotlinx.serialization/issues/1895 is fixed
// /** An [Instant] that is [serializable][Serializable] with [InstantInEpochSecondsSerializer]. */
// public typealias InstantInEpochSeconds = @Serializable(with = InstantInEpochSecondsSerializer::class) Instant
/** An [Instant] that is [serializable][Serializable] with [InstantInEpochSecondsSerializer]. */
public typealias InstantInEpochSeconds = @Serializable(with = InstantInEpochSecondsSerializer::class) Instant
Loading

0 comments on commit a62fc9a

Please sign in to comment.