import dependencies.Dep

apply plugin: 'com.android.library'
apply plugin: 'kotlin-multiplatform'
apply plugin: 'kotlin-kapt'

apply from: rootProject.file('gradle/android.gradle')

android {
    defaultConfig {
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [
                        "room.incremental": "true"
                ]
            }
        }
    }
}

kotlin {
    targets {
        fromPreset(presets.android, 'android')

        def buildForDevice = project.findProperty("device")?.toBoolean() ?: false
        def iosPreset = (buildForDevice) ? presets.iosArm64 : presets.iosX64
        fromPreset(iosPreset, 'ios') {
            binaries {
                framework {
                    // Disable bitcode embedding for the simulator build.
                    if (!buildForDevice) {
                        embedBitcode("disable")
                    }
                }
            }
        }
    }
    sourceSets {
        commonMain.dependencies {
            implementation Dep.Kotlin.stdlibCommon
            implementation project(":model")
            implementation Dep.Kotlin.coroutinesCommon
        }
        androidMain {
            dependsOn commonMain
            dependencies {
                implementation Dep.Kotlin.stdlibJvm
                implementation project(":model")
                implementation Dep.Kotlin.coroutines
                implementation Dep.AndroidX.lifecycleLiveData

                implementation Dep.AndroidX.Room.runtime
                implementation Dep.AndroidX.Room.coroutine
                implementation Dep.Dagger.core
                implementation Dep.Dagger.androidSupport
            }
        }
        commonTest.dependencies {
            implementation Dep.Test.KotlinMultiPlatform.commonModuleTest
            implementation Dep.Test.KotlinMultiPlatform.commonModuleTestAnnotations
            implementation Dep.MockK.common
        }
        androidTest {
            dependsOn commonMain
            dependencies {
                implementation Dep.Test.KotlinMultiPlatform.jvmModuleTest
                implementation Dep.Test.KotlinMultiPlatform.jvmModuleTestJunit
                implementation Dep.MockK.jvm
            }
        }
    }
}

dependencies {
    implementation project(":data:api")
    kapt Dep.AndroidX.Room.compiler
    kapt Dep.Dagger.compiler
    kapt Dep.Dagger.androidProcessor
}

configurations {
    compileClasspath
}
