| /* |
| * Copyright (C) 2020 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| import androidx.build.BundleInsideHelper |
| import androidx.build.KmpPlatformsKt |
| import androidx.build.LibraryType |
| import androidx.build.PlatformIdentifier |
| import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType |
| |
| plugins { |
| id("AndroidXPlugin") |
| alias(libs.plugins.kotlinSerialization) |
| } |
| |
| def enableNative = KmpPlatformsKt.enableNative(project) |
| |
| androidXMultiplatform { |
| jvm() { |
| withJava() |
| } |
| mac() |
| linux() |
| ios() |
| // NOTE, if you add android target here, make sure to add the proguard file as well. |
| |
| defaultPlatform(PlatformIdentifier.JVM) |
| |
| sourceSets { |
| all { |
| languageSettings.optIn("kotlin.RequiresOptIn") |
| } |
| |
| commonMain { |
| dependencies { |
| api(libs.kotlinStdlib) |
| api(libs.okio) |
| api(project(":datastore:datastore-core")) |
| api(project(":datastore:datastore-core-okio")) |
| } |
| } |
| commonTest { |
| dependencies { |
| implementation(libs.kotlinTestCommon) |
| implementation(libs.kotlinTestAnnotationsCommon) |
| implementation(libs.kotlinCoroutinesTest) |
| implementation(project(":datastore:datastore-core")) |
| implementation(project(":kruth:kruth")) |
| implementation(project(":internal-testutils-datastore")) |
| } |
| } |
| jvmMain { |
| dependsOn(commonMain) |
| } |
| jvmTest { |
| dependsOn(commonTest) |
| dependencies { |
| implementation(libs.junit) |
| implementation(libs.kotlinTest) |
| implementation(project(":internal-testutils-datastore")) |
| implementation(project(":kruth:kruth")) |
| } |
| } |
| if (enableNative) { |
| nativeMain { |
| dependsOn(commonMain) |
| dependencies { |
| implementation(libs.kotlinSerializationCore) |
| implementation(libs.kotlinSerializationProtobuf) |
| } |
| } |
| |
| nativeTest { |
| dependsOn(commonTest) |
| dependencies { |
| implementation(libs.kotlinTest) |
| implementation(project(":internal-testutils-datastore")) |
| implementation(project(":kruth:kruth")) |
| } |
| } |
| } |
| |
| targets.all { target -> |
| if (target.platformType == KotlinPlatformType.native) { |
| target.compilations["main"].defaultSourceSet { |
| dependsOn(nativeMain) |
| } |
| target.compilations["test"].defaultSourceSet { |
| dependsOn(nativeTest) |
| } |
| } |
| } |
| } |
| } |
| |
| BundleInsideHelper.forInsideJarKmp( |
| project, |
| /* from = */ "com.google.protobuf", |
| /* to = */ "androidx.datastore.preferences.protobuf", |
| // proto-lite dependency includes .proto files, which are not used and would clash if |
| // users also use proto library directly |
| /* dropResourcesWithSuffix = */ ".proto" |
| ) |
| |
| dependencies { |
| bundleInside(project(":datastore:datastore-preferences-proto")) |
| } |
| |
| androidx { |
| name = "Preferences DataStore Core" |
| type = LibraryType.PUBLISHED_LIBRARY |
| inceptionYear = "2020" |
| description = "Android Preferences DataStore without the Android Dependencies" |
| legacyDisableKotlinStrictApiMode = true |
| } |