diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index d6abfed304d..41189bbfb2a 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 63125e6daf7..63f7476e501 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 d34b122835e..b429ef81d04 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 927677dde73..d702180bf1a 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 d8efe0d18a8..e0aa14087fa 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 c326190d659..9940a3e3158 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 ea3b8e3de70..6ff2ebf0210 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 6e3372b6f27..39c09f00a66 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 4d38af49489..470698576a3 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 7db0c64b3ef..1e96bd4847c 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 84b8ef3b862..f97f0f061b5 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 4c25f2582ee..caf73baae0e 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 86ba3458131..94c25ca2818 100644 --- a/voice/build.gradle.kts +++ b/voice/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - `kord-targets` `kord-multiplatform-module` `kord-publishing` }