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 id("com.android.library") 32} 33 34android { 35 externalNativeBuild { 36 cmake { 37 path "src/androidMain/cpp/CMakeLists.txt" 38 version = libs.versions.cmake.get() 39 } 40 } 41 namespace = "androidx.datastore.core" 42} 43 44androidXMultiplatform { 45 jvm() 46 mac() 47 linux() 48 ios() 49 watchos() 50 tvos() 51 androidTarget() 52 53 defaultPlatform(PlatformIdentifier.ANDROID) 54 55 sourceSets { 56 configureEach { 57 languageSettings.optIn("kotlin.RequiresOptIn") 58 } 59 60 commonMain { 61 dependencies { 62 api(libs.kotlinStdlib) 63 api(libs.kotlinCoroutinesCore) 64 api("androidx.annotation:annotation:1.9.1") 65 } 66 } 67 68 jvmAndroidMain { 69 dependsOn(commonMain) 70 } 71 72 androidMain { 73 dependsOn(jvmAndroidMain) 74 } 75 76 jvmMain { 77 dependsOn(jvmAndroidMain) 78 } 79 80 commonTest { 81 dependencies { 82 implementation(libs.kotlinTestCommon) 83 implementation(libs.kotlinTestAnnotationsCommon) 84 implementation(libs.kotlinCoroutinesTest) 85 implementation(libs.okio) 86 implementation(project(":datastore:datastore-core-okio")) 87 implementation(project(":kruth:kruth")) 88 implementation(project(":internal-testutils-datastore")) 89 } 90 } 91 92 jvmAndroidTest { 93 dependsOn(commonTest) 94 dependencies { 95 implementation(libs.junit) 96 implementation(libs.kotlinTest) 97 implementation(project(":kruth:kruth")) 98 implementation(project(":internal-testutils-datastore")) 99 100 // Workaround bug in 1.8.0, was supposed be fixed in RC2/final, but apparently not. 101 implementation(libs.kotlinTestJunit) 102 } 103 } 104 105 jvmTest { 106 dependsOn(jvmAndroidTest) 107 } 108 109 androidUnitTest { 110 dependsOn(jvmAndroidTest) 111 dependencies { 112 implementation(libs.protobufLite) 113 } 114 } 115 116 androidInstrumentedTest { 117 dependsOn(jvmAndroidTest) 118 dependencies { 119 implementation(libs.truth) 120 implementation(project(":internal-testutils-truth")) 121 implementation(libs.testRunner) 122 implementation(libs.testCore) 123 implementation("androidx.lifecycle:lifecycle-service:2.6.1") 124 125 // Workaround bug in 1.8.0, was supposed be fixed in RC2/final, but apparently not. 126 implementation(libs.kotlinTestJunit) 127 } 128 } 129 130 nativeMain { 131 dependsOn(commonMain) 132 dependencies { 133 implementation(libs.atomicFu) 134 } 135 } 136 nativeTest { 137 dependsOn(commonTest) 138 } 139 140 targets.configureEach { target -> 141 if (target.platformType == KotlinPlatformType.native) { 142 target.compilations["main"].defaultSourceSet { 143 dependsOn(nativeMain) 144 } 145 target.compilations["test"].defaultSourceSet { 146 dependsOn(nativeTest) 147 } 148 } 149 } 150 } 151} 152 153androidx { 154 name = "DataStore Core" 155 type = SoftwareType.PUBLISHED_LIBRARY 156 inceptionYear = "2020" 157 description = "Android DataStore Core - contains the underlying store used by each serialization method" 158 legacyDisableKotlinStrictApiMode = true 159 metalavaK2UastEnabled = false 160} 161