apply plugin: "com.android.application"
apply plugin: "kotlin-android"
apply plugin: "io.fabric"
apply plugin: "realm-android"

android {
    signingConfigs {
        release
    }

    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.gpacini.daysuntil"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 4
        versionName "1.3"
    }
    buildTypes {
        debug {
            resValue "string", "information_heading", "Information - DEBUG"

            applicationIdSuffix ".debug"
        }
        release {
            resValue "string", "information_heading", "Information - $defaultConfig.versionName"

            minifyEnabled true
            shrinkResources false
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    packagingOptions {
        exclude "META-INF/DEPENDENCIES"
        exclude "LICENSE.txt"
        exclude "META-INF/LICENSE"
        exclude "META-INF/LICENSE.txt"
        exclude "META-INF/NOTICE"
    }
    sourceSets {
        main.java.srcDirs += "src/main/kotlin"
    }
}

dependencies {
    final SUPPORT_LIBRARY_VERSION = "23.3.0"

    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    compile "com.android.support:support-v4:$SUPPORT_LIBRARY_VERSION"
    compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
    compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
    compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
    compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
    compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"

    compile "io.reactivex:rxandroid:1.1.0"
    compile "io.reactivex:rxjava:1.1.3"
    compile "com.artemzin.rxjava:proguard-rules:1.1.3.0"

    compile "uk.co.ribot:easyadapter:1.5.0@aar"

    compile "com.wdullaer:materialdatetimepicker:2.3.0"

    compile "com.squareup.picasso:picasso:2.5.2"
    compile "com.soundcloud.android:android-crop:1.0.1@aar"

    compile("com.crashlytics.sdk.android:crashlytics:2.5.5@aar") {
        transitive = true;
    }
}

buildscript {
    ext.kotlin_version = "1.0.1-2"
    repositories {
        jcenter()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

repositories {
    jcenter()
    maven { url "https://maven.fabric.io/public" }
}

try {
    def props = new Properties()

    props.load(new FileInputStream(rootProject.file("release.properties")))

    android.signingConfigs.release.storeFile file(props.keyStore)
    android.signingConfigs.release.storePassword props.keyStorePassword
    android.signingConfigs.release.keyAlias props.keyAlias
    android.signingConfigs.release.keyPassword props.keyAliasPassword

    android.defaultConfig.manifestPlaceholders = [fabricApiKey: "$props.fabricAPIKey"]
} catch (Exception e) {
    //Dummy API Key
    android.defaultConfig.manifestPlaceholders = [fabricApiKey: "781629148259378d44601ad4b85c966bb38841eb"]
}