| /* |
| * Copyright 2017-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
| */ |
| |
| import static KotlinVersion.* |
| |
| java { |
| toolchain { |
| languageVersion.set(JavaLanguageVersion.of(11)) |
| } |
| } |
| |
| tasks.withType(JavaCompile).configureEach { |
| options.release = 8 |
| } |
| |
| // Unfortunately there is no compatible version of okio for Wasm WASI target, so we need to skip to configure WASI for json-okio and json-tests. |
| // json-tests uses okio with incorporate with other formatter tests so it is hard and not worth to separate it for two projects for WASI. |
| // So we disable WASI target in it and we hope, that WASI version of compiler and serialization plugin are identical to the WasmJS target so WASI target is being covered. |
| Boolean isOkIoOrFormatTests = (project.name == 'kotlinx-serialization-json-okio' || project.name == 'kotlinx-serialization-json-tests') |
| |
| kotlin { |
| jvm { |
| withJava() |
| compilations.configureEach { |
| kotlinOptions { |
| jvmTarget = '1.8' |
| freeCompilerArgs += '-Xjdk-release=1.8' |
| } |
| } |
| } |
| |
| js { |
| nodejs { |
| testTask { |
| useMocha { |
| timeout = "10s" |
| } |
| } |
| } |
| configure([compilations.main, compilations.test]) { |
| kotlinOptions { |
| sourceMap = true |
| moduleKind = "umd" |
| } |
| } |
| } |
| |
| wasmJs { |
| nodejs() |
| } |
| |
| if (!isOkIoOrFormatTests) { |
| wasmWasi { |
| nodejs() |
| } |
| } |
| |
| sourceSets.all { |
| kotlin.srcDirs = ["$it.name/src"] |
| resources.srcDirs = ["$it.name/resources"] |
| languageSettings { |
| progressiveMode = true |
| |
| optIn("kotlin.ExperimentalMultiplatform") |
| optIn("kotlin.ExperimentalStdlibApi") |
| optIn("kotlinx.serialization.InternalSerializationApi") |
| } |
| } |
| |
| sourceSets { |
| commonMain { |
| dependencies { |
| api 'org.jetbrains.kotlin:kotlin-stdlib-common' |
| } |
| } |
| |
| commonTest { |
| dependencies { |
| api 'org.jetbrains.kotlin:kotlin-test-common' |
| api 'org.jetbrains.kotlin:kotlin-test-annotations-common' |
| } |
| } |
| |
| jvmMain { |
| dependencies { |
| api 'org.jetbrains.kotlin:kotlin-stdlib' |
| } |
| } |
| |
| jvmTest { |
| dependencies { |
| api 'org.jetbrains.kotlin:kotlin-test-junit' |
| } |
| } |
| |
| jsMain { |
| dependencies { |
| api 'org.jetbrains.kotlin:kotlin-stdlib-js' |
| } |
| } |
| |
| jsTest { |
| dependencies { |
| api 'org.jetbrains.kotlin:kotlin-test-js' |
| } |
| } |
| |
| create("wasmMain") { |
| dependsOn(commonMain) |
| } |
| create("wasmTest") { |
| dependsOn(commonTest) |
| } |
| |
| wasmJsMain { |
| dependsOn(wasmMain) |
| dependencies { |
| api 'org.jetbrains.kotlin:kotlin-stdlib-wasm-js' |
| } |
| } |
| |
| wasmJsTest { |
| dependsOn(wasmTest) |
| dependencies { |
| api 'org.jetbrains.kotlin:kotlin-test-wasm-js' |
| } |
| } |
| |
| if (!isOkIoOrFormatTests) { |
| wasmWasiMain { |
| dependsOn(wasmMain) |
| dependencies { |
| api 'org.jetbrains.kotlin:kotlin-stdlib-wasm-wasi' |
| } |
| } |
| |
| wasmWasiTest { |
| dependsOn(wasmTest) |
| dependencies { |
| api 'org.jetbrains.kotlin:kotlin-test-wasm-wasi' |
| } |
| } |
| } |
| |
| nativeMain.dependencies { |
| } |
| } |
| |
| sourceSets.findAll({ it.name.contains("Test") }).forEach { srcSet -> |
| srcSet.languageSettings { |
| it.optIn("kotlinx.serialization.InternalSerializationApi") |
| it.optIn("kotlinx.serialization.ExperimentalSerializationApi") |
| } |
| } |
| |
| sourceSets.matching({ it.name.contains("Main") }).all { srcSet -> |
| project.ext.set("kotlin.mpp.freeCompilerArgsForSourceSet.${srcSet.name}", ["-Xexplicit-api=strict"]) |
| } |
| |
| targets.all { |
| compilations.all { |
| kotlinOptions { |
| if (rootProject.ext.kotlin_lv_override != null) { |
| languageVersion = rootProject.ext.kotlin_lv_override |
| freeCompilerArgs += "-Xsuppress-version-warnings" |
| } |
| freeCompilerArgs += "-Xexpect-actual-classes" |
| } |
| } |
| compilations.main { |
| kotlinOptions { |
| allWarningsAsErrors = true |
| } |
| } |
| } |
| |
| def targetsWithoutTestRunners = ["linuxArm64", "linuxArm32Hfp"] |
| configure(targets) { |
| // Configure additional binaries to run tests in the background |
| if (["macos", "linux", "mingw"].any { name.startsWith(it) && !targetsWithoutTestRunners.contains(name) }) { |
| binaries { |
| test("background", [nativeDebugBuild]) { |
| freeCompilerArgs += ["-trw"] |
| } |
| } |
| testRuns { |
| background { setExecutionSourceFrom(binaries.backgroundDebugTest) } |
| } |
| } |
| } |
| } |
| |
| rootProject.extensions.findByType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension.class).with { |
| // canary nodejs that supports recent Wasm GC changes |
| it.nodeVersion = "21.0.0-v8-canary202309167e82ab1fa2" |
| it.nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary" |
| } |