buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.2'
        //noinspection DifferentKotlinGradleVersion
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}


repositories {
    google()
    jcenter()
    maven { url 'https://jitpack.io' }
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'org.jetbrains.kotlin.android.extensions'
apply plugin: 'kotlin-kapt'

androidExtensions {
    experimental = true
}

dependencies {
    implementation('oauth.signpost:signpost-commonshttp4:1.2.1.2') {
        exclude group: 'org.apache.httpcomponents'
    }
    implementation 'commons-io:commons-io:2.6'
    implementation 'com.squareup:otto:1.3.8'
    implementation 'com.google.zxing:android-integration:3.3.0'

    implementation 'com.github.blocoio:faker:1.0.1'

    implementation 'androidx.annotation:annotation:1.1.0'

    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

    testImplementation 'junit:junit:4.13.1'

    // Required for instrumented tests
    androidTestImplementation 'androidx.annotation:annotation:1.1.0'

    androidTestImplementation('com.schibsted.spain:barista:2.7.1') {
        exclude group: 'com.android.support'
        exclude group: 'org.jetbrains.kotlin' // Only if you already use Kotlin in your project
    }

    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestUtil 'androidx.test:orchestrator:1.3.0'

}

def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

def testPropertiesFile = rootProject.file("test.properties")
def testProperties = new Properties()
testProperties.load(new FileInputStream(testPropertiesFile))

testProperties.putAll(gradle.getStartParameter().getProjectProperties())

android {
    compileSdkVersion 29
    buildToolsVersion "28.0.3"

    useLibrary 'org.apache.http.legacy'

    buildFeatures {
        dataBinding = true
    }

    defaultConfig {
        versionCode 1461
        versionName "1.4.6.1"

        minSdkVersion 18
        targetSdkVersion 29

        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    }

    testOptions {
        execution 'ANDROIDX_TEST_ORCHESTRATOR'
    }
    

    signingConfigs {
        release {
            keyAlias keystoreProperties.getProperty('keyAlias', '')
            keyPassword keystoreProperties.getProperty('keyPassword', '')
            storeFile file(keystoreProperties.getProperty('storeFile', 'dummy'))
            storePassword keystoreProperties.getProperty('storePassword', '')
        }
    }

    buildTypes {
        release {
            zipAlignEnabled true
            signingConfig signingConfigs.release
            minifyEnabled true
        }

        debug {
            buildConfigField("String", "TEST_USER_ID", "\"${testProperties.testUserId}\"")
            buildConfigField("String", "TEST_USER_KEY_READONLY", "\"${testProperties.testUserKeyReadonly}\"")
            buildConfigField("String", "FLAVOR", "\"\"")
        }
    }

    lintOptions {
        abortOnError false
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
    }
}

apply plugin: 'kotlin-android-extensions'