1/* 2 * Copyright 2017 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 25import androidx.build.SoftwareType 26import androidx.build.PlatformIdentifier 27import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType 28import org.jetbrains.kotlin.konan.target.Family 29 30plugins { 31 id("AndroidXPlugin") 32 id("com.android.library") 33} 34 35androidXMultiplatform { 36 androidTarget() 37 desktop() 38 mac() 39 linux() 40 ios() 41 42 defaultPlatform(PlatformIdentifier.ANDROID) 43 44 sourceSets { 45 configureEach { 46 languageSettings.optIn("kotlin.contracts.ExperimentalContracts") 47 } 48 49 commonMain { 50 dependencies { 51 api("androidx.annotation:annotation:1.8.1") 52 api(libs.kotlinStdlib) 53 api(libs.kotlinCoroutinesCore) 54 } 55 } 56 57 commonTest { 58 dependencies { 59 implementation(project(":kruth:kruth")) 60 implementation(libs.kotlinTest) 61 implementation(libs.kotlinCoroutinesTest) 62 } 63 } 64 65 jvmCommonMain { 66 dependsOn(commonMain) 67 } 68 69 jvmCommonTest { 70 dependsOn(commonTest) 71 dependencies { 72 implementation(libs.junit) 73 } 74 } 75 76 androidMain { 77 dependsOn(jvmCommonMain) 78 dependencies { 79 api(libs.kotlinCoroutinesAndroid) 80 implementation("androidx.core:core-viewtree:1.0.0") 81 } 82 } 83 84 androidUnitTest { 85 dependsOn(jvmCommonTest) 86 dependencies { 87 implementation(libs.mockitoCore4) 88 } 89 } 90 91 androidInstrumentedTest { 92 dependsOn(commonTest) 93 dependencies { 94 implementation("androidx.core:core-ktx:1.2.0") 95 implementation(libs.testExtJunit) 96 implementation(libs.testCore) 97 implementation(libs.testRunner) 98 } 99 } 100 101 desktopMain { dependsOn(jvmCommonMain) } 102 nonJvmCommonMain { dependsOn(commonMain) } 103 nativeMain { dependsOn(nonJvmCommonMain) } 104 darwinMain { dependsOn(nativeMain) } 105 linuxMain { dependsOn(nativeMain) } 106 107 targets.configureEach { target -> 108 if (target.platformType == KotlinPlatformType.native) { 109 target.compilations["main"].defaultSourceSet { 110 def konanTargetFamily = target.konanTarget.family 111 if (konanTargetFamily == Family.OSX || konanTargetFamily == Family.IOS) { 112 dependsOn(darwinMain) 113 } else if (konanTargetFamily == Family.LINUX) { 114 dependsOn(linuxMain) 115 } else { 116 throw new GradleException("unknown native target ${target}") 117 } 118 } 119 } 120 } 121 } 122} 123 124android { 125 buildTypes.configureEach { 126 consumerProguardFiles "proguard-rules.pro" 127 } 128 namespace = "androidx.lifecycle.viewmodel" 129} 130 131androidx { 132 name = "Lifecycle ViewModel" 133 type = SoftwareType.PUBLISHED_LIBRARY 134 inceptionYear = "2017" 135 description = "Android Lifecycle ViewModel" 136 metalavaK2UastEnabled = false 137} 138