import dependencies.Dep

def ideaActive = System.getProperty("idea.active") == "true"

apply plugin: 'com.android.library'
apply plugin: 'kotlin-multiplatform'
apply plugin: 'kotlinx-serialization'
apply plugin: 'kotlin-android-extensions'

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

androidExtensions {
    experimental = true
    features = ["parcelize"]
}
kotlin {
    jvm()
    android("android")
    iosArm64("iosArm64") {
        binaries {
            framework {
                freeCompilerArgs += "-Xobjc-generics"
            }
        }
    }
    iosX64("iosX64") {
        binaries {
            framework {
                freeCompilerArgs += "-Xobjc-generics"
            }
        }
    }
    if (ideaActive) {
        iosX64("ios") {
            binaries {
                framework {
                    freeCompilerArgs += "-Xobjc-generics"
                }
            }
        }
    }
    sourceSets {
        commonMain {
            languageSettings {
                languageVersion = '1.3'
                apiVersion = '1.3'
                progressiveMode = true
            }
            dependencies {
                api Dep.Kotlin.stdlibCommon
                api Dep.Klock.common
                implementation Dep.Kotlin.serializationCommon
                implementation Dep.Kotlin.coroutinesCommon
            }
        }
        jvmMain {
            dependencies {
                implementation Dep.Kotlin.stdlibJvm
                implementation Dep.Kotlin.coroutines
            }
        }
        androidMain {
            dependsOn commonMain
            dependencies {
                implementation Dep.Kotlin.stdlibJvm
                implementation Dep.Kotlin.coroutines
            }
        }
        commonTest.dependencies {
            implementation Dep.Test.KotlinMultiPlatform.commonModuleTest
            implementation Dep.Test.KotlinMultiPlatform.commonModuleTestAnnotations
            implementation Dep.MockK.common
        }
        jvmTest {
            dependsOn jvmMain
            dependencies {
                implementation Dep.Test.KotlinMultiPlatform.jvmModuleTest
                implementation Dep.Test.KotlinMultiPlatform.jvmModuleTestJunit
                implementation Dep.MockK.jvm
            }
        }
        iOSMain {
            dependsOn commonMain
            dependencies {
                implementation Dep.Kotlin.coroutinesNative
                implementation Dep.Kotlin.serializationNative
            }
        }
        configure(iosX64Main) {
            dependsOn iOSMain
            dependencies {
                implementation Dep.Kotlin.coroutinesIosX64
                implementation Dep.Kotlin.serializationIosX64
            }
        }
        configure(iosArm64Main) {
            dependsOn iOSMain
            dependencies {
                implementation Dep.Kotlin.coroutinesIosArm64
                implementation Dep.Kotlin.serializationIosArm64
            }
        }
    }
}
configurations {
    compileClasspath
}
