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

group = 'expo.modules.transactionsmsreader'
version = '0.1.0'

def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
if (expoModulesCorePlugin.exists()) {
  apply from: expoModulesCorePlugin
  applyKotlinExpoModulesCorePlugin()
}

// SDK 54 default targets — all values are overridable from the consumer app's
// `build.gradle` so older toolchains can still compile.
def safeExtGet(prop, fallback) {
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

android {
  namespace "expo.modules.transactionsmsreader"

  compileSdkVersion safeExtGet("compileSdkVersion", 35)

  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
  if (agpVersion.tokenize('.')[0].toInteger() < 8) {
    compileOptions {
      sourceCompatibility JavaVersion.VERSION_11
      targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
      jvmTarget = JavaVersion.VERSION_11.majorVersion
    }
  }

  defaultConfig {
    minSdkVersion safeExtGet("minSdkVersion", 24)
    targetSdkVersion safeExtGet("targetSdkVersion", 34)
  }

  lintOptions {
    abortOnError false
  }

  publishing {
    singleVariant("release") {
      withSourcesJar()
    }
  }
}

dependencies {
  implementation project(':expo-modules-core')

  // Kotlin stdlib — version controlled by the consumer app via Expo.
  implementation "org.jetbrains.kotlin:kotlin-stdlib:${safeExtGet('kotlinVersion', '1.9.25')}"

  // Coroutines for off-main-thread SMS provider reads.
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3"
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"
}
