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

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

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


android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId "com.integreight.onesheeld"
        minSdkVersion 9
        targetSdkVersion 25
        versionCode 170521
        versionName "1.9.0"
        archivesBaseName = "1Sheeld.v$versionName.$versionCode"
        buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L"
    }

    buildTypes.all {
        ext.enableCrashlytics = isCrashlyticsPropertiesAvailable()
    }

    buildTypes {
        debug {
            versionNameSuffix getWorkingBranchSuffix()
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            minifyEnabled true
            debuggable false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    lintOptions {
        abortOnError false
    }

    useLibrary 'org.apache.http.legacy'
}

dependencies {
    compile project(':localeapi')
    compile project(':pullToRefreshlibrary')
    compile project(':quickReturnHeader')
    compile project(':pagerIndicator')
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.facebook.android:facebook-android-sdk:4.5.0'
    compile 'com.google.android.gms:play-services-analytics:10.0.1'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'com.google.android.gms:play-services-auth:10.0.1'
    compile 'com.google.android.gms:play-services-vision:10.0.1'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.snappydb:snappydb-lib:0.5.0'
    compile 'com.esotericsoftware.kryo:kryo:2.24.0'
    compile 'com.github.hotchemi:android-rate:0.5.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }

    compile('com.google.android.gms:play-services-identity:10.0.1') {
        transitive = true;
    }
    compile('com.google.api-client:google-api-client-android:1.22.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    compile('com.google.apis:google-api-services-gmail:v1-rev48-1.22.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    compile 'org.twitter4j:twitter4j-core:4.0.4'
    compile 'org.twitter4j:twitter4j-async:4.0.4'
    compile 'org.twitter4j:twitter4j-stream:4.0.4'
    compile 'cz.msebera.android:httpclient:4.4.1.1'
    compile 'net.sf.supercsv:super-csv:2.4.0'
    compile 'com.github.amlcurran.showcaseview:library:5.4.3'
    compile 'com.github.emanzanoaxa:RippleEffect:52ea2a0ab6'
    compile 'com.drewnoakes:metadata-extractor:2.8.1'
    compile 'com.integreight.onesheeld:sdk:2.2.0'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
}

def isCrashlyticsPropertiesAvailable() {
    return new File("./oneSheeld/fabric.properties").exists()
}

def getWorkingBranchSuffix() {
    def workingBranchSuffix = ""
    try {
        def workingBranch = "git --git-dir=${rootDir}/.git --work-tree=${rootDir} rev-parse --abbrev-ref HEAD".execute().text.trim()
        workingBranchSuffix = (workingBranch != "") ? " - branch:" + workingBranch : ""
    }
    catch (all) {
    }
    return workingBranchSuffix
}

def isGoogleServicesFileAvailable() {
    return new File("./oneSheeld/google-services.json").exists()
}

if (isGoogleServicesFileAvailable()) {
    apply plugin: 'com.google.gms.google-services'
}