import dependencies.Dep

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

apply from: rootProject.file('gradle/android.gradle')
android.libraryVariants.all {
    // TODO replace with https://issuetracker.google.com/issues/72050365 once released.
    it.generateBuildConfig.enabled = true
}

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

        final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
                              ? presets.iosArm64 : presets.iosX64

        fromPreset(iOSTarget, 'iOS') {
            compilations.main.outputKinds('FRAMEWORK')
        }
    }
    sourceSets {
        commonMain.dependencies {
            api project(":model")
            api project(":data:device")
            implementation Dep.Kotlin.stdlibCommon
            implementation Dep.Ktor.clientCommon
            implementation Dep.Timber.common
        }
        androidMain {
            dependsOn commonMain
            dependencies {
                implementation Dep.Kotlin.stdlibJvm
                implementation Dep.Dagger.core
                implementation Dep.Dagger.androidSupport
                implementation Dep.Timber.android
            }
        }
        androidTest {
            dependsOn androidMain
            dependencies {
                implementation Dep.Test.junit
                implementation Dep.Test.slf4j
            }
        }
        iOSMain {
            dependsOn commonMain
            dependencies {
            }
        }
    }
}

dependencies {
    api project(":model")
    api project(":data:device")
    kapt Dep.Dagger.compiler
    kapt Dep.Dagger.androidProcessor
}

configurations {
    compileClasspath
}

