/*
 * Copyright (c) 2019 Adyen N.V.
 *
 * This file is open source and available under the MIT license. See the LICENSE file for more info.
 *
 * Created by caiof on 8/2/2019.
 */

plugins {
    alias libs.plugins.android.application
    alias libs.plugins.kotlin.android
    alias libs.plugins.kotlin.compose
    alias libs.plugins.ksp
    alias libs.plugins.hilt
}

apply from: "${rootDir}/config/gradle/codeQuality.gradle"

if (file("local.gradle").exists()) {
    apply from: "local.gradle"
} else if (System.getenv("CI") == "true") {
    apply from: "ci.local.gradle"
} else if (!isIDEBuild()) {
    // Renovate doesn't set the CI variable, so this way we can still make sure the build succeeds.
    apply from: "ci.local.gradle"
} else {
    throw new GradleException("File example-app/local.gradle not found. Check example-app/README.md for more instructions.")
}

def isIDEBuild() {
    return project.properties['android.injected.invoked.from.ide'] == 'true'
}

android {
    compileSdk libs.versions.compile.sdk.get().toInteger()

    defaultConfig {
        applicationId "com.adyen.checkout.example"
        namespace "com.adyen.checkout.example"

        minSdk libs.versions.min.sdk.get().toInteger()
        targetSdk libs.versions.target.sdk.get().toInteger()
        versionCode libs.versions.version.code.get().toInteger()
        versionName rootProject.ext.versionName

        testInstrumentationRunner 'com.adyen.checkout.test.HiltTestRunner'
    }

    testOptions {
        animationsDisabled = true
    }

    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    buildFeatures {
        compose true
        viewBinding true
        buildConfig true
    }
}

dependencies {
    // Checkout
    implementation project(':drop-in')
    implementation project(':components-compose')
    implementation project(':core')
//    implementation "com.adyen.checkout:drop-in:LATEST_VERSION"
//    implementation "com.adyen.checkout:components-compose:LATEST_VERSION"

    // Dependencies
    implementation libs.bundles.kotlin.coroutines

    implementation libs.androidx.appcompat
    implementation libs.androidx.recyclerview
    implementation libs.androidx.constraintlayout
    implementation libs.androidx.preference

    implementation platform(libs.compose.bom)
    implementation libs.bundles.compose.ui
    implementation libs.compose.activity
    implementation libs.compose.hilt
    implementation libs.compose.material
    implementation libs.compose.material.icons
    implementation libs.compose.viewmodel

    implementation libs.material

    implementation libs.bundles.retrofit
    implementation libs.bundles.moshi
    implementation libs.okhttp.logging

    implementation libs.hilt
    ksp libs.hilt.compiler

    debugImplementation libs.leak.canary
    debugImplementation libs.compose.ui.tooling
    debugImplementation libs.compose.ui.test.manifest

    // Tests
    testImplementation libs.bundles.junit
    testImplementation libs.bundles.mockito
    testImplementation libs.konsist


    androidTestImplementation libs.bundles.androidx.test
    androidTestImplementation libs.barista
    androidTestImplementation libs.bundles.espresso
    androidTestImplementation libs.hilt.test
    androidTestImplementation libs.bundles.kotlin.coroutines.test
    androidTestImplementation libs.mock.web.server

    kspAndroidTest libs.hilt.compiler.test
}
