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

android {
    def globalConfiguration = rootProject.extensions.getByName("ext")

    compileSdkVersion globalConfiguration["androidCompileSdkVersion"]
    buildToolsVersion globalConfiguration["androidBuildToolsVersion"]

    defaultConfig {
        minSdkVersion globalConfiguration["androidMinSdkVersion"]
        targetSdkVersion globalConfiguration["androidTargetSdkVersion"]
        multiDexEnabled = true
        testInstrumentationRunner "<%= appPackage %>.ui.test.TestRunner"
    }

    buildTypes {
        debug {
            testCoverageEnabled true
        }
    }

    dexOptions {
        preDexLibraries = false
        dexInProcess = false
        javaMaxHeapSize "4g"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
    }

    lintOptions {
        quiet true
        abortOnError false
        ignoreWarnings true
    }

}

kapt {
    correctErrorTypes = true
}

configurations.all {
    resolutionStrategy {
        force "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    }
}

dependencies {
    def mobileUiDependencies = rootProject.ext.mobileUiDependencies
    def mobileUiTestDependencies = rootProject.ext.mobileUiTestDependencies

    implementation project(':presentation')
    implementation project(':data')
    implementation project(':cache')
    implementation project(':remote')

    implementation mobileUiDependencies.javaxAnnotation

    implementation mobileUiDependencies.kotlin
    implementation mobileUiDependencies.javaxInject
    implementation mobileUiDependencies.rxKotlin
    implementation mobileUiDependencies.androidAnnotations
    implementation mobileUiDependencies.androidSupportV4
    implementation mobileUiDependencies.androidSupportV13
    implementation mobileUiDependencies.appCompatV7
    implementation mobileUiDependencies.supportRecyclerView
    implementation mobileUiDependencies.supportDesign
    implementation mobileUiDependencies.timber
    implementation mobileUiDependencies.rxAndroid
    implementation mobileUiDependencies.glide
    implementation mobileUiDependencies.dagger
    implementation mobileUiDependencies.daggerSupport

    testImplementation mobileUiTestDependencies.kotlinJUnit

    kapt mobileUiDependencies.daggerCompiler
    kapt mobileUiDependencies.daggerProcessor
    compileOnly mobileUiDependencies.glassfishAnnotation

    // Instrumentation test dependencies
    androidTestImplementation mobileUiTestDependencies.junit
    androidTestImplementation mobileUiTestDependencies.mockito
    androidTestImplementation mobileUiTestDependencies.mockitoAndroid
    androidTestImplementation (mobileUiTestDependencies.espressoCore) {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    androidTestImplementation (mobileUiTestDependencies.androidRunner) {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    androidTestImplementation (mobileUiTestDependencies.androidRules) {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    androidTestImplementation (mobileUiTestDependencies.espressoIntents) {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    androidTestImplementation(mobileUiTestDependencies.espressoContrib) {
        exclude module: 'appcompat'
        exclude module: 'appcompat-v7'
        exclude module: 'support-v4'
        exclude module: 'support-v13'
        exclude module: 'support-annotations'
        exclude module: 'recyclerview-v7'
        exclude module: 'design'
    }

    kaptTest mobileUiDependencies.daggerCompiler
    kaptAndroidTest mobileUiDependencies.daggerCompiler
}
