apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.github.ben-manes.versions'
//apply plugin: 'io.fabric'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    dexOptions {
        maxProcessCount 4
        preDexLibraries false
        javaMaxHeapSize "8g"
    }

    defaultConfig {
        applicationId "io.mvpstarter.sample"
        minSdkVersion 19
        targetSdkVersion 28
        testInstrumentationRunner "${applicationId}.runner.RxAndroidJUnitRunner"
        versionCode 1000
        // Major -> Millions, Minor -> Thousands, Bugfix -> Hundreds. E.g 1.3.72 == 1,003,072
        versionName '0.1.0'

        buildConfigField("String", "POKEAPI_API_URL",
                "\"${PokeapiApiUrl}\"")

        multiDexEnabled true
    }

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

    sourceSets {
        def commonTestDir = 'src/commonTest/java'
        test {
            java.srcDir commonTestDir
        }
        androidTest {
            java.srcDir commonTestDir
        }
    }

    lintOptions {
        textOutput "stdout"
        textReport true
        checkAllWarnings true
        warningsAsErrors true
        showAll true
        explainIssues true
        abortOnError false
        lintConfig file("$projectDir/lint.xml")
    }

    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude 'LICENSE.txt'
        exclude 'META-INF/license/LICENSE.base64.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/rxjava.properties'
        exclude 'META-INF/MANIFEST.MF'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    testOptions {
        unitTests {
            returnDefaultValues = true
        }
    }

    dataBinding {
        enabled = true
    }

    androidExtensions {
        experimental = true
    }
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'org.jetbrains.kotlin' && requested.name == 'kotlin-reflect') {
            details.useVersion kotlin_version
        }
    }
}

apply from: 'dependencies.gradle'

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    implementation supportLibs
    implementation googlePlayLibs
    implementation networkLibs
    implementation rxJavaLibs
    implementation otherLibs

    debugImplementation debugLibs
    releaseImplementation releaseLibs

    implementation(glideOkhttp) {
        exclude group: 'glide-parent'
    }
    
    debugImplementation(sherlock) {
        transitive = true
    }

    // APT dependencies
    kapt annotationProcessorLibs
    kaptTest daggerCompiler
    kaptAndroidTest daggerCompiler

    testImplementation unitTestLibs
    androidTestImplementation androidTestsLibs
}

// Log out test results to console
tasks.matching { it instanceof Test }.all {
    testLogging.events = ["failed", "passed", "skipped"]
}