| /* |
| * 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. |
| */ |
| |
| import androidx.build.KmpPlatformsKt |
| import androidx.build.LibraryType |
| import androidx.build.PlatformIdentifier |
| import androidx.build.Publish |
| import androidx.build.SdkHelperKt |
| import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType |
| import org.jetbrains.kotlin.konan.target.KonanTarget |
| |
| plugins { |
| id("AndroidXPlugin") |
| id("com.android.library") |
| id("androidx.stableaidl") |
| } |
| |
| def nativeEnabled = KmpPlatformsKt.enableNative(project) |
| |
| 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.all { |
| consumerProguardFiles "proguard-rules.pro" |
| stableAidl { |
| version 1 |
| } |
| } |
| namespace "androidx.room" |
| } |
| |
| androidXMultiplatform { |
| mac() |
| linux() |
| ios() { |
| // Link to sqlite3 available in iOS |
| binaries.all { |
| linkerOpts += ["-lsqlite3"] |
| } |
| } |
| android() |
| |
| defaultPlatform(PlatformIdentifier.ANDROID) |
| |
| sourceSets { |
| commonMain { |
| dependencies { |
| api(libs.kotlinStdlib) |
| api(project(":room:room-common")) |
| api(project(":sqlite:sqlite")) |
| api(projectOrArtifact(":annotation:annotation")) |
| } |
| } |
| commonTest { |
| dependencies { |
| implementation(libs.kotlinTest) |
| implementation(project(":kruth:kruth")) |
| } |
| } |
| androidMain { |
| dependsOn(commonMain) |
| dependencies { |
| api(project(":sqlite:sqlite-framework")) |
| 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.1.0-rc01") |
| } |
| } |
| 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(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") |
| } |
| } |
| if (nativeEnabled) { |
| nativeMain { |
| dependsOn(commonMain) |
| dependencies { |
| api(project(":sqlite:sqlite-framework")) |
| } |
| } |
| nativeTest { |
| dependsOn(commonTest) |
| } |
| } |
| targets.all { target -> |
| if (target.platformType == KotlinPlatformType.native) { |
| target.compilations["main"].defaultSourceSet { |
| dependsOn(nativeMain) |
| } |
| def test = target.compilations["test"] |
| test.defaultSourceSet { |
| dependsOn(nativeTest) |
| } |
| if (target.konanTarget == KonanTarget.LINUX_X64.INSTANCE) { |
| // 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 == KonanTarget.MACOS_X64.INSTANCE || |
| target.konanTarget == KonanTarget.MACOS_ARM64.INSTANCE |
| ) { |
| // 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")) |
| } |
| |
| androidx { |
| name = "Room-Runtime" |
| type = LibraryType.PUBLISHED_LIBRARY |
| publish = Publish.SNAPSHOT_AND_RELEASE |
| inceptionYear = "2017" |
| description = "Android Room-Runtime" |
| metalavaK2UastEnabled = true |
| } |