1/*
2 * Copyright (C) 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
27import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
28
29plugins {
30    id("AndroidXPlugin")
31    alias(libs.plugins.kotlinSerialization)
32}
33
34androidXMultiplatform {
35    jvm()
36    mac()
37    linux()
38    ios()
39    watchos()
40    tvos()
41    androidLibrary {
42        namespace = "androidx.datastore.preferences.core"
43        optimization {
44            it.consumerKeepRules.publish = true
45            it.consumerKeepRules.files.add(
46                    new File("src/jvmMain/resources/META-INF/proguard/androidx.datastore_datastore-preferences-core.pro")
47            )
48        }
49        experimentalProperties["android.lint.useK2Uast"] = false
50    }
51
52    defaultPlatform(PlatformIdentifier.JVM)
53
54    sourceSets {
55        configureEach {
56            languageSettings.optIn("kotlin.RequiresOptIn")
57        }
58
59        commonMain {
60            dependencies {
61                api(libs.kotlinStdlib)
62                api(libs.okio)
63                api(project(":datastore:datastore-core"))
64                api(project(":datastore:datastore-core-okio"))
65            }
66        }
67        commonTest {
68            dependencies {
69                implementation(libs.kotlinTestCommon)
70                implementation(libs.kotlinTest)
71                implementation(libs.kotlinTestAnnotationsCommon)
72                implementation(libs.kotlinCoroutinesTest)
73                implementation(project(":datastore:datastore-core"))
74                implementation(project(":kruth:kruth"))
75                implementation(project(":internal-testutils-datastore"))
76            }
77        }
78        jvmAndroidMain {
79            dependsOn(commonMain)
80            dependencies {
81                implementation(project(":datastore:datastore-preferences-proto"))
82            }
83        }
84        jvmMain {
85            dependsOn(jvmAndroidMain)
86        }
87        androidMain {
88            dependsOn(jvmAndroidMain)
89        }
90        jvmAndroidTest {
91            dependsOn(commonTest)
92            dependencies {
93                implementation(libs.junit)
94            }
95        }
96        nativeMain {
97            dependsOn(commonMain)
98            dependencies {
99                implementation(libs.kotlinSerializationCore)
100                implementation(libs.kotlinSerializationProtobuf)
101            }
102        }
103        jvmTest {
104            dependsOn(jvmAndroidTest)
105        }
106        nativeTest {
107            dependsOn(commonTest)
108            dependencies {
109                implementation(libs.kotlinTest)
110                implementation(project(":internal-testutils-datastore"))
111                implementation(project(":kruth:kruth"))
112            }
113        }
114
115        targets.configureEach { target ->
116            if (target.platformType == KotlinPlatformType.native) {
117                target.compilations["main"].defaultSourceSet {
118                    dependsOn(nativeMain)
119                }
120                target.compilations["test"].defaultSourceSet {
121                    dependsOn(nativeTest)
122                }
123            }
124        }
125    }
126}
127
128androidx {
129    name = "Preferences DataStore Core"
130    type = SoftwareType.PUBLISHED_LIBRARY
131    inceptionYear = "2020"
132    description = "Android Preferences DataStore without the Android Dependencies"
133    legacyDisableKotlinStrictApiMode = true
134    metalavaK2UastEnabled = false
135}
136