buildscript {
    repositories {
        mavenLocal()
        jcenter()
        mavenCentral()
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
        classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
    }
}

plugins {
    id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version"
    id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
}

project.version = "$library_version"
project.group = "$library_group"

apply from: "publish.gradle"

repositories {
    mavenLocal()
    jcenter()
    mavenCentral()
    maven { url "https://kotlin.bintray.com/kotlinx" }
}

kotlin {
    jvm()
    js()

    sourceSets {
        commonMain {
            dependencies {
                implementation kotlin('stdlib')
                api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlin_coroutines_version"
                api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialisation_runtime_version"
                api "org.jetbrains.kotlinx:kotlinx-serialization-properties-common:$kotlin_serialisation_runtime_version"

                api "com.soywiz.korlibs.klock:klock:$klock_version"
                api "com.benasher44:uuid:$uuid_version"

                api "io.ktor:ktor-client-core:$ktor_version"
            }
        }
        commonTest {
            dependencies {
                implementation kotlin('test-common')
                implementation kotlin('test-annotations-common')
            }
        }

        jvmMain {
            dependencies {
                api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version"
                api "org.jetbrains.kotlinx:kotlinx-serialization-properties:$kotlin_serialisation_runtime_version"

                api "io.ktor:ktor-client:$ktor_version"
                api "io.ktor:ktor-server:$ktor_version"

                api "io.ktor:ktor-server-host-common:$ktor_version"
                api "io.ktor:ktor-client-cio:$ktor_version"
            }
        }
        jvmTest {
            dependencies {
                implementation kotlin('test-junit')
            }
        }

        jsMain {
            dependencies {
                api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlin_serialisation_runtime_version"
                api "org.jetbrains.kotlinx:kotlinx-serialization-properties-js:$kotlin_serialisation_runtime_version"
                api "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$kotlin_coroutines_version"
                api "io.ktor:ktor-client-js:$ktor_version"
            }
        }
    }


    targets.all {
        compilations.all {
            kotlinOptions {
                freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xopt-in=kotlin.RequiresOptIn"]
            }
        }
    }
}
