def getGitSha() {
    return 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim();
}

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url "https://dl.bintray.com/hani-momanii/maven" }
    maven { url "https://jitpack.io" }
}

apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'realm-android'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.p3.bewoplanner"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    signingConfigs {
        release {
            storeFile file('../keystore.jks')
            storePassword 'Qva/F637QEDfM)Z]'
            keyAlias 'bewoplaner-chat'
            keyPassword 'q7vWk(V&R6+NVjvg'
        }
    }

    buildTypes {
        debug {
            ext.enableCrashlytics = false
        }
        release {
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "String", "GIT_VERSION_SHA", "\"" + getGitSha() + "\""
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    lintOptions {
        abortOnError false
        disable 'InvalidPackage'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'

    // Android support libraries
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'com.android.support:design:25.3.0'

    // Butter Knife
    compile 'com.jakewharton:butterknife:8.4.0'
    apt 'com.jakewharton:butterknife-compiler:8.4.0'

    // Dagger
    compile 'com.google.dagger:dagger:2.7'
    apt 'com.google.dagger:dagger-compiler:2.7'
    provided 'javax.annotation:jsr250-api:1.0'

    // Rx Java
    compile 'io.reactivex:rxjava:1.1.6'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'

    // Retrofit
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'

    // OkHttp
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'

    // Glide
    compile 'com.github.bumptech.glide:glide:3.7.0'

    // Circle ImageView
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
        transitive = true;
    }

    // Secure Preferences
    compile 'com.scottyab:secure-preferences-lib:0.1.4'

    // Firebase
    compile 'com.google.firebase:firebase-messaging:10.2.0'

    // emojis
    compile 'hani.momanii.supernova_emoji_library:supernova-emoji-library:0.0.2'

    // circle progress
    compile 'com.github.lzyzsd:circleprogress:1.2.1'

    // event bus
    compile 'org.greenrobot:eventbus:3.0.0'
}

task adp2upload(type: Exec, dependsOn: "build") {

    ext {
        channel = "bewoplaner-chat"
        slug = "bewoplaner-chat"
        versionCode = rootProject.versionCode
        identifier = "com.p3.bewoplaner"
        file = "build/outputs/apk/app-release.apk"
        notes = "Nightly build for BeWoPlaner Chat"
    }
    commandLine 'upload_build.sh', "-c", "$channel", "-v", "$versionCode", "-p", "android", "-a", "$slug", "-f", "$file", "-i", "$identifier", "-n", "$notes"
}
apply plugin: 'com.google.gms.google-services'