apply plugin: 'com.android.application'
apply from: '../config/quality/quality.gradle'
apply from: '../config/jacoco.gradle'
apply plugin: 'com.github.ben-manes.versions'
//apply plugin: 'io.fabric'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.0'

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

    defaultConfig {
        defaultPublishConfig 'debug'

        applicationId "io.mvpstarter.sample"
        minSdkVersion 19
        targetSdkVersion 27
        testInstrumentationRunner "io.mvpstarter.sample.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}\"")
    }
    buildTypes {
        release {
            minifyEnabled false
            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 true
        ignoreWarnings false
        checkReleaseBuilds true
        htmlReport true
        xmlReport true
        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'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    testOptions {
        animationsDisabled = true
        unitTests {
            includeAndroidResources = true
            returnDefaultValues = true
            all {
                jacoco {
                    includeNoLocationClasses true
                }
                systemProperty 'robolectric.logging.enabled', 'true'
                systemProperty 'robolectric.logging', 'stdout'
                // Print test details in the terminal (or CI).
                testLogging {
                    events 'passed', 'skipped', 'failed', 'standardOut', 'standardError' // Log out test results to console
                    exceptionFormat 'full'
                }
            }
        }
    }
}

configurations.all {
    resolutionStrategy {
        force 'com.squareup.okio:okio:1.11.0'
        force "com.squareup.okhttp3:okhttp:3.5.0"
    }
}


apply from: 'dependencies.gradle'

dependencies {

    implementation supportLibs
    implementation googlePlayLibs
    implementation networkLibs
    implementation rxJavaLibs
    implementation otherLibs

    debugImplementation debugLibs
    releaseImplementation releaseLibs

    debugImplementation(sherlock) {
        transitive = true
    }

    // APT dependencies
    annotationProcessor annotationProcessorLibs
    testAnnotationProcessor daggerCompiler
    androidTestAnnotationProcessor daggerCompiler

    testImplementation unitTestLibs
    androidTestImplementation androidTestsLibs
}