blob: 33edc12673059203b897b80c9ec12dede4b8b67b [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
import static androidx.build.dependencies.DependenciesKt.*
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 KOTLIN_STDLIB_COMMON
}
}
commonTest {
dependencies {
implementation KOTLIN_TEST_COMMON
implementation KOTLIN_TEST_ANNOTATIONS_COMMON
}
}
// 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 KOTLIN_STDLIB_JDK8
}
}
// 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 KOTLIN_TEST
implementation KOTLIN_TEST_JUNIT
}
}
jsMain {
dependencies {
implementation KOTLIN_STDLIB_JS
}
}
jsTest {
dependencies {
implementation KOTLIN_TEST_JS
}
}
}
}
// 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
}