plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
}

apply from: '../versions.gradle'

android {
    compileSdkVersion 31
    buildToolsVersion "30.0.3"

    signingConfigs {
        myConfig {
            keyAlias 'fastcashier'
            keyPassword '123456'
            storeFile file('../fastcashier.jks')
            storePassword '123456'
        }
    }

    defaultConfig {
        applicationId "com.miya.fastcashier"
        minSdkVersion 19
        targetSdkVersion 31
        versionCode VERSION_CODE.toInteger()
        versionName VERSION_NAME.toString()
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        release {
            signingConfig signingConfigs.myConfig
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        viewBinding true
    }

    android.applicationVariants.all { variant ->

        variant.outputs.all { output ->
            outputFileName = new File(output.outputFile.parent,
                    "${getAppChannel()}" + "_v" +
                            variant.versionName + "_" +
                            variant.versionCode + "_" +
                            variant.buildType.name + "_" +
                            "${buildTime()}" +
                            ".apk"
            ).getName()
        }
    }
}

dependencies {
    implementation project(':lib_common')

    kapt 'androidx.room:room-compiler:2.4.0'
    implementation 'androidx.room:room-runtime:2.4.0'

    implementation 'com.rengwuxian.materialedittext:library:2.1.4'
    implementation 'com.github.GrenderG:Toasty:1.5.2'

    testImplementation 'junit:junit:4.+'

    implementation 'com.alibaba:fastjson:1.2.8'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'com.github.ybq:Android-SpinKit:1.4.0'
    implementation 'com.elvishew:xlog:1.10.1'

    implementation 'com.contrarywind:Android-PickerView:4.1.9'
}

static String buildTime() {
    Date date = new Date()
    String dates = date.format("yyyyMMddHHmm", TimeZone.getTimeZone("Asia/Shanghai"))
    return dates
}

String getAppChannel() {
    return project.CHANNEL
}