-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit attempts to provide Kotlin/JS support for Kord (see #69) Breaking Changes: * The following member functions were replaced by extension functions. Importing the extension functions should fix this breaking change. * dev.kord.common.Locale.asJavaLocale -> import dev.kord.common.asJavaLocale * dev.kord.core.cache.KordCacheBuilder.lruCache -> import dev.kord.core.cache.lruCache * dev.kord.rest.builder.message.create.MessageCreateBuilder.addFile -> import dev.kord.rest.builder.message.create.addFile * dev.kord.rest.builder.message.modify.MessageModifyBuilder.addFile -> import dev.kord.rest.builder.message.modify.addFile * dev.kord.rest.request.RequestBuilder.file -> import dev.kord.rest.request.file * The type of the following declarations was changed from java.util.Locale to dev.kord.common.Locale: * dev.kord.core.entity.Guild.preferredLocale * dev.kord.rest.builder.guild.GuildModifyBuilder.preferredLocale * All annotations in dev.kord.common.annotation and the dev.kord.gateway.PrivilegedIntent annotation now have BINARY instead of RUNTIME retention. This means they are no longer visible for reflection. * All maven consumers must append '-jvm' to their artifact IDs for kord-common, kord-rest, kord-gateway and kord-core. * The core-voice capability has been removed, please use the kord-core-voice artifact instead. --------- Co-authored-by: Lukellmann <[email protected]>
- Loading branch information
1 parent
d76ce05
commit 64f6636
Showing
821 changed files
with
2,962 additions
and
1,739 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import kotlinx.validation.ApiValidationExtension | ||
|
||
fun ApiValidationExtension.applyKordBCVOptions() { | ||
nonPublicMarkers += "dev.kord.common.annotation.KordInternal" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,46 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions | ||
import kotlinx.atomicfu.plugin.gradle.AtomicFUPluginExtension | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.getByType | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet | ||
|
||
object CompilerArguments { | ||
const val time = "-opt-in=kotlin.time.ExperimentalTime" | ||
const val contracts = "-opt-in=kotlin.contracts.ExperimentalContracts" | ||
object OptIns { | ||
const val coroutines = "kotlinx.coroutines.ExperimentalCoroutinesApi" | ||
} | ||
|
||
const val kordPreview = "-opt-in=dev.kord.common.annotation.KordPreview" | ||
const val kordExperimental = "-opt-in=dev.kord.common.annotation.KordExperimental" | ||
const val kordVoice = "-opt-in=dev.kord.common.annotation.KordVoice" | ||
val kordOptIns = listOf( | ||
"kotlin.time.ExperimentalTime", | ||
"kotlin.contracts.ExperimentalContracts", | ||
|
||
const val progressive = "-progressive" | ||
} | ||
"dev.kord.common.annotation.KordInternal", | ||
"dev.kord.common.annotation.KordPreview", | ||
"dev.kord.common.annotation.KordExperimental", | ||
"dev.kord.common.annotation.KordVoice", | ||
) | ||
|
||
object Jvm { | ||
const val target = 8 | ||
} | ||
|
||
fun KotlinJvmCompilerOptions.applyKordCompilerOptions() { | ||
allWarningsAsErrors.set(true) | ||
freeCompilerArgs.add(CompilerArguments.progressive) | ||
fun KotlinCommonCompilerOptions.applyKordCompilerOptions() { | ||
// TODO: set to true again once https://github.com/Kotlin/kotlinx-atomicfu/issues/289 is fixed | ||
allWarningsAsErrors.set(false) | ||
freeCompilerArgs.add("-progressive") | ||
} | ||
|
||
fun KotlinSourceSet.applyKordOptIns() { | ||
languageSettings { | ||
if ("Test" in name) optIn(OptIns.coroutines) | ||
kordOptIns.forEach(::optIn) | ||
} | ||
} | ||
|
||
fun Project.configureAtomicFU() { | ||
// https://github.com/Kotlin/kotlinx-atomicfu/issues/210 | ||
configure<AtomicFUPluginExtension> { | ||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
dependenciesVersion = libs.findVersion("kotlinx-atomicfu").get().requiredVersion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask | ||
import java.net.URL | ||
|
||
fun AbstractDokkaLeafTask.applyKordDokkaOptions() { | ||
failOnWarning.set(true) | ||
|
||
dokkaSourceSets.configureEach { | ||
|
||
jdkVersion.set(Jvm.target) | ||
|
||
suppressGeneratedFiles.set(false) | ||
|
||
sourceLink { | ||
localDirectory.set(project.projectDir) | ||
remoteUrl.set(URL("https://github.com/kordlib/kord/blob/${Library.commitHashOrDefault("0.9.x")}/${project.name}")) | ||
remoteLineSuffix.set("#L") | ||
} | ||
|
||
externalDocumentationLink("https://kotlinlang.org/api/kotlinx.coroutines/") | ||
externalDocumentationLink("https://kotlinlang.org/api/kotlinx.serialization/") | ||
externalDocumentationLink( | ||
url = "https://kotlinlang.org/api/kotlinx-datetime/", | ||
packageListUrl = "https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/package-list", | ||
) | ||
externalDocumentationLink("https://api.ktor.io/") | ||
|
||
// don't list `TweetNaclFast` in docs | ||
perPackageOption { | ||
matchingRegex.set("""com\.iwebpp\.crypto""") | ||
suppress.set(true) | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
plugins { | ||
org.jetbrains.kotlin.multiplatform | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
kotlin { | ||
jvm() | ||
js(IR) { | ||
nodejs() | ||
} | ||
jvmToolchain(Jvm.target) | ||
|
||
targets { | ||
all { | ||
compilations.all { | ||
compilerOptions.options.applyKordCompilerOptions() | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.