apply plugin: 'com.android.library'

def packageJsonFile = file("${project.projectDir}/../package.json")
def wrapperVersion = "0rn"
if (packageJsonFile.exists()) {
    def pkg = new groovy.json.JsonSlurper().parse(packageJsonFile)
    def parts = pkg.version.toString().tokenize('.')
    wrapperVersion = "${parts[-1]}rn"
}

android {
    namespace "com.fiuu.xdk.reactnative"
    compileSdkVersion 37
    buildFeatures {
        buildConfig true
    }
    defaultConfig {
        minSdkVersion 26
        targetSdkVersion 36
        versionCode 1
        versionName "1.0.0"
        buildConfigField "String", "WRAPPER_VERSION", "\"${wrapperVersion}\""
    }

    testOptions {
        unitTests.includeAndroidResources = false
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url 'https://jitpack.io'
            content {
                includeGroup('com.github.FiuuPayment')
            }
            metadataSources {
                mavenPom()
                artifact()
            }
        }
    }
}

dependencies {
    api 'androidx.appcompat:appcompat:1.7.1'
    implementation 'com.facebook.react:react-android'
    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.robolectric:robolectric:4.14.1'
    // NOTE: Do NOT append "@aar" here. That notation tells Gradle to fetch only
    // the artifact and skip resolving the library's own POM/module dependencies
    // (Gson, OkHttp, Play Services Pay/Wallet, zxing, commons-lang3, etc.),
    // which causes runtime NoClassDefFoundError crashes (e.g. missing
    // com.google.gson.Gson) when the vendor SDK's PaymentActivity loads.
    implementation 'com.github.FiuuPayment:Mobile-XDK-Fiuu_Android_Library:3.34.41'
}
