buildscript {
  // Buildscript is evaluated before everything else so we can't use getExtOrDefault
  def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['ThetaClientReactNative_kotlinVersion']

  repositories {
      google()
      mavenCentral()
  }

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

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

apply plugin: 'com.facebook.react'

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

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

android {
  namespace = "com.ricoh360.thetaclientreactnative"
  compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')

  defaultConfig {
    minSdkVersion getExtOrIntegerDefault('minSdkVersion')
    targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
  }
  buildTypes {
    release {
      minifyEnabled false
    }
  }

  lintOptions {
    disable 'GradleCompatible'
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
  }

  kotlinOptions {
    jvmTarget = "17"
  }

}

repositories {
  mavenCentral()
  google()
}

def kotlin_version = getExtOrDefault('kotlinVersion')

dependencies {
  // noinspection GradleDynamicVersion
  implementation "com.facebook.react:react-native:+"
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3"
  implementation "com.ricoh360.thetaclient:theta-client:1.15.0"
}

react {
  jsRootDir = file("../src/")
  libraryName = "ThetaClientReactNative"
  codegenJavaPackageName = "com.ricoh360.thetaclientreactnative"
}
