blob: 45ddd3fc751ae9e1bb1eacb72d631c5bf4f261d7 [file] [log] [blame]
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import androidx.build.Publish
plugins {
id("kotlin-multiplatform")
id("AndroidXPlugin")
id("com.android.library")
}
kotlin {
// Use Kotlin-MPP plugin target presets for 4 platforms. These create both XYZMain and XYZTest
// sourcesets.
targets {
android()
js()
jvm()
fromPreset(presets.linuxX64, "linux")
}
// We specify additional dependencies for the presets above in the sourceSets block.
sourceSets {
// commonMain and commonTest are special: a copy of them is automatically
// included (implicit "dependsOn") in all sourcesets in the Kotlin MPP presets.
commonMain {
dependencies {
implementation(libs.kotlinStdlibCommon)
}
}
commonTest {
dependencies {
implementation(libs.kotlinTestCommon)
implementation(libs.kotlinTestAnnotationsCommon)
}
}
// Note that although we don't have androidXYZ/ directories, Android targets are still
// generated from the commonMain/commonTest/jvmMain/jvmTest, given the android() preset.
androidMain {
dependsOn(jvmMain)
}
// TODO: Android test names will change after https://youtrack.jetbrains.com/issue/KT-34650
androidTest {
dependsOn(jvmTest)
}
androidAndroidTest {
dependsOn(jvmTest)
}
jvmMain {
dependencies {
implementation(libs.kotlinStdlibJdk8)
}
}
// jvmTest differs from androidTest in that it fails at compile-time if any android
// dependencies are included, whereas androidTest fails at runtime only if they are used.
jvmTest {
dependencies {
implementation(libs.kotlinTest)
implementation(libs.kotlinTestJunit)
}
}
jsMain {
dependencies {
implementation(libs.kotlinStdlibJs)
}
}
jsTest {
dependencies {
implementation(libs.kotlinTestJs)
}
}
}
}
// TODO(aelias): Add dokka { multiplatform {} } block
androidx {
name = "Kotlin-MPP Sample Library"
publish = Publish.NONE
}
//TODO: Remove after upgrading Kotlin to >=1.3.50 (https://youtrack.jetbrains.net/issue/KT-33246)
linuxTest.configure {
binaryResultsDirectory = binResultsDir
}