diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index d6abfed304d4..41189bbfb2a2 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -12,6 +12,7 @@ repositories { kotlin { compilerOptions { allWarningsAsErrors = true + freeCompilerArgs.add("-Xcontext-receivers") } } diff --git a/buildSrc/src/main/kotlin/kord-targets.gradle.kts b/buildSrc/src/main/kotlin/Targets.kt similarity index 62% rename from buildSrc/src/main/kotlin/kord-targets.gradle.kts rename to buildSrc/src/main/kotlin/Targets.kt index 63125e6daf76..63f7476e5012 100644 --- a/buildSrc/src/main/kotlin/kord-targets.gradle.kts +++ b/buildSrc/src/main/kotlin/Targets.kt @@ -1,10 +1,10 @@ +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension +import org.jetbrains.kotlin.gradle.kpm.external.ExternalVariantApi +import org.jetbrains.kotlin.gradle.kpm.external.project import org.jetbrains.kotlin.konan.target.HostManager -plugins { - org.jetbrains.kotlin.multiplatform -} - -kotlin { +@OptIn(ExternalVariantApi::class) +fun KotlinMultiplatformExtension.targets() { // There are issues with compiling the linux variant on windows // Please use WSL if you need to work on the linux port if (!HostManager.hostIsMingw) { @@ -14,7 +14,7 @@ kotlin { jvm() - if (name != "voice" && name != "core-voice") { + if (project.name != "voice" && project.name != "core-voice") { mingwX64() js { nodejs() diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index d34b122835e8..b429ef81d044 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -36,6 +36,7 @@ kotlin { } } + targets() explicitApi() jvmToolchain(Jvm.target) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 927677dde737..d702180bf1a7 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -2,13 +2,13 @@ import dev.kord.gradle.tools.util.commitHash import dev.kord.gradle.tools.util.shortCommitHash plugins { - `kord-targets` `kord-multiplatform-module` `kord-publishing` alias(libs.plugins.buildconfig) } kotlin { + targets() sourceSets { commonMain { dependencies { diff --git a/core-voice/build.gradle.kts b/core-voice/build.gradle.kts index d8efe0d18a8a..e0aa14087fad 100644 --- a/core-voice/build.gradle.kts +++ b/core-voice/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - `kord-targets` `kord-multiplatform-module` `kord-publishing` } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index c326190d6593..9940a3e31580 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - `kord-targets` `kord-multiplatform-module` `kord-publishing` } diff --git a/core/live-tests/build.gradle.kts b/core/live-tests/build.gradle.kts index ea3b8e3de708..6ff2ebf02104 100644 --- a/core/live-tests/build.gradle.kts +++ b/core/live-tests/build.gradle.kts @@ -1,8 +1,9 @@ plugins { - `kord-targets` + org.jetbrains.kotlin.multiplatform } kotlin { + targets() sourceSets { all { applyKordOptIns() diff --git a/gateway/build.gradle.kts b/gateway/build.gradle.kts index 6e3372b6f274..39c09f00a66d 100644 --- a/gateway/build.gradle.kts +++ b/gateway/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - `kord-targets` `kord-multiplatform-module` `kord-publishing` } diff --git a/ksp-annotations/build.gradle.kts b/ksp-annotations/build.gradle.kts index 4d38af494894..470698576a38 100644 --- a/ksp-annotations/build.gradle.kts +++ b/ksp-annotations/build.gradle.kts @@ -1,13 +1,16 @@ import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask plugins { - `kord-targets` - + org.jetbrains.kotlin.multiplatform // workaround for https://youtrack.jetbrains.com/issue/KT-43500 (not intended to be published) org.jetbrains.dokka `kord-publishing` } +kotlin { + targets() +} + tasks.withType().configureEach { dokkaSourceSets.configureEach { suppress = true diff --git a/rest/build.gradle.kts b/rest/build.gradle.kts index 7db0c64b3ef0..1e96bd4847c6 100644 --- a/rest/build.gradle.kts +++ b/rest/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - `kord-targets` `kord-multiplatform-module` `kord-publishing` } diff --git a/samples/build.gradle.kts b/samples/build.gradle.kts index 84b8ef3b8626..f97f0f061b5f 100644 --- a/samples/build.gradle.kts +++ b/samples/build.gradle.kts @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.konan.target.Family plugins { - `kord-targets` + org.jetbrains.kotlin.multiplatform } @OptIn(ExperimentalKotlinGradlePluginApi::class) @@ -17,9 +17,7 @@ kotlin { } } } - js { - binaries.executable() - } + targets() targets.withType { // Voice does not target windows, so we disable it diff --git a/test-kit/build.gradle.kts b/test-kit/build.gradle.kts index 4c25f2582ee3..caf73baae0e6 100644 --- a/test-kit/build.gradle.kts +++ b/test-kit/build.gradle.kts @@ -1,7 +1,7 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi plugins { - `kord-targets` + org.jetbrains.kotlin.multiplatform } @OptIn(ExperimentalKotlinGradlePluginApi::class) @@ -15,6 +15,7 @@ kotlin { } } } + targets() sourceSets { commonMain { dependencies { diff --git a/voice/build.gradle.kts b/voice/build.gradle.kts index 86ba34581311..94c25ca28188 100644 --- a/voice/build.gradle.kts +++ b/voice/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - `kord-targets` `kord-multiplatform-module` `kord-publishing` }