55@file:OptIn(ExperimentalWasmDsl ::class )
66
77import org.gradle.kotlin.dsl.*
8+ import org.jetbrains.kotlin.gradle.*
9+ import org.jetbrains.kotlin.gradle.dsl.*
810import org.jetbrains.kotlin.gradle.plugin.mpp.*
9- import org.jetbrains.kotlin.gradle.targets.js.dsl.*
11+ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
1012import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
1113import org.jetbrains.kotlin.gradle.targets.native.tasks.*
14+ import org.jetbrains.kotlin.gradle.tasks.*
1215import org.jetbrains.kotlin.gradle.testing.*
1316
1417plugins {
1518 kotlin(" multiplatform" )
1619}
1720
18- java {
19- toolchain {
20- languageVersion.set(JavaLanguageVersion .of(11 ))
21- }
22- }
23-
2421tasks.withType<JavaCompile >().configureEach {
2522 options.release = 8
2623}
@@ -30,13 +27,13 @@ kotlin {
3027
3128 jvm {
3229 withJava()
33- compilations.configureEach {
34- kotlinOptions {
35- jvmTarget = " 1.8"
36- freeCompilerArgs + = " -Xjdk-release=1.8"
37- }
30+ @OptIn(ExperimentalKotlinGradlePluginApi ::class )
31+ compilerOptions {
32+ jvmTarget = JvmTarget .JVM_1_8
33+ freeCompilerArgs.add(" -Xjdk-release=1.8" )
3834 }
3935 }
36+ jvmToolchain(jdkToolchainVersion)
4037
4138 js {
4239 nodejs {
@@ -46,11 +43,11 @@ kotlin {
4643 }
4744 }
4845 }
49- compilations.matching { it.name == " main " || it.name == " test " }.configureEach {
50- kotlinOptions {
51- sourceMap = true
52- moduleKind = " umd "
53- }
46+
47+ @OptIn( ExperimentalKotlinGradlePluginApi :: class )
48+ compilerOptions {
49+ sourceMap = true
50+ moduleKind = JsModuleKind . MODULE_UMD
5451 }
5552 }
5653
@@ -154,19 +151,18 @@ kotlin {
154151 optIn(" kotlinx.serialization.ExperimentalSerializationApi" )
155152 }
156153 }
154+ }
157155
158- targets.all {
159- compilations.all {
160- kotlinOptions {
161- if (overriddenLanguageVersion != null ) {
162- languageVersion = overriddenLanguageVersion
163- freeCompilerArgs + = " -Xsuppress-version-warnings"
164- }
165- freeCompilerArgs + = " -Xexpect-actual-classes"
166- }
167- }
168- compilations[" main" ].kotlinOptions {
156+ tasks.withType(KotlinCompilationTask ::class ).configureEach {
157+ compilerOptions {
158+ val isMainTaskName = name.startsWith(" compileKotlin" )
159+ if (isMainTaskName) {
169160 allWarningsAsErrors = true
170161 }
162+ if (overriddenLanguageVersion != null ) {
163+ languageVersion = KotlinVersion .fromVersion(overriddenLanguageVersion!! )
164+ freeCompilerArgs.add(" -Xsuppress-version-warnings" )
165+ }
166+ freeCompilerArgs.add(" -Xexpect-actual-classes" )
171167 }
172168}
0 commit comments