| /* |
| * 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 `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 |
| import org.jetbrains.kotlin.konan.target.Family |
| |
| plugins { |
| id("AndroidXPlugin") |
| id("com.android.library") |
| 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)) |
| } |
| } |
| } |
| |
| android { |
| sourceSets { |
| main { |
| // Align AGP main source set root with KMP |
| root = 'src/androidMain' |
| } |
| } |
| defaultConfig { |
| multiDexEnabled true |
| } |
| buildFeatures { |
| aidl = true |
| } |
| buildTypes.configureEach { |
| consumerProguardFiles "proguard-rules.pro" |
| stableAidl { |
| version 1 |
| } |
| } |
| namespace "androidx.room" |
| } |
| |
| androidXMultiplatform { |
| enableBinaryCompatibilityValidator = true |
| |
| android() |
| ios() { |
| // Link to sqlite3 available in iOS |
| binaries.configureEach { |
| linkerOpts += ["-lsqlite3"] |
| } |
| } |
| jvm() |
| linux() |
| mac() |
| |
| defaultPlatform(PlatformIdentifier.ANDROID) |
| |
| // Source set structure: |
| // ┌──────────────────┐ |
| // │ commonMain │ |
| // └──────────────────┘ |
| // │ |
| // ┌──────────────┴─────────────┐ |
| // │ │ |
| // ▼ ▼ |
| // ┌──────────────────┐ ┌──────────────────┐ |
| // │ jvmAndroidMain │ │ jvmNativeMain │ |
| // └──────────────────┘ └──────────────────┘ |
| // │ │ |
| // ┌───────────┴──────────────┬─────────────┴───────────┐ |
| // │ │ │ |
| // ▼ ▼ ▼ |
| // ┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐ |
| // │ androidMain │ │ jvmMain │ │ nativeMain │ |
| // └──────────────────┘ └──────────────────┘ └──────────────────┘ |
| sourceSets { |
| commonMain { |
| dependencies { |
| api(libs.kotlinStdlib) |
| api(project(":room:room-common")) |
| api(project(":sqlite:sqlite")) |
| api("androidx.annotation:annotation:1.8.0") |
| api(libs.kotlinCoroutinesCore) |
| implementation(libs.atomicFu) |
| } |
| } |
| commonTest { |
| dependencies { |
| implementation(libs.kotlinTest) |
| implementation(libs.kotlinCoroutinesTest) |
| implementation(project(":kruth:kruth")) |
| } |
| } |
| jvmAndroidMain { |
| dependsOn(commonMain) |
| } |
| jvmNativeMain { |
| dependsOn(commonMain) |
| } |
| jvmMain { |
| dependsOn(jvmAndroidMain) |
| dependsOn(jvmNativeMain) |
| } |
| jvmTest { |
| dependsOn(commonTest) |
| dependencies { |
| implementation(project(":sqlite:sqlite-bundled")) |
| implementation(libs.kotlinTestJunit) |
| } |
| } |
| androidMain { |
| dependsOn(jvmAndroidMain) |
| dependencies { |
| api(project(":sqlite:sqlite-framework")) |
| api(libs.kotlinCoroutinesAndroid) |
| implementation("androidx.arch.core:core-runtime:2.2.0") |
| compileOnly("androidx.collection:collection:1.2.0") |
| compileOnly("androidx.lifecycle:lifecycle-livedata-core:2.0.0") |
| compileOnly("androidx.paging:paging-common:2.0.0") |
| implementation("androidx.annotation:annotation-experimental:1.4.1") |
| } |
| } |
| androidUnitTest { |
| dependsOn(commonTest) |
| dependencies { |
| implementation("androidx.arch.core:core-testing:2.2.0") |
| implementation(libs.junit) |
| implementation(libs.byteBuddy) |
| implementation(libs.mockitoCore4) |
| implementation(libs.mockitoKotlin4) |
| implementation("androidx.lifecycle:lifecycle-livedata-core:2.0.0") |
| implementation(libs.testRunner) // Needed for @FlakyTest and @Ignore |
| } |
| } |
| androidInstrumentedTest { |
| dependsOn(commonTest) |
| 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(jvmNativeMain) |
| dependencies { |
| api(project(":sqlite:sqlite-framework")) |
| } |
| } |
| nativeTest { |
| dependsOn(commonTest) |
| dependencies { |
| implementation(project(":sqlite:sqlite-bundled")) |
| implementation(libs.okio) |
| } |
| } |
| targets.configureEach { target -> |
| if (target.platformType == KotlinPlatformType.native) { |
| target.compilations["main"].defaultSourceSet { |
| dependsOn(nativeMain) |
| } |
| def test = target.compilations["test"] |
| test.defaultSourceSet { |
| dependsOn(nativeTest) |
| } |
| 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" |
| ] |
| } |
| } |
| } |
| } |
| } |
| |
| dependencies { |
| lintChecks(project(":room:room-runtime-lint")) |
| sqliteSharedArchive(project(":sqlite:sqlite-bundled")) |
| add("kspAndroidAndroidTest", project(":room:room-compiler")) |
| } |
| |
| androidx { |
| name = "Room-Runtime" |
| type = LibraryType.PUBLISHED_LIBRARY |
| inceptionYear = "2017" |
| description = "Android Room-Runtime" |
| } |