apply plugin: 'com.android.application'
apply plugin: 'io.fabric'// Firebase Crashlytics

// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file("keystore.properties")

// Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()

// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

def todayDate = new Date().format("yyyyMMdd")
def buildNumber = "01"
def buildStep = "sp01"

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "kr.co.hanwha.hifive"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName '1.4.6'
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

        buildConfigField "String", "REVISION", "\"${todayDate}${buildNumber}\""
        buildConfigField "String", "RC", "\"${buildStep}\""

        buildConfigField "String", "WEB_REAL_URL", "\"https://qtalk.dreamplus.center/newgw/b/v2\""
        buildConfigField "String", "WEB_DEV_URL", "\"https://qtalk-dev.dreamplus.center/newgw/b/v2\""
        buildConfigField "String", "WEB_LOCAL_URL", "\"http://192.168.0.27:38999/b/v2\""

        buildConfigField "String", "REAL_URL", "\"https://qtalk.dreamplus.center/newgw/a/v2\""
        buildConfigField "String", "DEV_URL", "\"https://qtalk-dev.dreamplus.center/newgw/a/v2\""
        buildConfigField "String", "LOCAL_URL", "\"http://192.168.0.38:38999/a/v2\""

        buildConfigField "String", "DOWNLOAD_URL", "\"http://qtalk.dreamplus.center/downloads/\""
    }
    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
            v1SigningEnabled true
            v2SigningEnabled true
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
            buildConfigField "String", "SERVER_TYPE", "\"REAL\""
            buildConfigField "int", "BUILD_NUMBER", "01"
            buildConfigField "String", "HF_KEY_GA_LOG_EVENT", "\"HF_REAL_EVENT\""
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "String", "SERVER_TYPE", "\"DEV\""
            buildConfigField "int", "BUILD_NUMBER", "01"
            buildConfigField "String", "HF_KEY_GA_LOG_EVENT", "\"HF_EVENT\""
        }
    }
}

android.applicationVariants.all { variant ->
    variant.outputs.all {
        def buildName = variant.buildType.name=="debug"?"dev":"prd"
//        def buildNumber = variant.buildType.buildConfigFields.get("BUILD_NUMBER").value
        outputFileName = "HIFIVE_${buildName}_v.${variant.versionName}_rv_${todayDate}${buildNumber}.apk"
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //    implementation 'com.android.support:appcompat-v7:26.1.0'
    //    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    implementation 'com.google.firebase:firebase-core:11.8.0'
    /**
     * Test Unit
     */
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    //    compile 'com.android.support:design:26.1.0'
    /**
     * Network
     */
    implementation 'com.squareup.okhttp3:okhttp:3.7.0'
    /**
     * Json
     */
    implementation 'com.google.code.gson:gson:2.8.1'
    /**
     * Support
     */
    releaseImplementation('com.crashlytics.sdk.android:crashlytics:2.7.0-SNAPSHOT@aar') {
// Firebase Crashlytics
        transitive = true
    }
    /**
     * 이미지 로더
     */
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    /**
     * Logger
     */
    implementation 'com.jakewharton.timber:timber:4.7.1'
}


apply plugin: 'com.google.gms.google-services'
