apply plugin: 'com.android.application'

repositories {
    maven() {
        url 'http://jcenter.bintray.com'
    }
}

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 29
        versionName '0.7.5 beta'
    }

    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }
    lintOptions {
        disable 'InvalidPackage'
    }

    signingConfigs {
        // can be overwritten from custom_env.gradle script
        wail {
            storeFile file('debug-keystore.jks')
            storePassword '123456'
            keyAlias '123456'
            keyPassword '123456'
        }
    }

    buildTypes {
        // A build signed with debug keys.
        // Not using proguard, it's fast to package.
        fast_debug {
            versionNameSuffix ' debug ' + getDateForVersionName()
            signingConfig signingConfigs.wail
            // Gradle defaults to debuggable=false for variants other than "debug".
            debuggable true
        }
        // A build signed with debug keys.
        // Using proguard, it's slower to package.
        debug {
            versionNameSuffix ' debug ' + getDateForVersionName()
            signingConfig signingConfigs.wail
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
        }
        // A build signed with release keys.
        // Using proguard for code optimization and reducing the apk size.
        release {
            signingConfig signingConfigs.wail
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
        }
    }

    // for applying custom environment properties
    if (new File('wail-app/custom_env.gradle').exists()) {
        apply from: 'custom_env.gradle'
    }
}

dependencies {
    // NOTICE, libraries versions are FIXED for stability
    // because gradle can automatically load newer version which can add bugs and have to be tested
    def support_version = ':22.2.0'
    compile 'com.android.support:support-v13' + support_version
    compile 'com.android.support:support-v4' + support_version
    compile 'com.android.support:appcompat-v7' + support_version
    compile 'com.android.support:cardview-v7' + support_version
    compile 'com.melnykov:floatingactionbutton:1.1.0'
    compile 'com.rengwuxian.materialedittext:library:1.7.1'
    compile 'com.afollestad:material-dialogs:0.7.6.0'
    compile 'com.jakewharton:butterknife:5.1.2'

    compile fileTree(dir: 'libs', include: '*.jar')
}

def getDateForVersionName() {
    return new Date().format('yyyy.MM.dd HH:mm:ss');
}
