1/**
2 * This file was created using the `create_project.py` script located in the
3 * `<AndroidX root>/development/project-creator` directory.
4 *
5 * Please use that script when creating a new project, rather than copying an existing project and
6 * modifying its settings.
7 */
8
9import androidx.build.SoftwareType
10import androidx.build.PlatformIdentifier
11import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
12
13plugins {
14    id("AndroidXPlugin")
15    id("com.android.library")
16    id("androidx.baselineprofile")
17}
18androidXMultiplatform {
19    androidTarget()
20    desktop()
21    mac()
22    linux()
23    ios()
24
25    defaultPlatform(PlatformIdentifier.ANDROID)
26
27    sourceSets {
28        commonMain {
29            dependencies {
30                api(libs.kotlinStdlib)
31                api(project(":lifecycle:lifecycle-common"))
32                api("androidx.annotation:annotation:1.8.1")
33            }
34        }
35
36        commonTest {
37            dependencies {
38                implementation(project(":internal-testutils-lifecycle"))
39                implementation(libs.kotlinCoroutinesTest)
40                implementation(libs.kotlinTest)
41                implementation(project(":kruth:kruth"))
42                implementation(libs.atomicFu)
43            }
44        }
45
46        jvmCommonMain {
47            dependsOn(commonMain)
48            dependencies {
49                api("androidx.arch.core:core-common:2.2.0")
50            }
51        }
52
53        desktopMain {
54            dependsOn(jvmCommonMain)
55        }
56
57        desktopTest {
58            dependsOn(commonTest)
59            dependencies {
60                implementation(libs.kotlinCoroutinesSwing)
61            }
62        }
63
64        androidMain {
65            dependsOn(jvmCommonMain)
66            dependencies {
67                api(libs.kotlinCoroutinesAndroid)
68                implementation("androidx.core:core-viewtree:1.0.0")
69                implementation("androidx.arch.core:core-runtime:2.2.0")
70                implementation("androidx.profileinstaller:profileinstaller:1.4.0")
71            }
72        }
73
74        androidUnitTest {
75            dependsOn(commonTest)
76            dependencies {
77                implementation(libs.junit)
78                implementation(libs.mockitoCore4)
79            }
80        }
81
82        androidInstrumentedTest {
83            dependsOn(commonTest)
84            dependencies {
85                implementation("androidx.core:core-viewtree:1.0.0")
86                implementation(libs.junit)
87                implementation(libs.truth)
88                implementation(libs.testExtJunit)
89                implementation(libs.testCore)
90                implementation(libs.testRunner)
91                implementation(libs.kotlinCoroutinesTest)
92            }
93        }
94
95        nonJvmCommonMain {
96            dependsOn(commonMain)
97        }
98
99        nativeMain {
100            dependsOn(nonJvmCommonMain)
101
102            // Required for WeakReference usage
103            languageSettings.optIn("kotlin.experimental.ExperimentalNativeApi")
104        }
105
106        nativeTest {
107            dependsOn(commonTest)
108        }
109
110        targets.configureEach { target ->
111            if (target.platformType == KotlinPlatformType.native) {
112                target.compilations["main"].defaultSourceSet {
113                    dependsOn(nativeMain)
114
115                    // Required for WeakReference usage
116                    languageSettings.optIn("kotlin.experimental.ExperimentalNativeApi")
117                }
118                target.compilations["test"].defaultSourceSet {
119                    dependsOn(nativeTest)
120                }
121            }
122        }
123    }
124}
125
126dependencies {
127    api(libs.jspecify)
128    lintPublish(project(":lifecycle:lifecycle-runtime-lint"))
129}
130
131android {
132    buildTypes.configureEach {
133        consumerProguardFiles "proguard-rules.pro"
134    }
135
136    // Include `*.java` files into the build
137    sourceSets["main"].java.srcDir("src/androidMain/java")
138    sourceSets["test"].java.srcDir("src/androidUnitTest/kotlin")
139    namespace = "androidx.lifecycle.runtime"
140    // TODO(b/345531033)
141    experimentalProperties["android.lint.useK2Uast"] = false
142}
143
144androidx {
145    name = "Lifecycle Runtime"
146    type = SoftwareType.PUBLISHED_LIBRARY
147    inceptionYear = "2017"
148    description = "Android Lifecycle Runtime"
149}
150