diff --git a/buildSrc/src/main/kotlin/Compiler.kt b/buildSrc/src/main/kotlin/Compiler.kt index 00b3f31b5b6..6caa6484fc3 100644 --- a/buildSrc/src/main/kotlin/Compiler.kt +++ b/buildSrc/src/main/kotlin/Compiler.kt @@ -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( @@ -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.applyKordTestOptIns() { named { it.contains("test", ignoreCase = true) }.configureEach { // allow `ExperimentalCoroutinesApi` for `TestScope.currentTime` diff --git a/buildSrc/src/main/kotlin/kord-internal-module.gradle.kts b/buildSrc/src/main/kotlin/kord-internal-module.gradle.kts index 102f730ea2e..ad9b04bb4d1 100644 --- a/buildSrc/src/main/kotlin/kord-internal-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-internal-module.gradle.kts @@ -7,8 +7,13 @@ repositories { } kotlin { - jvmToolchain(Jvm.target) compilerOptions { - applyKordCompilerOptions() + applyKordJvmCompilerOptions() + } +} + +tasks { + withType().configureEach { + options.release = KORD_JVM_TARGET } } diff --git a/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts index 236b1027f1c..076b387f80e 100644 --- a/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts @@ -8,18 +8,21 @@ repositories { mavenCentral() } +@OptIn(ExperimentalKotlinGradlePluginApi::class) kotlin { - jvm() + compilerOptions { + applyKordCommonCompilerOptions() + } + + jvm { + compilerOptions { + applyKordJvmCompilerOptions() + } + } js { nodejs() useCommonJs() } - jvmToolchain(Jvm.target) - - @OptIn(ExperimentalKotlinGradlePluginApi::class) - compilerOptions { - applyKordCompilerOptions() - } } tasks { diff --git a/buildSrc/src/main/kotlin/kord-module.gradle.kts b/buildSrc/src/main/kotlin/kord-module.gradle.kts index f46703c0f73..19322086bd4 100644 --- a/buildSrc/src/main/kotlin/kord-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-module.gradle.kts @@ -24,11 +24,8 @@ apiValidation { kotlin { explicitApi() - - jvmToolchain(Jvm.target) - compilerOptions { - applyKordCompilerOptions() + applyKordJvmCompilerOptions() optIn.addAll(kordOptIns) } @@ -45,6 +42,10 @@ tasks { withType().configureEach { applyKordDokkaOptions() } + + withType().configureEach { + options.release = KORD_JVM_TARGET + } } publishing { diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index 77ec746acbd..5a28f04dd8c 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -23,10 +23,19 @@ apiValidation { applyKordBCVOptions() } +@OptIn(ExperimentalKotlinGradlePluginApi::class) kotlin { explicitApi() + compilerOptions { + applyKordCommonCompilerOptions() + optIn.addAll(kordOptIns) + } - jvm() + jvm { + compilerOptions { + applyKordJvmCompilerOptions() + } + } js { nodejs { testTask { @@ -39,13 +48,6 @@ kotlin { } useCommonJs() } - jvmToolchain(Jvm.target) - - @OptIn(ExperimentalKotlinGradlePluginApi::class) - compilerOptions { - applyKordCompilerOptions() - optIn.addAll(kordOptIns) - } applyDefaultHierarchyTemplate() diff --git a/settings.gradle.kts b/settings.gradle.kts index d0ab04959b0..2a6e06084e9 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,8 +1,3 @@ -plugins { - // https://github.com/gradle/foojay-toolchains - id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" -} - rootProject.name = "kord" include(