plugins {
    id "com.android.library"
}

def coreProj
if (findProject(':core')) {
    coreProj = project(':core')
} else if (findProject(':sentiance-react-native_core')) {
    // Starting from RN 0.61, the @ sign is stripped from project names
    coreProj = project(':sentiance-react-native_core')
} else if (findProject(':@sentiance-react-native_core')) {
    // On RN 0.60, the @ sign is not stripped from project names
    coreProj = project(':@sentiance-react-native_core')
} else {
    throw new GradleException('Could not find the @sentiance-react-native/core package, have you installed it?')
}

android {
    namespace "com.sentiance.react.bridge.smartgeofences"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

apply from: "$coreProj.projectDir/package-json-reader.gradle"
apply from: "$coreProj.projectDir/sentiance-version-finder.gradle"

def corePackageJson = PackageJson.of(coreProj)
applyAndroidVersionsFrom(corePackageJson)
def sentianceSdkVersion = getSentianceSdkVersion()

dependencies {
    implementation(platform("com.sentiance:sdk-bom:${sentianceSdkVersion}"))
    api("com.sentiance:sdk-smart-geofences") { transitive = true }
    api coreProj

    if (findProject(':test-common')) {
        testImplementation project(':test-common')
    }
}

applyReactNativeDependency()
