apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'

def versionMajor = 1
def versionMinor = 3
def versionPatch = 0

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def keystoreAlias = properties.getProperty('keystore.keyAlias')
def keystoreAliasPassword = properties.getProperty('keystore.keyPassword')
def keystoreFile = properties.getProperty('keystore.file')
def keystorePassword = properties.getProperty('keystore.password')
def castId = properties.getProperty('cast.appId')

android {

    compileSdkVersion 25
    buildToolsVersion "24.0.3"

    lintOptions {
        abortOnError false
    }

    signingConfigs {
        release {
            keyAlias keystoreAlias
            keyPassword keystoreAliasPassword
            storeFile file(keystoreFile)
            storePassword keystorePassword
        }
    }

    defaultConfig {
        resValue "string", "app_name", "PremoFM"
        applicationId "com.mainmethod.premofm"
        minSdkVersion 21
        targetSdkVersion 25
        renderscriptTargetApi 21
        versionCode 100036
        versionName "${versionMajor}.${versionMinor}.${versionPatch}.${versionCode}"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        setProperty("archivesBaseName", "PremoFM-$versionName")
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        debug {
            buildConfigField "String", "API_ENV", "\"qa\""
            buildConfigField "String", "CAST_APP_ID", "\"" + castId + "\""
            versionNameSuffix "-DEBUG"
            //signingConfig signingConfigs.release
            applicationIdSuffix ".debug"
            resValue "string", "app_name", "PremoFM Debug"
        }
        release {
            buildConfigField "String", "API_ENV", "\"prod\""
            buildConfigField "String", "CAST_APP_ID", "\"" + castId + "\""
            minifyEnabled true
            shrinkResources true
            debuggable false
            zipAlignEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
    testOptions {
        unitTests.returnDefaultValues = true
    }
}

dependencies {
    // Unit testing dependencies
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:1.10.19'
    testCompile 'org.robolectric:robolectric:3.0'

    // Support libraries
    compile 'com.android.support:palette-v7:25.0.0'
    compile 'com.android.support:recyclerview-v7:25.0.0'
    compile 'com.android.support:support-v13:25.0.0'
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:cardview-v7:25.0.0'
    compile 'com.android.support:support-v4:25.0.0'
    compile 'com.android.support:design:25.0.0'
    compile 'com.android.support:mediarouter-v7:25.0.0'

    // Google Play Services
    compile 'com.google.android.gms:play-services-cast:9.0.2'

    // 3rd party imports
    compile 'io.reactivex:rxandroid:1.1.0'
    compile 'io.reactivex:rxjava:1.1.0'
    compile 'com.jakewharton.timber:timber:4.1.0'
    compile 'com.jakewharton.threetenabp:threetenabp:1.0.3'
    compile 'com.google.android.exoplayer:exoplayer:r2.0.4'
    compile 'com.github.amlcurran.showcaseview:library:5.3.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'org.apache.commons:commons-lang3:3.0'
    compile 'com.makeramen:roundedimageview:2.2.0'
    compile 'org.parceler:parceler-api:1.0.4'
    provided 'org.parceler:parceler:1.0.4'
}
