apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 22
        versionName project.VERSION_NAME
        versionCode Integer.parseInt(project.VERSION_CODE)

        //testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
    }

    signingConfigs {
        release
    }

    buildTypes {
        if (isReleaseBuild()) {
            release {
                signingConfig signingConfigs.release
            }
        }

        debug {
            applicationIdSuffix ".debug"
            versionNameSuffix "-debug"
        }
    }

    // This is important, it will run lint checks but won't abort build
    lintOptions {
        abortOnError false
    }
}

dependencies {
    // Cards Library
    compile project(':library-core')
    compile project(':library-cards')
    compile project(':library-recyclerview')
    // Support Libraries
    compile 'com.android.support:support-v4:22.1.1'
    compile 'com.android.support:appcompat-v7:22.1.1'

    //androidTestCompile 'com.jakewharton.espresso:espresso:1.1-r2'
}


def Properties props = new Properties()
def propFile = file('../../signing.properties')
if (propFile.canRead()){
    props.load(new FileInputStream(propFile))

    if (props!=null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
            props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {

        println 'RELEASE BUILD SIGNING'

        android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
        android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
        android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
        android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
    } else {
        println 'RELEASE BUILD NOT FOUND SIGNING PROPERTIES'

        android.buildTypes.release.signingConfig = null
    }
}else {
    println 'RELEASE BUILD NOT FOUND SIGNING FILE'
    android.buildTypes.release.signingConfig = null
}