apply plugin: 'com.android.application'
apply plugin: 'realm-android'

def getProperty(String filename, String propName) {
    def propsFile = rootProject.file(filename)
    if (propsFile.exists()) {
        def props = new Properties()
        props.load(new FileInputStream(propsFile))
        if (props[propName] != null) {
            return props[propName]
        } else {
            print("No such property " + propName + " in file " + filename)
        }
    } else {
        print(filename + " does not exist!")
    }
}

android {
    compileSdkVersion 29
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId "com.esoxjem.movieguide"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        buildConfigField "String", "TMDB_API_KEY", "\"${getProperty("local.properties", "tmdb_api_key")}\""
        buildConfigField "String", "TMDB_BASE_URL", "\"https://api.themoviedb.org/\""
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude 'META-INF/rxjava.properties'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

ext {
    supportLibVersion = '28.0.0'
    okhttpVersion = '4.2.2'
    daggerVersion = '2.5'
    espressoVersion = '3.0.2'
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    //Support
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.annotation:annotation:1.1.0'
    implementation 'androidx.palette:palette:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.test.espresso:espresso-idling-resource:3.2.0'

    // Rx
    implementation 'io.reactivex.rxjava2:rxjava:2.2.14'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'

    //RX View Binding
    implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.2.0'

    // Network
    implementation "com.squareup.okhttp3:okhttp:${okhttpVersion}"
    implementation "com.squareup.okhttp3:logging-interceptor:${okhttpVersion}"
    implementation 'com.github.bumptech.glide:glide:4.2.0'

    // Other
    implementation 'net.jcip:jcip-annotations:1.0'
    implementation 'com.google.guava:guava:18.0'
    implementation 'com.squareup.moshi:moshi:1.9.2'
    implementation 'com.jakewharton:butterknife:10.2.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'

    // Dependency Injection
    annotationProcessor "com.google.dagger:dagger-compiler:${daggerVersion}"
    implementation "com.google.dagger:dagger:${daggerVersion}"
    compileOnly 'javax.annotation:jsr250-api:1.0'

    // Retrofit 2
    implementation 'com.squareup.retrofit2:retrofit:2.6.2'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.6.2'
    implementation 'com.squareup.retrofit2:converter-moshi:2.6.2'

    // Tests
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:3.1.0'
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestImplementation('androidx.test.espresso:espresso-contrib:3.1.0') {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude module: 'recyclerview-v7'
    }
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test:rules:1.2.0'
}