5
5
@file:OptIn(ExperimentalWasmDsl ::class )
6
6
7
7
import org.gradle.kotlin.dsl.*
8
+ import org.jetbrains.kotlin.gradle.*
9
+ import org.jetbrains.kotlin.gradle.dsl.*
8
10
import 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
10
12
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
11
13
import org.jetbrains.kotlin.gradle.targets.native.tasks.*
14
+ import org.jetbrains.kotlin.gradle.tasks.*
12
15
import org.jetbrains.kotlin.gradle.testing.*
13
16
14
17
plugins {
15
18
kotlin(" multiplatform" )
16
19
}
17
20
18
- java {
19
- toolchain {
20
- languageVersion.set(JavaLanguageVersion .of(11 ))
21
- }
22
- }
23
-
24
21
tasks.withType<JavaCompile >().configureEach {
25
22
options.release = 8
26
23
}
@@ -30,13 +27,13 @@ kotlin {
30
27
31
28
jvm {
32
29
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" )
38
34
}
39
35
}
36
+ jvmToolchain(jdkToolchainVersion)
40
37
41
38
js {
42
39
nodejs {
@@ -46,11 +43,11 @@ kotlin {
46
43
}
47
44
}
48
45
}
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
54
51
}
55
52
}
56
53
@@ -154,19 +151,18 @@ kotlin {
154
151
optIn(" kotlinx.serialization.ExperimentalSerializationApi" )
155
152
}
156
153
}
154
+ }
157
155
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) {
169
160
allWarningsAsErrors = true
170
161
}
162
+ if (overriddenLanguageVersion != null ) {
163
+ languageVersion = KotlinVersion .fromVersion(overriddenLanguageVersion!! )
164
+ freeCompilerArgs.add(" -Xsuppress-version-warnings" )
165
+ }
166
+ freeCompilerArgs.add(" -Xexpect-actual-classes" )
171
167
}
172
168
}
0 commit comments