buildscript {
  ext.PagseguroPlugpag = [
    kotlinVersion: "2.0.21",
    minSdkVersion: 24,
    compileSdkVersion: 36,
    targetSdkVersion: 36
  ]

  ext.getExtOrDefault = { prop ->
    if (rootProject.ext.has(prop)) {
      return rootProject.ext.get(prop)
    }

    return PagseguroPlugpag[prop]
  }

  repositories {
    google()
    mavenCentral()
    maven { url 'https://github.com/pagseguro/PlugPagServiceWrapper/raw/master' }
  }

  dependencies {
    classpath "com.android.tools.build:gradle:8.7.2"
    // noinspection DifferentKotlinGradleVersion
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
  }
}


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

apply plugin: "com.facebook.react"

android {
  namespace "com.pagseguroplugpag"

  compileSdkVersion getExtOrDefault("compileSdkVersion")

  defaultConfig {
    minSdkVersion getExtOrDefault("minSdkVersion")
    targetSdkVersion getExtOrDefault("targetSdkVersion")
  }

  buildFeatures {
    buildConfig true
  }

  buildTypes {
    release {
      minifyEnabled false
    }
  }

  lint {
    disable "GradleCompatible"
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

  sourceSets {
    main {
      java {
        srcDirs += ["${buildDir}/generated/source/codegen/java"]
      }
    }
  }

  testOptions {
    unitTests {
      // Tipos Android/RN referenciados nos testes JVM (ex.: WritableNativeMap) retornam default.
      returnDefaultValues = true
      all {
        useJUnitPlatform()
      }
    }
  }
}

dependencies {
  implementation "com.facebook.react:react-android"
  implementation 'br.com.uol.pagseguro.plugpagservice.wrapper:wrapper:1.35.0'

  // Testes de integração Kotlin (Constituição Princípio III — TDD; FR-008)
  testImplementation "org.junit.jupiter:junit-jupiter:5.10.2"
  testRuntimeOnly "org.junit.platform:junit-platform-launcher:1.10.2"
  testImplementation "io.mockk:mockk:1.13.13"
  testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.1"
}
