1/* 2 * Copyright 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17/** 18 * This file was created using the `create_project.py` script located in the 19 * `<AndroidX root>/development/project-creator` directory. 20 * 21 * Please use that script when creating a new project, rather than copying an existing project and 22 * modifying its settings. 23 */ 24 25 26import androidx.build.SoftwareType 27import androidx.build.PlatformIdentifier 28import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType 29import org.jetbrains.kotlin.konan.target.Family 30 31plugins { 32 id("AndroidXPlugin") 33 id("com.android.library") 34} 35 36androidXMultiplatform { 37 androidTarget() 38 desktop() 39 mac() 40 linux() 41 ios() 42 43 defaultPlatform(PlatformIdentifier.ANDROID) 44 45 sourceSets { 46 commonMain { 47 dependencies { 48 api(project(":lifecycle:lifecycle-viewmodel")) 49 api(libs.kotlinStdlib) 50 api(libs.kotlinCoroutinesCore) 51 implementation(project(":lifecycle:lifecycle-runtime")) 52 implementation(project(":lifecycle:lifecycle-runtime-testing")) 53 implementation(project(":lifecycle:lifecycle-viewmodel-savedstate")) 54 } 55 } 56 57 commonTest { 58 dependencies { 59 implementation(project(":kruth:kruth")) 60 implementation(libs.kotlinTest) 61 implementation(libs.kotlinCoroutinesTest) 62 } 63 } 64 65 jvmMain { 66 dependsOn(commonMain) 67 } 68 69 jvmTest { 70 dependsOn(commonTest) 71 } 72 73 androidMain { 74 dependsOn(commonMain) 75 dependsOn(jvmMain) 76 } 77 78 androidUnitTest { 79 dependsOn(commonTest) 80 dependsOn(jvmTest) 81 dependencies { 82 implementation(libs.robolectric) 83 } 84 } 85 86 androidInstrumentedTest { 87 dependsOn(commonTest) 88 dependsOn(jvmTest) 89 dependencies { 90 implementation("androidx.core:core-ktx:1.2.0") 91 implementation(libs.testExtJunit) 92 implementation(libs.testCore) 93 implementation(libs.testRunner) 94 } 95 } 96 97 nonAndroidMain { 98 dependsOn(commonMain) 99 } 100 101 nonAndroidTest { 102 dependsOn(commonTest) 103 } 104 105 desktopMain { 106 dependsOn(jvmMain) 107 dependsOn(nonAndroidMain) 108 } 109 110 desktopTest { 111 dependsOn(jvmTest) 112 dependsOn(nonAndroidTest) 113 } 114 115 nativeMain { 116 dependsOn(commonMain) 117 dependsOn(nonAndroidMain) 118 } 119 120 nativeTest { 121 dependsOn(commonTest) 122 dependsOn(nonAndroidTest) 123 } 124 125 darwinMain { 126 dependsOn(nativeMain) 127 } 128 129 darwinTest { 130 dependsOn(nativeTest) 131 } 132 133 linuxMain { 134 dependsOn(nativeMain) 135 } 136 137 linuxTest { 138 dependsOn(nativeTest) 139 } 140 141 targets.configureEach { target -> 142 if (target.platformType == org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.native) { 143 target.compilations["main"].defaultSourceSet { 144 def konanTargetFamily = target.konanTarget.family 145 if (konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.OSX || konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.IOS) { 146 dependsOn(darwinMain) 147 } else if (konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.LINUX) { 148 dependsOn(linuxMain) 149 } else { 150 throw new GradleException("unknown native target ${target}") 151 } 152 } 153 target.compilations["test"].defaultSourceSet { 154 def konanTargetFamily = target.konanTarget.family 155 if (konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.OSX || konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.IOS) { 156 dependsOn(darwinTest) 157 } else if (konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.LINUX) { 158 dependsOn(linuxTest) 159 } else { 160 throw new GradleException("unknown native target ${target}") 161 } 162 } 163 } 164 } 165 } 166} 167 168androidx { 169 name = "Lifecycle ViewModel Testing" 170 type = SoftwareType.PUBLISHED_TEST_LIBRARY 171 inceptionYear = "2024" 172 description = "Testing utilities for 'lifecycle-viewmodel' artifact" 173} 174 175android { 176 namespace "androidx.lifecycle.viewmodel.testing" 177} 178