buildscript {
  repositories {
    google()
    mavenCentral()
    maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
    maven {
      // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
      url "$rootDir/../node_modules/react-native/android"
    }
    maven {
      url "https://maven.google.com"
    }

  }

  dependencies {
    // AGP is provided by the consuming application (React Native app).
    // Do not declare it here to avoid "multiple AGP versions" conflicts.
  }
}

def isNewArchitectureEnabled() {
  return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}

apply plugin: "com.android.library"


def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }

if (isNewArchitectureEnabled()) {
  apply plugin: "com.facebook.react"
}

def getExtOrDefault(name) {
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["BridtvSdkModule_" + name]
}

def getExtOrIntegerDefault(name) {
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["BridtvSdkModule_" + name]).toInteger()
}

android {
  namespace "com.bridtvsdkmodule"
  compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

  defaultConfig {
    minSdkVersion getExtOrIntegerDefault("minSdkVersion")
    targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
    buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
  }
  buildTypes {
    release {
      minifyEnabled false
    }
  }

  lintOptions {
    disable "GradleCompatible"
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
  }

}

repositories {
  maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
   mavenCentral()
   google()
  maven {
    // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
    url "$rootDir/../node_modules/react-native/android"
  }
  maven {
    url "https://maven.google.com"
  }
}


dependencies {
  // For < 0.71, this will be from the local maven repo
  // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
  //noinspection GradleDynpm namicVersion
  implementation "com.facebook.react:react-native:0.20.1"
  implementation 'tv.brid.sdk:bridsdk:1.6.7'

}

if (isNewArchitectureEnabled()) {
  react {
    jsRootDir = file("../src/")
    libraryName = "BridtvSdkModuleView"
    codegenJavaPackageName = "com.bridtvsdkmodule"
  }
}


