buildscript {
    ext {
        kotlinVersion = project.hasProperty('kotlinVersion') ? rootProject.ext.kotlinVersion : "1.8.22"
        mockkVersion = project.hasProperty('mockkVersion') ? rootProject.ext.mockkVersion : "1.13.5"
        junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
        coroutinesVersion = project.hasProperty('coroutinesVersion') ? rootProject.ext.coroutinesVersion : '1.7.2'
        androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
        androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
        androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
        kotlinxVersion = project.hasProperty('kotlinxVersion') ? rootProject.ext.kotlinxVersion : '1.7.2'
        androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.12.0'
        androidxLifecycleVersion = project.hasProperty('androidxLifecycleVersion') ? rootProject.ext.androidxLifecycleVersion : '2.6.2'
        androidxWorkVersion = project.hasProperty('androidxWorkVersion') ? rootProject.ext.androidxWorkVersion : '2.8.1'
        sunMailVersion = project.hasProperty('sunMailVersion') ? rootProject.ext.sunMailVersion : '1.6.7'
        retrofitVersion = project.hasProperty('retrofitVersion') ? rootProject.ext.retrofitVersion : '2.9.0'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.1.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10'
    }
}

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

android {
    namespace "com.mytiki.sdk.capture.receipt.capacitor"
    defaultConfig {
        minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
        compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
        targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        testApplicationId "com.mytiki.sdk.capture.receipt.capacitor"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = 17
    }
    packagingOptions {
        resources {
            excludes += ['META-INF/LICENSE-notice.md', 'META-INF/LICENSE.md', 'META-INF/NOTICE.md']
        }
    }
    lint {
        abortOnError false
    }
}

repositories {
    google()
    mavenCentral()
    maven { url  "https://maven.microblink.com" }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':capacitor-android')

    implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation "androidx.core:core:$androidxCoreVersion"
    implementation "androidx.core:core-ktx:$androidxCoreVersion"
    implementation "androidx.webkit:webkit:1.8.0"
    implementation "androidx.work:work-runtime:$androidxWorkVersion"
    implementation "androidx.work:work-runtime-ktx:$androidxWorkVersion"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$androidxLifecycleVersion"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$androidxLifecycleVersion"
    implementation "androidx.lifecycle:lifecycle-common-java8:$androidxLifecycleVersion"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$androidxLifecycleVersion"
    implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$androidxLifecycleVersion"
    implementation "androidx.fragment:fragment-ktx:1.6.1"
    implementation 'androidx.databinding:viewbinding:8.1.1'
    implementation "androidx.datastore:datastore-preferences:1.0.0"

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxVersion"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinxVersion"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$kotlinxVersion"

    implementation 'com.squareup.okhttp3:okhttp:4.11.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.11.0'
    implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
    implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
    implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
    implementation 'com.squareup.okio:okio:3.3.0'

    implementation "com.google.android.gms:play-services-tasks:18.0.2"
    implementation "com.google.android.gms:play-services-auth:20.7.0"
    implementation 'com.google.android.material:material:1.9.0'

    implementation 'com.jakewharton.timber:timber:5.0.1'

    implementation "com.sun.mail:android-mail:$sunMailVersion"
    implementation "com.sun.mail:android-activation:$sunMailVersion"

    implementation(platform("com.microblink.blinkreceipt:blinkreceipt-bom:1.6.8"))
    implementation("com.microblink.blinkreceipt:blinkreceipt-account-linking")
    implementation("com.microblink.blinkreceipt:blinkreceipt-camera")
    implementation("com.microblink.blinkreceipt:blinkreceipt-camera-ui")
    implementation("com.microblink.blinkreceipt:blinkreceipt-core")
    implementation("com.microblink.blinkreceipt:blinkreceipt-digital")
    implementation("com.microblink.blinkreceipt:blinkreceipt-recognizer")
    
    implementation 'androidx.test:monitor:1.6.1'
    implementation 'androidx.test.ext:junit-ktx:1.1.5'

    testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion"
    testImplementation "io.mockk:mockk:$mockkVersion"
    testImplementation 'org.json:json:20230227'

    testImplementation 'org.json:json:20230227'
    testImplementation "junit:junit:$junitVersion"
    testImplementation "io.mockk:mockk:$mockkVersion"

    androidTestImplementation "io.mockk:mockk-android:$mockkVersion"
    androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
    androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
    androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion"
    androidTestImplementation 'androidx.test:rules:1.5.0'
}
