apply from: file('./../gradle/constants.gradle')

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

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

def reactNativeVersion = safeExtGet("reactNative", "+")

android {
    compileSdkVersion project.ext.compileSdkVersion
    buildToolsVersion project.ext.buildToolsVersion

    defaultConfig {
        minSdkVersion project.ext.minSdkVersion
        targetSdkVersion project.ext.targetSdkVersion

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17.toString()
    }
    namespace 'com.applicaster.xray.reactnative'
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])

    xrayAPI(dependencies, ':xray-core')

    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:${reactNativeVersion}"

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.1'
    implementation 'androidx.appcompat:appcompat:1.2.0'

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test:core:1.5.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

project.ext {
    ARTIFACT_ID="xray-react-native"
    ARTIFACT_FILE_NAME="xray-react-native"
    POM_DESCRIPTION="Applicaster XRay React Native Extension"
}

if(rootProject.ext.has('xRayPublishing')) {
    apply from: file('./../gradle/publish.gradle')
}

