ext {
    junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
    androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
    androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
    androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
    compileSdkVersion = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
    targetSdkVersion = project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
}

buildscript {
    ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '2.2.20'
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.13.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.20"
    }
}

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

if (file('load-local-dev-repo-settings.gradle').exists()) {
    apply from: 'load-local-dev-repo-settings.gradle'
}

android {
    namespace "com.olo.olopaysdk.capacitorplugin"
    compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
    defaultConfig {
        minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
        targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        abortOnError false
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_21
        targetCompatibility JavaVersion.VERSION_21
    }
    kotlinOptions {
        jvmTarget = "21"
    }

    sourceSets {
        test {
            java.srcDirs = ['src/test/kotlin']
            resources.srcDirs = ['src/test/resources']
        }
    }
    testOptions {
        unitTests {
            includeAndroidResources = true
            returnDefaultValues = true
            all {
                testLogging {
                    events "passed", "skipped", "failed", "standardOut", "standardError"
                    showExceptions true
                    showCauses true
                    showStackTraces true
                }
            }
        }
    }
}

repositories {
    google()
    mavenCentral()
    if (rootProject.ext.has("addLocalDevRepo") && rootProject.ext.addLocalDevRepo != null) {
        rootProject.ext.addLocalDevRepo(repositories)
    }
}


dependencies {
    if (!rootProject.ext.has("addLocalDevDependency") ||
        rootProject.ext.addLocalDevDependency == null ||
        !rootProject.ext.addLocalDevDependency(dependencies)
    ) {
        implementation "com.olo.olopay:olo-pay-android-sdk:5.0.0"
    }

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "androidx.constraintlayout:constraintlayout:2.2.1"
    implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
    implementation project(path: ':capacitor-android')
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.9.4'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.4'
    implementation 'com.google.android.material:material:1.13.0'
    implementation "androidx.core:core-ktx:1.17.0"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2"

    // Testing Dependencies
    testImplementation "junit:junit:$junitVersion"
    androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
    androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
    testImplementation 'org.json:json:20250517'
}

