apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.xiaomi.mace.demo"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }

    lintOptions {
        abortOnError false
    }

    signingConfigs {
        release {
            storeFile file("mace_demo.jks")
            keyAlias "keyAlias"
            keyPassword "maceAndroid"
            storePassword "maceAndroid"
        }
        debug {
            storeFile file("mace_demo.jks")
            keyAlias "keyAlias"
            keyPassword "maceAndroid"
            storePassword "maceAndroid"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }

    flavorDimensions "mace"
    productFlavors {
        app {
            dimension "mace"
        }
    }

    sourceSets {
        main {
            jniLibs.srcDirs = ["libs"]
            jni.srcDirs = ['src/main/jni', 'src/main/jni/']
        }
    }

    applicationVariants.all { variant ->
        if (variant.buildType.name != "release") {
            return
        }
        def outputFolder = file("build/output/apk")

        variant.outputs.all {output ->
            def name = output.outputFile.name
            def newName = "Mace_" + new Date().format("yyyyMMdd_HHmm") + "_" + defaultConfig.versionName + "_" + variant.flavorName + ".apk"
            copy {
                from output.outputFile.parent
                into outputFolder
                include name
                rename(name, newName)
            }
        }
    }

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation project(':macelibrary')
    implementation 'org.greenrobot:eventbus:3.1.1'
}
