blob: ec119e6f35916c49894018077cd501418ac5919d [file] [log] [blame]
/*
* Copyright 2024 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.
*/
/**
* This file was created using the `create_project.py` script located in the
* `<AndroidX root>/development/project-creator` directory.
*
* Please use that script when creating a new project, rather than copying an existing project and
* modifying its settings.
*/
import androidx.build.KotlinTarget
import androidx.build.LibraryType
import androidx.build.PlatformIdentifier
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.konan.target.Family
plugins {
id("AndroidXPlugin")
}
androidXMultiplatform {
androidLibrary {
namespace = "androidx.lifecycle.viewmodel.testing"
withAndroidTestOnDeviceBuilder {
it.compilationName = "instrumentedTest"
it.defaultSourceSetName = "androidInstrumentedTest"
it.sourceSetTreeName = "test"
}
withAndroidTestOnJvmBuilder {
it.defaultSourceSetName = "androidUnitTest"
it.compilationName = "unitTest"
}
}
desktop()
mac()
linux()
ios()
defaultPlatform(PlatformIdentifier.ANDROID)
sourceSets {
commonMain {
dependencies {
api(project(":lifecycle:lifecycle-viewmodel"))
api(libs.kotlinStdlib)
api(libs.kotlinCoroutinesCore)
implementation(project(":lifecycle:lifecycle-runtime"))
implementation(project(":lifecycle:lifecycle-runtime-testing"))
implementation(project(":lifecycle:lifecycle-viewmodel-savedstate"))
}
}
commonTest {
dependencies {
implementation(project(":kruth:kruth"))
implementation(libs.kotlinTest)
implementation(libs.kotlinCoroutinesTest)
}
}
jvmMain {
dependsOn(commonMain)
}
jvmTest {
dependsOn(commonTest)
}
androidMain {
dependsOn(commonMain)
dependsOn(jvmMain)
}
androidUnitTest {
dependsOn(commonTest)
dependsOn(jvmTest)
dependencies {
implementation(libs.robolectric)
}
}
androidInstrumentedTest {
dependsOn(commonTest)
dependsOn(jvmTest)
dependencies {
implementation("androidx.core:core-ktx:1.2.0")
implementation(libs.testExtJunit)
implementation(libs.testCore)
implementation(libs.testRunner)
}
}
nonAndroidMain {
dependsOn(commonMain)
}
nonAndroidTest {
dependsOn(commonTest)
}
desktopMain {
dependsOn(jvmMain)
dependsOn(nonAndroidMain)
}
desktopTest {
dependsOn(jvmTest)
dependsOn(nonAndroidTest)
}
nativeMain {
dependsOn(commonMain)
dependsOn(nonAndroidMain)
}
nativeTest {
dependsOn(commonTest)
dependsOn(nonAndroidTest)
}
darwinMain {
dependsOn(nativeMain)
}
darwinTest {
dependsOn(nativeTest)
}
linuxMain {
dependsOn(nativeMain)
}
linuxTest {
dependsOn(nativeTest)
}
targets.configureEach { target ->
if (target.platformType == org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.native) {
target.compilations["main"].defaultSourceSet {
def konanTargetFamily = target.konanTarget.family
if (konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.OSX || konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.IOS) {
dependsOn(darwinMain)
} else if (konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.LINUX) {
dependsOn(linuxMain)
} else {
throw new GradleException("unknown native target ${target}")
}
}
target.compilations["test"].defaultSourceSet {
def konanTargetFamily = target.konanTarget.family
if (konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.OSX || konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.IOS) {
dependsOn(darwinTest)
} else if (konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.LINUX) {
dependsOn(linuxTest)
} else {
throw new GradleException("unknown native target ${target}")
}
}
}
}
}
}
androidx {
name = "Lifecycle ViewModel Testing"
type = LibraryType.PUBLISHED_TEST_LIBRARY
inceptionYear = "2024"
description = "Testing utilities for 'lifecycle-viewmodel' artifact"
kotlinTarget = KotlinTarget.KOTLIN_1_9
}