blob: 1bc8f7ce390b39f10c3c0b83e3ce77a92d71f8ca [file] [log] [blame]
/**
* 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.KmpPlatformsKt
import androidx.build.PlatformIdentifier
import androidx.build.Publish
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.konan.target.Family
plugins {
id("AndroidXPlugin")
id("com.android.library")
}
def macEnabled = KmpPlatformsKt.enableMac(project)
def linuxEnabled = KmpPlatformsKt.enableLinux(project)
androidXMultiplatform {
android()
desktop()
mac()
linux()
ios()
defaultPlatform(PlatformIdentifier.ANDROID)
sourceSets {
commonMain {
dependencies {
api(libs.kotlinStdlib)
api(project(":lifecycle:lifecycle-common"))
api(project(":annotation:annotation"))
}
}
commonTest {
dependencies {
implementation(libs.kotlinCoroutinesTest)
implementation(libs.kotlinTest)
implementation(project(":kruth:kruth"))
}
}
jvmMain {
dependsOn(commonMain)
dependencies {
api("androidx.arch.core:core-common:2.2.0")
}
}
desktopMain {
dependsOn(jvmMain)
}
androidMain {
dependsOn(jvmMain)
dependencies {
api(libs.kotlinCoroutinesAndroid)
implementation("androidx.arch.core:core-runtime:2.2.0")
implementation("androidx.profileinstaller:profileinstaller:1.3.0")
}
}
androidUnitTest {
dependsOn(commonTest)
dependencies {
implementation(libs.junit)
implementation(libs.mockitoCore4)
}
}
androidInstrumentedTest {
dependsOn(commonTest)
dependencies {
implementation(libs.junit)
implementation(libs.truth)
implementation(libs.testExtJunit)
implementation(libs.testCore)
implementation(libs.testRunner)
implementation(libs.kotlinCoroutinesTest)
}
}
if (macEnabled || linuxEnabled) {
nativeMain {
dependsOn(commonMain)
// Required for WeakReference usage
languageSettings.optIn("kotlin.experimental.ExperimentalNativeApi")
}
nativeTest {
dependsOn(commonTest)
}
}
if (macEnabled) {
darwinMain {
dependsOn(nativeMain)
// Required for WeakReference usage
languageSettings.optIn("kotlin.experimental.ExperimentalNativeApi")
}
}
if (linuxEnabled) {
linuxMain {
dependsOn(nativeMain)
// Required for WeakReference usage
languageSettings.optIn("kotlin.experimental.ExperimentalNativeApi")
}
}
targets.all { target ->
if (target.platformType == KotlinPlatformType.native) {
target.compilations["main"].defaultSourceSet {
def konanTargetFamily = target.konanTarget.family
if (konanTargetFamily == Family.OSX || konanTargetFamily == Family.IOS) {
dependsOn(darwinMain)
} else if (konanTargetFamily == Family.LINUX) {
dependsOn(linuxMain)
} else {
throw new GradleException("unknown native target ${target}")
}
// Required for WeakReference usage
languageSettings.optIn("kotlin.experimental.ExperimentalNativeApi")
}
target.compilations["test"].defaultSourceSet {
dependsOn(nativeTest)
}
}
}
}
}
android {
buildTypes.all {
consumerProguardFiles "proguard-rules.pro"
}
// Include `*.java` files into the build
sourceSets["main"].java.srcDir("src/androidMain/java")
sourceSets["test"].java.srcDir("src/androidUnitTest/kotlin")
namespace "androidx.lifecycle.runtime"
}
androidx {
name = "Lifecycle Runtime"
publish = Publish.SNAPSHOT_AND_RELEASE
inceptionYear "2017"
description "Android Lifecycle Runtime"
metalavaK2UastEnabled = true
}