buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}
repositories {
    mavenCentral()
    jcenter()
    maven { url "https://www.jitpack.io" }
    maven { url "http://dl.bintray.com/piasy/maven" }
}
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

def dbflow_version = "4.0.0-beta2"
def ciName = isEmpty(System.getenv("TRAVIS_TAG")) ? "Staging" : System.getenv("TRAVIS_TAG")
def ciCode = isEmpty(System.getenv("TRAVIS_BUILD_NUMBER")) ? 1000 : Integer.valueOf(System.getenv("TRAVIS_BUILD_NUMBER"))
def buglyPrdKey = isEmpty(System.getenv('BUGLY_PRD')) ? "" : System.getenv('BUGLY_PRD')
def isEmpty(String str) {
    return str == null || "".equals(str);
}

android {
    signingConfigs {
        config {
            keyAlias System.getenv('KEY_ALIAS')
            keyPassword System.getenv('KEY_PWD')
            storeFile file(projectDir.parentFile.absolutePath + '/houxg-leamonax.jks')
            storePassword System.getenv('KEYSTORE_PWD')
        }
    }
    compileSdkVersion 24
    buildToolsVersion "25.0.1"
    defaultConfig {
        applicationId "org.houxg.leamonax"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode ciCode
        versionName ciName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    lintOptions {
        abortOnError false
    }

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

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
            buildConfigField "String", "BUGLY_KEY", String.format("\"%s\"", buglyPrdKey)
        }
    }

    buildTypes.each { buildType ->
        def properties = new Properties();
        if (buildType.isDebuggable()) {
            properties.load(new FileInputStream(new File(projectDir.absolutePath + "/staging.properties")))
            buildType.buildConfigField "String", "BUGLY_KEY", properties['BUGLY_KEY']
        }
    }
}


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

    compile 'com.jakewharton:butterknife:8.4.0'
    apt 'com.jakewharton:butterknife-compiler:8.4.0'

    compile group: 'com.squareup.okhttp3', name: 'logging-interceptor', version: '3.4.1'
    compile group: 'com.squareup.retrofit2', name: 'adapter-rxjava', version: '2.1.0'

    apt "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"
    compile "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}"
    compile "com.github.Raizlabs.DBFlow:dbflow:${dbflow_version}"

    compile 'org.greenrobot:eventbus:3.0.0'

    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'io.reactivex:rxjava:1.1.9'
    compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
    compile 'org.mongodb:mongo-java-driver:2.12.4'

    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'jp.wasabeef:glide-transformations:2.0.1'
    compile 'com.android.support:support-v13:24.1.0'
    compile 'com.yuyh.imgsel:library:1.3.2'
    compile 'com.facebook.stetho:stetho:1.4.1'
    compile 'com.github.houxg:FlexLayout:1.2'

    compile 'net.danlew:android.joda:2.9.5'
    compile group: 'com.tencent.bugly', name: 'crashreport_upgrade', version: '1.2.1'
    compile 'com.elvishew:xlog:1.3.0'
    compile 'com.github.piasy:BigImageViewer:1.2.5'
    compile 'com.github.piasy:GlideImageLoader:1.2.5'
}
