def DEFAULT_COMPILE_SDK_VERSION = 36
def DEFAULT_MIN_SDK_VERSION = 21
def DEFAULT_TARGET_SDK_VERSION = 35

buildscript {
    ext.kotlin_version = '2.1.21'

    if (project == rootProject) {
        repositories {
            google()
            mavenCentral()
        }

        dependencies {
            classpath 'com.android.tools.build:gradle:8.1.1'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        }
    }
}

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

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

android {
    compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
    namespace = "com.withpersona.sdk2.reactnative"
    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
        targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
        }
    }
    lintOptions {
        disable 'GradleCompatible'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '17'
    }
    dexOptions {
        preDexLibraries = false
    }
}

repositories {
    google()
    mavenLocal()
    mavenCentral()
    maven {
        url "https://sdk.withpersona.com/android/releases"
    }
    maven {
        url 'https://jitpack.io'
    }
}

dependencies {
    //noinspection GradleDynamicVersion
    implementation("com.facebook.react:react-android:+")

    // NB: be sure to bump `nfc-impl` in example/android/app/build.gradle as well
    implementation 'com.withpersona.sdk2:inquiry:2.42.0'
    implementation("androidx.fragment:fragment:1.8.6")

    // Kotlin
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
