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 "de.beyondsoft.ownchat"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    signingConfigs {
        release {
            storeFile file('../ownChat.jks')
            storePassword 'jlzvnz9e4ur3gfk6hwsw'
            keyAlias 'ownChatKey'
            keyPassword '6fhnfqm07tvbagm3t6k4'
        }
    }
    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'
    })
    // Android support libraries
    // Butter Knife
    // Dagger
    // Rx Java
    // Retrofit
    // OkHttp
    // Glide
    // Circle ImageView
    compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
        transitive = true;
    }
    // Secure Preferences
    // Firebase
    // emojis
    // circle progress
    // event bus
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'com.android.support:design:25.3.0'
    compile 'com.jakewharton:butterknife:8.4.0'
    compile 'com.google.dagger:dagger:2.7'
    compile 'io.reactivex:rxjava:1.1.6'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'
    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'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.scottyab:secure-preferences-lib:0.1.4'
    compile 'com.google.firebase:firebase-messaging:10.2.0'
    compile 'hani.momanii.supernova_emoji_library:supernova-emoji-library:0.0.2'
    compile 'com.github.lzyzsd:circleprogress:1.2.1'
    compile 'org.greenrobot:eventbus:3.0.0'
    testCompile 'junit:junit:4.12'
    apt 'com.jakewharton:butterknife-compiler:8.4.0'
    apt 'com.google.dagger:dagger-compiler:2.7'
    provided 'javax.annotation:jsr250-api:1.0'
}

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

    ext {
        channel = "bewoplaner-chat"
        slug = "bewoplaner-chat"
        versionCode = rootProject.versionCode
        identifier = "de.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'