blob: 532e2cae04ea55804dcc1ee1fa9dd28e0708682a [file] [log] [blame]
/*
* 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
}
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"
metaInfo = true
}
}
}
wasmJs {
d8()
}
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'
}
}
wasmJsMain {
kotlin {
srcDir 'wasmMain/src'
}
dependencies {
api 'org.jetbrains.kotlin:kotlin-stdlib-wasm-js'
}
}
wasmJsTest {
kotlin {
srcDir 'wasmTest/src'
}
dependencies {
api 'org.jetbrains.kotlin:kotlin-test-wasm-js'
}
}
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"]
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) }
}
}
}
}