configureAndroidApp(project)

def getAccessToken() {
    def systemEnvKey = System.getenv('ACCESS_KEY')

    def props = new Properties()
    def propsFile = file("local.properties")
    if (propsFile.exists()) {
        propsFile.withInputStream { props.load(it) }
    }
    def localPropsKey = props.getProperty("accessKey")

    return localPropsKey ?: systemEnvKey ?: "\"\""
}

def getClientSecret() {
    def systemEnvKey = System.getenv('CLIENT_SECRET')

    def props = new Properties()
    def propsFile = file("local.properties")
    if (propsFile.exists()) {
        propsFile.withInputStream { props.load(it) }
    }
    def localPropsKey = props.getProperty("clientSecret")

    return localPropsKey ?: systemEnvKey ?: "\"\""
}

android {
    namespace 'com.badoo.ribs.example'

    compileSdk 34

    defaultConfig {
        applicationId "com.badoo.ribs.example"
        minSdk deps.build.minSdk
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        buildConfigField "String", "ACCESS_KEY", getAccessToken()
        buildConfigField "String", "CLIENT_SECRET", getClientSecret()
    }

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

}

dependencies {
    implementation deps.android.appCompat
    implementation deps.android.design
    implementation deps.android.constraintLayout
    implementation deps.android.recyclerView
    implementation deps.external.coil
    implementation deps.android.browser


    implementation deps.external.rxrelay3
    implementation deps.external.rxandroid3

    implementation deps.retrofit.retrofit
    implementation deps.retrofit.rxjavaAdapter
    implementation deps.retrofit.moshiConverter
    implementation deps.retrofit.okhttp
    implementation deps.retrofit.okhttpLoggingInterceptor
    implementation deps.retrofit.moshiKotlin

    implementation project(":libraries:rib-base")
    implementation project(':libraries:rib-rx3')
    implementation project(":libraries:rib-portal")

    implementation deps.external.mviCore
    implementation deps.external.mviCoreAndroid
    implementation deps.external.mviCoreBinder
    implementation deps.external.mviCoreDiff
    implementation project(path: ':libraries:rib-debug-utils')

    junitTestImplementation(project)
    testImplementation deps.test.mockitoKotlin
    testImplementation deps.test.assertj
    testImplementation project(":libraries:rib-base-test")
    testImplementation project(':libraries:rib-base-test-rx3')

    junitAndroidTestImplementation(project)
    androidTestImplementation project(":libraries:rib-base-test")
    androidTestImplementation deps.androidTest.espresso
    androidTestImplementation deps.androidTest.runner

    debugImplementation project(":libraries:rib-base-test-activity")
}
