blob: 9931fbce3af8eae2ed97c904240c16eb99877ba2 [file] [log] [blame]
/*
* 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.KmpPlatformsKt
import androidx.build.LibraryType
import androidx.build.PlatformIdentifier
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
id("AndroidXPlugin")
id("com.android.library")
id("com.google.protobuf")
}
def enableNative = KmpPlatformsKt.enableNative(project)
android {
externalNativeBuild {
cmake {
path "src/androidMain/cpp/CMakeLists.txt"
version libs.versions.cmake.get()
}
}
namespace "androidx.datastore.core"
}
protobuf {
protoc {
artifact = libs.protobufCompiler.get()
}
// Generates the java proto-lite code for the protos in this project. See
// https://github.com/google/protobuf-gradle-plugin#customizing-protobuf-compilation
// for more information.
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option "lite"
}
}
}
}
}
androidXMultiplatform {
jvm()
mac()
linux()
ios()
android()
defaultPlatform(PlatformIdentifier.ANDROID)
sourceSets {
all {
languageSettings.optIn("kotlin.RequiresOptIn")
}
commonMain {
dependencies {
api(libs.kotlinStdlib)
api(libs.kotlinCoroutinesCore)
}
}
jvmMain {
dependencies {
api("androidx.annotation:annotation:1.3.0")
}
}
androidMain {
dependsOn(jvmMain)
}
commonTest {
dependencies {
implementation(libs.kotlinTestCommon)
implementation(libs.kotlinTestAnnotationsCommon)
implementation(libs.kotlinCoroutinesTest)
implementation(libs.okio)
api(project(":datastore:datastore-core-okio"))
implementation(project(":kruth:kruth"))
implementation(project(":internal-testutils-datastore"))
}
}
jvmTest {
dependencies {
implementation(libs.junit)
implementation(libs.kotlinTest)
implementation(project(":kruth:kruth"))
implementation(project(":internal-testutils-datastore"))
// Workaround bug in 1.8.0, was supposed be fixed in RC2/final, but apparently not.
implementation(libs.kotlinTestJunit)
}
}
androidTest {
dependsOn(jvmTest)
dependencies {
implementation(libs.protobufLite)
implementation(libs.truth)
implementation(project(":internal-testutils-truth"))
implementation(libs.testRunner)
implementation(libs.testCore)
// Workaround bug in 1.8.0, was supposed be fixed in RC2/final, but apparently not.
implementation(libs.kotlinTestJunit)
}
}
androidAndroidTest {
dependsOn(androidTest)
}
if (enableNative) {
nativeMain {
dependsOn(commonMain)
dependencies {
implementation(libs.atomicFu)
}
}
nativeTest {
dependsOn(commonTest)
}
}
targets.all { target ->
if (target.platformType == KotlinPlatformType.native) {
target.compilations["main"].defaultSourceSet {
dependsOn(nativeMain)
}
target.compilations["test"].defaultSourceSet {
dependsOn(nativeTest)
}
}
}
}
}
androidx {
name = "DataStore Core"
type = LibraryType.PUBLISHED_LIBRARY
inceptionYear = "2020"
description = "Android DataStore Core - contains the underlying store used by each serialization method"
legacyDisableKotlinStrictApiMode = true
}