diff options
Diffstat (limited to 'gradle/configure-source-sets.gradle')
-rw-r--r-- | gradle/configure-source-sets.gradle | 99 |
1 files changed, 91 insertions, 8 deletions
diff --git a/gradle/configure-source-sets.gradle b/gradle/configure-source-sets.gradle index e7888eea..f744b171 100644 --- a/gradle/configure-source-sets.gradle +++ b/gradle/configure-source-sets.gradle @@ -1,36 +1,67 @@ /* - * Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * 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() - configure([compilations.main, compilations.test]) { + compilations.configureEach { kotlinOptions { - jvmTarget = '1.6' - freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning" + jvmTarget = '1.8' + freeCompilerArgs += '-Xjdk-release=1.8' } } } js { - nodejs {} + nodejs { + testTask { + useMocha { + timeout = "10s" + } + } + } configure([compilations.main, compilations.test]) { kotlinOptions { sourceMap = true moduleKind = "umd" - metaInfo = true } } } + wasmJs { + nodejs() + } + + if (!isOkIoOrFormatTests) { + wasmWasi { + nodejs() + } + } + sourceSets.all { kotlin.srcDirs = ["$it.name/src"] resources.srcDirs = ["$it.name/resources"] languageSettings { progressiveMode = true - optIn("kotlin.Experimental") optIn("kotlin.ExperimentalMultiplatform") optIn("kotlin.ExperimentalStdlibApi") optIn("kotlinx.serialization.InternalSerializationApi") @@ -75,6 +106,43 @@ kotlin { } } + 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 { } } @@ -91,6 +159,15 @@ kotlin { } 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 @@ -98,7 +175,7 @@ kotlin { } } - def targetsWithoutTestRunners = ["linuxArm32Hfp", "linuxArm64", "mingwX86"] + 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) }) { @@ -113,3 +190,9 @@ kotlin { } } } + +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" +}
\ No newline at end of file |