apply plugin: 'com.android.application'


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 28
    defaultConfig {
        applicationId "com.an.dagger"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        buildConfigField "String", "TMDB_API_KEY", "\"${getProperty("local.properties", "tmdb_api_key")}\""
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    /* I use Data Binding and Java8 in all my projects */
    dataBinding {
        enabled true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    /* Android Support Library: RecyclerView, CardView  */
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'

    /* Retrofit using RxJava2, Okhttp, Okhttp logging interceptor, Gson  */
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'

    /* RxAndroid  */
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'

    /* Picasso lib for image loading  */
    implementation 'com.squareup.picasso:picasso:2.71828'

    /* Android Architecture Component - ConstraintLayout  */
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

    /* Android Architecture Component - LiveData & ViewModel  */
    implementation 'android.arch.lifecycle:extensions:1.1.1'

    /* Android Architecture Component - Room Persistance Lib  */
    implementation 'android.arch.persistence.room:runtime:1.1.1'
    implementation 'android.arch.persistence.room:rxjava2:1.1.1'
    annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'

    /* Dagger2 - We are going to use dagger.android which includes
     * support for Activity and fragment injection so we need to include
     * the following dependencies */
    implementation 'com.google.dagger:dagger-android:2.17'
    implementation 'com.google.dagger:dagger-android-support:2.17'
    annotationProcessor 'com.google.dagger:dagger-android-processor:2.17'

    /* Dagger2 - default dependency */
    annotationProcessor 'com.google.dagger:dagger-compiler:2.17'
}
