// The React Native module over the sMap Android SDK (ca.superroute.smap).
//
// The SDK comes from JitPack (com.github.Goodneo-Solutions:smap-sdk:<version>, the tag of this release) unless
// the app includes the SDK's source as the project ':smap-android' (the example does, so it builds against the
// SDK in this repository). Set `smapAndroidVersion` in the app's root `ext` to pick another tag.
def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

apply plugin: "com.android.library"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"

android {
    namespace "ca.superroute.smap.reactnative"
    compileSdk safeExtGet("compileSdkVersion", 36)

    defaultConfig {
        minSdk safeExtGet("minSdkVersion", 24)
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
}

kotlin {
    jvmToolchain(17)
}

repositories {
    google()
    mavenCentral()
    maven { url "https://jitpack.io" }
}

dependencies {
    implementation "com.facebook.react:react-android"
    def localSdk = rootProject.findProject(":smap-android")
    if (localSdk != null) {
        api localSdk
    } else {
        api "com.github.Goodneo-Solutions:smap-sdk:${safeExtGet("smapAndroidVersion", "1.0.2")}"
    }
}
