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

        dependencies {
            classpath 'com.android.tools.build:gradle:3.5.4'
        }
    }
}

apply plugin: 'com.android.library'

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

android {
    def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
    if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
        namespace = "com.reactnativegleapsdk"
    }

    compileSdkVersion safeExtGet('Gleapsdk_compileSdkVersion', 33)
    defaultConfig {
        minSdkVersion safeExtGet('Gleapsdk_minSdkVersion', 21)
        targetSdkVersion safeExtGet('Gleapsdk_targetSdkVersion', 33)

    }

    buildTypes {
        release {
            minifyEnabled false
        }
    }
    lintOptions {
        disable 'GradleCompatible'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

repositories {
    mavenLocal()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url("$rootDir/../node_modules/react-native/android")
    }
    google()
    mavenCentral()
}

dependencies {
  implementation "com.facebook.react:react-native:+"
  implementation group: 'io.gleap', name: 'gleap-android-sdk', version: '14.5.0'

  if(rootProject && rootProject.ext) {
    if(rootProject.ext.targetSdkVersion == 30 || rootProject.ext.compileSdkVersion == 30) {
      implementation( "androidx.appcompat:appcompat:1.3.0") {
        force = true
      }
    }
  }
}
