1/* 2 * Copyright 2020 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 27 28plugins { 29 id("AndroidXPlugin") 30 id("com.android.library") 31 id("AndroidXComposePlugin") 32 alias(libs.plugins.kotlinSerialization) 33} 34 35androidXMultiplatform { 36 androidTarget() 37 jvmStubs() 38 linuxX64Stubs() 39 40 defaultPlatform(PlatformIdentifier.ANDROID) 41 42 sourceSets { 43 commonMain { 44 dependencies { 45 api(project(":lifecycle:lifecycle-common")) 46 api(project(":lifecycle:lifecycle-viewmodel")) 47 api("androidx.annotation:annotation:1.8.1") 48 api("androidx.compose.runtime:runtime:1.7.8") 49 api(libs.kotlinSerializationCore) 50 implementation(libs.kotlinStdlib) 51 } 52 } 53 54 commonTest { 55 dependencies { 56 implementation(project(":lifecycle:lifecycle-viewmodel-savedstate")) 57 implementation(project(":lifecycle:lifecycle-viewmodel-testing")) 58 implementation(project(":lifecycle:lifecycle-runtime-testing")) 59 } 60 } 61 62 androidMain { 63 dependsOn(commonMain) 64 dependencies { 65 api(project(":lifecycle:lifecycle-viewmodel-savedstate")) 66 api("androidx.compose.ui:ui:1.7.8") 67 // Converting `lifecycle-viewmodel-compose` to KMP and including a transitive 68 // dependency on `lifecycle-livedata-core` triggered a Gradle bug. Adding the 69 // `livedata` dependency directly works around the issue. 70 // See https://github.com/gradle/gradle/issues/14220 for details. 71 compileOnly(project(":lifecycle:lifecycle-livedata-core")) 72 } 73 } 74 75 androidInstrumentedTest { 76 dependsOn(commonTest) 77 dependencies { 78 implementation(project(":compose:ui:ui-test-junit4")) 79 implementation(project(":compose:test-utils")) 80 implementation(libs.testRules) 81 implementation(libs.testRunner) 82 implementation(libs.junit) 83 implementation(libs.truth) 84 implementation("androidx.fragment:fragment:1.3.0") 85 implementation("androidx.appcompat:appcompat:1.3.0") 86 // old version of common-java8 conflicts with newer version, because both have 87 // DefaultLifecycleEventObserver. 88 // Outside of androidx this is resolved via constraint added to lifecycle-common, 89 // but it doesn't work in androidx. 90 // See aosp/1804059 91 implementation(project(":lifecycle:lifecycle-common-java8")) 92 implementation("androidx.activity:activity-compose:1.10.1") 93 } 94 } 95 96 nonAndroidMain { 97 dependsOn(commonMain) 98 } 99 100 jvmStubsMain { 101 dependsOn(nonAndroidMain) 102 } 103 104 linuxx64StubsMain { 105 dependsOn(nonAndroidMain) 106 } 107 } 108} 109 110dependencies { 111 lintPublish(project(":lifecycle:lifecycle-viewmodel-compose-lint")) 112} 113 114androidx { 115 name = "Lifecycle ViewModel Compose" 116 type = SoftwareType.PUBLISHED_LIBRARY_ONLY_USED_BY_KOTLIN_CONSUMERS 117 inceptionYear = "2021" 118 description = "Compose integration with Lifecycle ViewModel" 119 samples(project(":lifecycle:lifecycle-viewmodel-compose:lifecycle-viewmodel-compose-samples")) 120} 121 122android { 123 compileSdk = 35 124 namespace = "androidx.lifecycle.viewmodel.compose" 125} 126