buildscript {
  repositories {
    google()
    mavenCentral()
  }

  dependencies {
    classpath("com.android.tools.build:gradle:8.3.2")
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24")
  }
}

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

apply plugin: "com.android.library"
apply plugin: 'org.jetbrains.kotlin.android'


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["Default_" + name]
}

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

android {
  compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
  namespace 'com.paxposlink'
  buildFeatures {
    buildConfig true
  }

  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_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
  kotlinOptions {
    jvmTarget = '17'
  }

}

repositories {
  mavenCentral()
  google()
}


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 GradleDynamicVersion
  implementation "com.facebook.react:react-native:+"

  //! https://developer.pax.us/resources/section/250038301709316096?sectionName=POSLink%202&articleId=352771637260593152
  //! POSLink Semi-Integration SDK V2.02.00 (2025-11-26)
  //! Core: POSLink_Core_Android_V2.00.11 | Semi/Admin Plugin: V2.02.00 | PaxLog 1.0.13 | GLComm V1.12.01
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation 'androidx.core:core-ktx:1.16.0'
  implementation 'com.google.code.gson:gson:2.9.1'
}

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