Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/native
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/deployment-ci.yml
#	.github/workflows/docs-ci.yml
#	buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts
#	buildSrc/src/main/kotlin/kord-module.gradle.kts
#	buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts
#	buildSrc/src/main/kotlin/kord-publishing.gradle.kts
#	core/src/commonMain/kotlin/Kord.kt
#	gateway/src/commonMain/kotlin/Gateway.kt
#	gateway/src/commonMain/kotlin/Utils.kt
#	gradle/libs.versions.toml
#	ksp-annotations/build.gradle.kts
#	voice/src/commonMain/kotlin/gateway/VoiceGateway.kt
  • Loading branch information
DRSchlaubi committed Sep 12, 2024
2 parents 4ea3199 + 4f6712f commit 8c8b869
Show file tree
Hide file tree
Showing 59 changed files with 402 additions and 585 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ in [`gradle.properties`](gradle.properties))
```kotlin
repositories {
mavenCentral()
// Kord Snapshots Repository (Optional):
// Kord Snapshot Repositories (optional, choose one of these):
maven("https://repo.kord.dev/snapshots")
maven("https://oss.sonatype.org/content/repositories/snapshots")
}

Expand All @@ -81,7 +82,10 @@ dependencies {
```groovy
repositories {
mavenCentral()
// Kord Snapshots Repository (Optional):
// Kord Snapshot Repositories (optional, choose one of these):
maven {
url "https://repo.kord.dev/snapshots"
}
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
Expand All @@ -94,9 +98,19 @@ dependencies {

### Maven

##### Kord Snapshots Repository (Optional):
##### Kord Snapshot Repositories (optional, choose one of these):

```xml
<repository>
<id>snapshots-repo</id>
<url>https://repo.kord.dev/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>

<repository>
<id>snapshots-repo</id>
Expand All @@ -113,7 +127,6 @@ dependencies {
---

```xml

<dependency>
<groupId>dev.kord</groupId>
<artifactId>kord-core-jvm</artifactId>
Expand Down
16 changes: 11 additions & 5 deletions buildSrc/src/main/kotlin/Compiler.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import org.gradle.api.NamedDomainObjectSet
import org.gradle.kotlin.dsl.assign
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet

val kordOptIns = listOf(
Expand All @@ -12,16 +14,20 @@ val kordOptIns = listOf(
"dev.kord.common.annotation.KordVoice",
)

object Jvm {
const val target = 8
}

fun KotlinCommonCompilerOptions.applyKordCompilerOptions() {
internal fun KotlinCommonCompilerOptions.applyKordCommonCompilerOptions() {
allWarningsAsErrors = true
progressiveMode = true
freeCompilerArgs.add("-Xexpect-actual-classes")
}

internal const val KORD_JVM_TARGET = 8

internal fun KotlinJvmCompilerOptions.applyKordJvmCompilerOptions() {
applyKordCommonCompilerOptions()
jvmTarget = JVM_1_8
freeCompilerArgs.add("-Xjdk-release=1.8")
}

internal fun NamedDomainObjectSet<KotlinSourceSet>.applyKordTestOptIns() {
named { it.contains("test", ignoreCase = true) }.configureEach {
// allow `ExperimentalCoroutinesApi` for `TestScope.currentTime`
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Documentation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fun AbstractDokkaLeafTask.applyKordDokkaOptions() {

dokkaSourceSets.configureEach {

jdkVersion = Jvm.target
jdkVersion = 22

suppressGeneratedFiles = false

Expand Down
9 changes: 7 additions & 2 deletions buildSrc/src/main/kotlin/kord-internal-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ repositories {
}

kotlin {
jvmToolchain(Jvm.target)
compilerOptions {
applyKordCompilerOptions()
applyKordJvmCompilerOptions()
}
}

tasks {
withType<JavaCompile>().configureEach {
options.release = KORD_JVM_TARGET
}
}
2 changes: 0 additions & 2 deletions buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import org.gradle.configurationcache.extensions.capitalized
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest

plugins {
org.jetbrains.kotlin.multiplatform
Expand Down
27 changes: 24 additions & 3 deletions buildSrc/src/main/kotlin/kord-publishing.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinMultiplatform
import org.jetbrains.kotlin.konan.target.Family
import java.lang.System.getenv
import java.util.Base64

plugins {
id("com.vanniktech.maven.publish.base")
Expand Down Expand Up @@ -55,4 +54,26 @@ mavenPublishing {
url = Library.projectUrl
}
}

repositories {
maven {
url = uri(if (isRelease) Repo.releasesUrl else Repo.snapshotsUrl)

credentials {
username = getenv("NEXUS_USER")
password = getenv("NEXUS_PASSWORD")
}
}

if (!isRelease) {
maven {
name = "kordSnapshots"
url = uri("https://repo.kord.dev/snapshots")
credentials {
username = getenv("KORD_REPO_USER")
password = getenv("KORD_REPO_PASSWORD")
}
}
}
}
}
138 changes: 0 additions & 138 deletions common/api/common.klib.api

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ kotlin {
dependencies {
api(libs.ktor.client.js)

// workaround for https://youtrack.jetbrains.com/issue/KT-43500
// (intended to be compileOnly in commonMain only)
// workaround for https://youtrack.jetbrains.com/issue/KT-43500 /
// https://youtrack.jetbrains.com/issue/KT-64109#focus=Comments-27-10064206.0-0 /
// https://youtrack.jetbrains.com/issue/KT-61096 (intended to be compileOnly in commonMain only)
implementation(projects.kspAnnotations)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ public class Permissions internal constructor(

@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "Binary compatibility, keep for some releases.",
message = "Kept for binary compatibility, this declaration will be removed in 0.17.0.",
)
public inline fun copy0(builder: Builder.() -> Unit): Permissions {
contract { callsInPlace(builder, EXACTLY_ONCE) }
Expand Down Expand Up @@ -620,7 +620,8 @@ public class Permissions internal constructor(
@Suppress(names = arrayOf("DEPRECATION_ERROR"))
@Deprecated(
level = DeprecationLevel.ERROR,
message = "Renamed to 'Companion'.",
message =
"Renamed to 'Companion'. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in 0.17.0.",
replaceWith = ReplaceWith(expression = "Permissions.Companion", imports =
arrayOf("dev.kord.common.entity.Permissions")),
)
Expand All @@ -630,7 +631,8 @@ public class Permissions internal constructor(

@Deprecated(
level = DeprecationLevel.ERROR,
message = "Renamed to 'Companion'.",
message =
"Renamed to 'Companion'. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in 0.17.0.",
replaceWith = ReplaceWith(expression = "Permissions.Companion", imports =
arrayOf("dev.kord.common.entity.Permissions")),
)
Expand All @@ -650,7 +652,7 @@ public inline fun Permissions(builder: Permissions.Builder.() -> Unit = {}): Per
@Suppress(names = arrayOf("FunctionName"))
@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "Binary compatibility, keep for some releases.",
message = "Kept for binary compatibility, this declaration will be removed in 0.17.0.",
)
public inline fun Permissions0(builder: Permissions.Builder.() -> Unit = {}): Permissions {
contract { callsInPlace(builder, EXACTLY_ONCE) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ public class SystemChannelFlags internal constructor(
@Suppress(names = arrayOf("DEPRECATION_ERROR"))
@Deprecated(
level = DeprecationLevel.ERROR,
message = "Renamed to 'Companion'.",
message =
"Renamed to 'Companion'. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in 0.17.0.",
replaceWith = ReplaceWith(expression = "SystemChannelFlags.Companion", imports =
arrayOf("dev.kord.common.entity.SystemChannelFlags")),
)
Expand All @@ -340,7 +341,8 @@ public class SystemChannelFlags internal constructor(

@Deprecated(
level = DeprecationLevel.ERROR,
message = "Renamed to 'Companion'.",
message =
"Renamed to 'Companion'. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in 0.17.0.",
replaceWith = ReplaceWith(expression = "SystemChannelFlags.Companion", imports =
arrayOf("dev.kord.common.entity.SystemChannelFlags")),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public class UserFlags internal constructor(

@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "Binary compatibility, keep for some releases.",
message = "Kept for binary compatibility, this declaration will be removed in 0.17.0.",
)
public inline fun copy0(builder: Builder.() -> Unit): UserFlags {
contract { callsInPlace(builder, EXACTLY_ONCE) }
Expand Down
2 changes: 1 addition & 1 deletion common/src/commonMain/kotlin/DiscordBitSet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public fun DiscordBitSet(value: String): DiscordBitSet {


@Deprecated(
"Replaced by 'DiscordBitSet.serializer()'.",
"Replaced by 'DiscordBitSet.serializer()'. This declaration will be removed in 0.16.0.",
ReplaceWith("DiscordBitSet.serializer()", imports = ["dev.kord.common.DiscordBitSet"]),
DeprecationLevel.HIDDEN,
)
Expand Down
2 changes: 1 addition & 1 deletion common/src/commonMain/kotlin/Locale.kt
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public data class Locale(val language: String, val country: String? = null) {
}

@Deprecated(
"Replaced by 'Locale.serializer()'.",
"Replaced by 'Locale.serializer()'. This declaration will be removed in 0.16.0.",
ReplaceWith("Locale.serializer()", imports = ["dev.kord.common.Locale"]),
DeprecationLevel.HIDDEN,
)
Expand Down
2 changes: 1 addition & 1 deletion common/src/commonMain/kotlin/entity/DiscordChannel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public sealed class ArchiveDuration(
@Suppress("UNUSED_PARAMETER") unused: Nothing?,
) : ArchiveDuration(duration) {
@Deprecated(
"Replaced by 'ArchiveDuration.from()'.",
"Replaced by 'ArchiveDuration.from()'. This declaration will be removed in 0.16.0.",
ReplaceWith("ArchiveDuration.from(duration)", imports = ["dev.kord.common.entity.ArchiveDuration"]),
DeprecationLevel.HIDDEN,
)
Expand Down
6 changes: 4 additions & 2 deletions common/src/commonMain/kotlin/entity/DiscordShard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public data class DiscordShard(val index: Int, val count: Int) {
public companion object {
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"Renamed to 'Companion'.",
"Renamed to 'Companion'. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration " +
"will be removed in 0.17.0.",
ReplaceWith("DiscordShard.Companion", imports = ["dev.kord.common.entity.DiscordShard"]),
DeprecationLevel.ERROR,
)
Expand All @@ -44,7 +45,8 @@ public data class DiscordShard(val index: Int, val count: Int) {
}

@Deprecated(
"Renamed to 'Companion'.",
"Renamed to 'Companion'. The deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will " +
"be removed in 0.17.0.",
ReplaceWith("DiscordShard.Companion", imports = ["dev.kord.common.entity.DiscordShard"]),
DeprecationLevel.ERROR,
)
Expand Down
3 changes: 2 additions & 1 deletion common/src/commonMain/kotlin/entity/Permissions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public val Permissions.Companion.ALL: Permissions get() = ALL_PERMISSIONS

@Suppress("UnusedReceiverParameter", "DEPRECATION_ERROR")
@Deprecated(
"'Permissions.NewCompanion' was renamed to 'Permissions.Companion'. Use 'Permissions.Companion.ALL' instead.",
"'Permissions.NewCompanion' was renamed to 'Permissions.Companion'. Use 'Permissions.Companion.ALL' instead. The " +
"deprecation level will be raised to HIDDEN in 0.16.0 and this declaration will be removed in 0.17.0.",
ReplaceWith("Permissions.ALL", imports = ["dev.kord.common.entity.Permissions", "dev.kord.common.entity.ALL"]),
DeprecationLevel.ERROR,
)
Expand Down
15 changes: 8 additions & 7 deletions common/src/commonMain/kotlin/entity/Snowflake.kt
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public class Snowflake : Comparable<Snowflake> {
*
* The comparison is based first on the value of the [timestamp], then on the value of the [workerId], then on the
* value of the [processId] and finally on the value of the [increment]. It is *consistent with equals*, as defined
* by [Comparable](https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html).
* by [Comparable](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/Comparable.html).
*/
override fun compareTo(other: Snowflake): Int {
// the layout of Snowflake values from MSB to LSB is timestamp, workerId, processId, increment,
Expand Down Expand Up @@ -175,12 +175,13 @@ public class Snowflake : Comparable<Snowflake> {
* [processId] and [increment] are not taken into account.
*
* Note: this comparator imposes an ordering that is *inconsistent with equals*, as defined by
* [Comparator](https://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html). It therefore shouldn't be
* used to order a [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) or
* [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html). This is because
* `TimestampComparator` only compares the first 42 bits of the ULong [value] (comparing the timestamp), whereas
* [equals][Snowflake.equals] compares all the bits of the [value]. `TimestampComparator` can return `0` even if
* [equals][Snowflake.equals] returns `false`, but [equals][Snowflake.equals] only returns `true` if
* [Comparator](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/Comparator.html). It
* therefore shouldn't be used to order a
* [SortedSet](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/SortedSet.html) or
* [SortedMap](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/SortedMap.html). This is
* because `TimestampComparator` only compares the first 42 bits of the ULong [value] (comparing the timestamp),
* whereas [equals][Snowflake.equals] compares all the bits of the [value]. `TimestampComparator` can return `0`
* even if [equals][Snowflake.equals] returns `false`, but [equals][Snowflake.equals] only returns `true` if
* `TimestampComparator` returns `0`.
*/
public val TimestampComparator: Comparator<Snowflake> = Comparator { s1, s2 ->
Expand Down
Loading

0 comments on commit 8c8b869

Please sign in to comment.