blob: 4e32d8eb7660851851e9fe2a83de33cc72932b27 [file] [edit]
/*
* Copyright (C) 2016 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 `createProject` gradle task (./gradlew createProject)
*
* Please use the task when creating a new project, rather than copying an existing project and
* modifying its settings.
*/
import androidx.build.KotlinTarget
import androidx.build.SoftwareType
import androidx.build.PlatformIdentifier
import com.android.build.api.dsl.KotlinMultiplatformAndroidHostTestCompilation
import com.android.build.gradle.internal.lint.AndroidLintAnalysisTask
import com.android.build.gradle.internal.lint.LintModelWriterTask
import com.google.devtools.ksp.gradle.KspAATask
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.konan.target.Family
plugins {
id("AndroidXPlugin")
id("androidx.stableaidl")
id("com.google.devtools.ksp")
}
configurations {
// Configuration for resolving shared archive file of androidx's SQLite compilation
sqliteSharedArchive {
canBeConsumed = false
canBeResolved = true
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.NATIVE_LINK))
}
}
}
androidXMultiplatform {
androidLibrary {
withJava()
namespace = "androidx.room3"
optimization {
it.consumerKeepRules.publish = true
it.consumerKeepRules.files.add(
new File(project.projectDir, "src/androidMain/proguard-rules.pro")
)
}
stableAidl {
version = 1
}
compilations.withType(KotlinMultiplatformAndroidHostTestCompilation) {
it.returnDefaultValues = true
}
}
ios() {
// Link to sqlite3 available in iOS
binaries.configureEach {
linkerOpts += ["-lsqlite3"]
}
}
js()
jvm()
linux()
mac()
tvos()
wasmJs()
watchos()
defaultPlatform(PlatformIdentifier.ANDROID)
sourceSets {
commonMain {
dependencies {
api(project(":room3:room3-common"))
api(project(":sqlite:sqlite"))
api("androidx.collection:collection:1.5.0")
api("androidx.annotation:annotation:1.9.1")
api(libs.kotlinCoroutinesCore)
}
}
commonTest {
dependencies {
implementation(libs.kotlinTest)
implementation(libs.kotlinCoroutinesTest)
implementation(project(":kruth:kruth"))
}
}
nonWebMain {
dependsOn(commonMain)
}
nonWebTest {
dependsOn(commonTest)
}
jvmNativeWebMain {
dependsOn(commonMain)
}
jvmMain {
dependsOn(jvmNativeWebMain)
}
jvmTest {
dependencies {
implementation(project(":sqlite:sqlite-bundled"))
implementation(libs.kotlinTestJunit)
}
}
jvmAndAndroidMain {
dependsOn(nonWebMain)
}
jvmAndAndroidTest {
dependsOn(nonWebTest)
}
androidMain {
kotlin.srcDirs += "src/androidMain/java"
dependencies {
api(libs.jspecify)
api(project(":sqlite:sqlite-framework"))
api(libs.kotlinCoroutinesAndroid)
implementation("androidx.annotation:annotation-experimental:1.5.0")
}
}
androidHostTest {
dependencies {
implementation("androidx.arch.core:core-testing:2.2.0")
implementation(libs.junit)
implementation(libs.byteBuddy)
implementation(libs.mockitoCore4)
implementation(libs.mockitoKotlin4)
implementation(libs.testRunner) // Needed for @FlakyTest and @Ignore
}
}
androidDeviceTest {
dependencies {
implementation(project(":sqlite:sqlite-bundled"))
implementation(libs.junit)
implementation(libs.testExtJunit)
implementation(libs.testCore)
implementation(libs.testRunner)
implementation(libs.espressoCore)
implementation(libs.mockitoCore)
implementation(libs.dexmakerMockito)
implementation(project(":internal-testutils-truth")) // for assertThrows
implementation(project(":kruth:kruth"))
implementation("androidx.arch.core:core-testing:2.2.0")
}
}
nativeMain {
dependsOn(nonWebMain)
dependsOn(jvmNativeWebMain)
dependencies {
api(project(":sqlite:sqlite-framework"))
implementation(libs.atomicFu)
}
}
nativeTest {
dependsOn(nonWebTest)
dependencies {
implementation(project(":sqlite:sqlite-bundled"))
implementation(libs.okio)
}
}
targets.configureEach { target ->
if (target.platformType == KotlinPlatformType.native) {
def test = target.compilations["test"]
if (target.konanTarget.family == Family.LINUX) {
// For tests in Linux host, statically include androidx's compiled SQLite
// via a generated C interop definition
createCinteropFromArchiveConfiguration(test, configurations["sqliteSharedArchive"])
} else if (target.konanTarget.family == Family.OSX) {
// For tests in Mac host, link to shared SQLite library included in MacOS
test.kotlinOptions.freeCompilerArgs += [
"-linker-options", "-lsqlite3"
]
}
}
}
webMain {
dependsOn(jvmNativeWebMain)
}
}
}
dependencies {
sqliteSharedArchive(project(":sqlite:sqlite-bundled"))
add("kspAndroidDeviceTest", project(":room3:room3-compiler"))
}
androidx {
name = "Room-Runtime"
type = SoftwareType.PUBLISHED_LIBRARY
inceptionYear = "2017"
description = "Android Room-Runtime"
kotlinTarget = KotlinTarget.KOTLIN_2_1
}
// TODO(b/430983364): Workaround KSP incremental issue
tasks.withType(KotlinCompile).configureEach {
incremental = false
}
tasks.withType(KspAATask).configureEach {
it.kspConfig.incremental.set(false)
}
// b/446711395
// IDE Sync only error:
// Reason: Task ':sqlite:sqlite-framework:linuxArm64TestCinterop-sqliteSharedArchiveKlib' uses this output of task ':sqlite:sqlite-framework:cinteropTestSqliteSharedArchiveLinuxArm64'
// without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
tasks.withType(Zip).configureEach {
if (name == "linuxX64TestCinterop-sqliteSharedArchiveKlib") {
mustRunAfter(tasks.named("cinteropTestSqliteSharedArchiveLinuxX64"))
}
if (name == "linuxArm64TestCinterop-sqliteSharedArchiveKlib") {
mustRunAfter(tasks.named("cinteropTestSqliteSharedArchiveLinuxArm64"))
}
}