buildscript {
    ext.safeExtGet = { prop, fallback ->
        return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
    }
    ext {
        gson_version = '2.9.1'
        startup_version = '1.1.1'
        kotlin_coroutine_version = '1.6.4'
        retrofit_version = '2.9.0'
        room_version = '2.5.0'
        mqtt_version = '1.2.5'
        ktor_network_version = '2.1.0'
    }

    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.8.0')}"
    }
}

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

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

android {
    namespace 'com.gizwits.reactnativegizwitssdkv5'
    compileSdkVersion safeExtGet('compileSdkVersion', 34)
    buildToolsVersion safeExtGet('buildToolsVersion', '33.0.0')

    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', 26)
        targetSdkVersion safeExtGet('targetSdkVersion', 34)
    }

    // compileOptions {
    //     sourceCompatibility JavaVersion.VERSION_11
    //     targetCompatibility JavaVersion.VERSION_11
    // }

    // kotlinOptions {
    //     jvmTarget = '11'
    // }
}

repositories {
    google()
    mavenCentral()
}

dependencies {
    //noinspection GradleDynamicVersion
    implementation 'com.facebook.react:react-native:+'

    implementation 'com.jakewharton.timber:timber:5.0.1'
    implementation "org.eclipse.paho:org.eclipse.paho.client.mqttv3:$mqtt_version"

    implementation "androidx.startup:startup-runtime:$startup_version"

    implementation("io.github.gizwits:sdk:0.5.2-rongwei")
    implementation("io.github.gizwits:sdk-bluetooth:0.5.2-rongwei")
    implementation("io.github.gizwits:sdk-lan:0.5.2-rongwei")
    implementation("io.github.gizwits:sdk-mqtt:0.5.2-rongwei")
    // implementation files('libs/sdk-release.aar')
    // implementation files('libs/sdk-bluetooth-release.aar')
    // implementation files('libs/sdk-lan-release.aar')
    // implementation files('libs/sdk-mqtt-release.aar')
    
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutine_version")
    // retrofit
    implementation("com.squareup.retrofit2:retrofit:$retrofit_version")
    implementation("com.squareup.retrofit2:converter-gson:$retrofit_version")
    implementation("com.squareup.retrofit2:converter-scalars:$retrofit_version")
    // gson
    implementation("com.google.code.gson:gson:$gson_version")
    //ktor
    implementation "io.ktor:ktor-network:$ktor_network_version"

}
