blob: 57876b2886a110b7828fa5c6e1a18c24aa8defb9 [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.
*/
/**
* This file was created using the `create_project.py` script located in the
* `<AndroidX root>/development/project-creator` directory.
*
* Please use that script when creating a new project, rather than copying an existing project and
* modifying its settings.
*/
import androidx.build.LibraryType
import androidx.build.PlatformIdentifier
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
plugins {
id("AndroidXPlugin")
id("com.android.library")
id("com.google.protobuf")
id ("kotlin-parcelize")
}
android {
externalNativeBuild {
cmake {
path "src/androidMain/cpp/CMakeLists.txt"
version libs.versions.cmake.get()
}
}
namespace "androidx.datastore.core"
}
protobuf {
protoc {
artifact = libs.protobufCompiler.get()
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option "lite"
}
}
}
}
}
def protoDir = project.layout.projectDirectory.dir("src/androidInstrumentedTest/proto")
tasks.named("extractAndroidTestProto").configure {
it.inputFiles.from(project.files(protoDir))
}
androidXMultiplatform {
enableBinaryCompatibilityValidator = true
jvm()
mac()
linux()
ios()
android()
defaultPlatform(PlatformIdentifier.ANDROID)
sourceSets {
configureEach {
languageSettings.optIn("kotlin.RequiresOptIn")
}
commonMain {
dependencies {
api(libs.kotlinStdlib)
api(libs.kotlinCoroutinesCore)
api("androidx.annotation:annotation:1.7.0")
}
}
commonJvmMain {
dependsOn(commonMain)
}
androidMain {
dependsOn(commonJvmMain)
}
jvmMain {
dependsOn(commonJvmMain)
}
commonTest {
dependencies {
implementation(libs.kotlinTestCommon)
implementation(libs.kotlinTestAnnotationsCommon)
implementation(libs.kotlinCoroutinesTest)
implementation(libs.okio)
implementation(project(":datastore:datastore-core-okio"))
implementation(project(":kruth:kruth"))
implementation(project(":internal-testutils-datastore"))
}
}
commonJvmTest {
dependsOn(commonTest)
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)
}
}
jvmTest {
dependsOn(commonJvmTest)
}
androidUnitTest {
dependsOn(commonJvmTest)
dependencies {
implementation(libs.protobufLite)
}
}
androidInstrumentedTest {
dependsOn(commonJvmTest)
dependencies {
implementation(libs.protobufLite)
implementation(libs.truth)
implementation(project(":internal-testutils-truth"))
implementation(libs.testRunner)
implementation(libs.testCore)
implementation("androidx.lifecycle:lifecycle-service:2.6.1")
// Workaround bug in 1.8.0, was supposed be fixed in RC2/final, but apparently not.
implementation(libs.kotlinTestJunit)
}
}
nativeMain {
dependsOn(commonMain)
dependencies {
implementation(libs.atomicFu)
}
}
nativeTest {
dependsOn(commonTest)
}
targets.configureEach { 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
}