1/*
2 * Copyright 2018 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.PlatformIdentifier
26import androidx.build.SoftwareType
27
28plugins {
29    id("AndroidXPlugin")
30    alias(libs.plugins.kotlinSerialization)
31}
32
33androidXMultiplatform {
34    androidLibrary {
35        namespace = "androidx.navigation.testing"
36        experimentalProperties["android.experimental.kmp.enableAndroidResources"] = true
37
38        withAndroidTestOnDeviceBuilder {
39            it.compilationName = "instrumentedTest"
40            it.defaultSourceSetName = "androidInstrumentedTest"
41            it.sourceSetTreeName = "test"
42        }
43        withAndroidTestOnJvmBuilder {
44            it.compilationName = "unitTest"
45            it.defaultSourceSetName = "androidUnitTest"
46        }
47    }
48    desktop()
49    linux()
50    mac()
51    ios()
52
53    defaultPlatform(PlatformIdentifier.ANDROID)
54
55    sourceSets {
56        configureEach {
57            languageSettings.optIn("kotlin.contracts.ExperimentalContracts")
58        }
59
60        commonMain {
61            dependencies {
62                api(project(":navigation:navigation-runtime"))
63                api(project(":lifecycle:lifecycle-runtime-testing"))
64
65                implementation(libs.kotlinCoroutinesCore)
66                implementation(libs.kotlinSerializationCore)
67                implementation(project(":navigation:navigation-common"))
68                implementation(project(":lifecycle:lifecycle-common"))
69                implementation(project(":lifecycle:lifecycle-viewmodel"))
70                implementation(project(":lifecycle:lifecycle-viewmodel-savedstate"))
71            }
72        }
73
74        commonTest {
75            dependencies {
76                implementation(project(":kruth:kruth"))
77            }
78        }
79
80        nonAndroidMain {
81            dependsOn(commonMain)
82        }
83
84        nonAndroidTest {
85            dependsOn(commonTest)
86        }
87
88        jvmCommonMain {
89            dependsOn(commonMain)
90        }
91
92        jvmCommonTest {
93            dependsOn(commonTest)
94            dependencies {
95                runtimeOnly(libs.kotlinTestJunit)
96                implementation(libs.junit)
97            }
98        }
99
100        desktopMain {
101            dependsOn(jvmCommonMain)
102            dependsOn(nonAndroidMain)
103        }
104
105        desktopTest {
106            dependsOn(jvmCommonTest)
107            dependsOn(nonAndroidTest)
108        }
109
110        androidMain {
111            dependsOn(commonMain)
112            dependencies {
113                api(project(":lifecycle:lifecycle-runtime"))
114                api(project(":lifecycle:lifecycle-viewmodel"))
115                api(project(":savedstate:savedstate-ktx"))
116                implementation("androidx.core:core-ktx:1.1.0")
117                implementation("androidx.profileinstaller:profileinstaller:1.4.0")
118            }
119        }
120
121        androidUnitTest {
122            dependsOn(commonTest)
123            dependencies {
124                implementation(libs.robolectric)
125
126                runtimeOnly(libs.testCore)
127                runtimeOnly(libs.kotlinTestJunit)
128                implementation(libs.junit)
129                implementation(libs.testRunner)
130            }
131        }
132
133        androidInstrumentedTest {
134            dependsOn(commonTest)
135            dependencies {
136                implementation(project(":internal-testutils-navigation"))
137                implementation("androidx.lifecycle:lifecycle-runtime:2.6.2")
138                implementation(libs.testExtJunit)
139                implementation(libs.testExtTruth)
140                implementation(libs.testRules)
141
142                runtimeOnly(libs.testCore)
143                runtimeOnly(libs.kotlinTestJunit)
144                implementation(libs.junit)
145                implementation(libs.testRunner)
146            }
147        }
148
149        nativeMain { dependsOn(commonMain) }
150        linuxMain { dependsOn(nativeMain) }
151        darwinMain { dependsOn(nativeMain) }
152
153        nativeTest { dependsOn(commonTest) }
154        linuxTest { dependsOn(nativeTest) }
155        darwinTest { dependsOn(nativeTest) }
156
157        targets.configureEach { target ->
158            if (target.platformType == org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.native) {
159                if (target.konanTarget.family.appleFamily) {
160                    target.compilations["main"].defaultSourceSet.dependsOn(darwinMain)
161                    target.compilations["test"].defaultSourceSet.dependsOn(darwinTest)
162                } else if (target.konanTarget.family == org.jetbrains.kotlin.konan.target.Family.LINUX) {
163                    target.compilations["main"].defaultSourceSet.dependsOn(linuxMain)
164                    target.compilations["test"].defaultSourceSet.dependsOn(linuxTest)
165                }
166            }
167        }
168    }
169}
170
171androidx {
172    name = "Navigation Testing"
173    type = SoftwareType.PUBLISHED_LIBRARY
174    inceptionYear = "2017"
175    description = "Android Navigation-Testing"
176}
177