apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"
    defaultConfig {
        //FIXME: Change application name as your requirement
        manifestPlaceholders = [applicationName: "Odoo by Eiru"]
        //FIXME: Please change the application id as your requirement
        applicationId "com.eiru.odoo"
        minSdkVersion 14
        targetSdkVersion 24
        versionCode 6
        versionName "2.2.0"
        multiDexEnabled true
    }
    dexOptions {
        javaMaxHeapSize "2g"
    }
    buildTypes {
        release {
            minifyEnabled false
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:cardview-v7:24.0.0'
    compile 'com.google.android.gms:play-services:9.0.2'
    compile 'com.android.support:design:24.0.0'
    compile project(':intro-slider-lib')
    compile project(':odoo-rpc-v3')
}

/**
 * Application Package checker.
 * Required to change application Id 'com.odoo' and application name 'Odoo'
 */
task compilePreCheck(dependsOn: build) {
    if (project.getProperty("checkForPackageName") == "true") {
        def testId = project.getProperty("appId")
        def testName = project.getProperty("appName")
        def packageWarning = "Application name and Application id must be different than '$testId' and '$testName'.\n\n " +
                "Please change your Application Id and Application name in app/build.gradle\n" +
                "Thank You.\n Odoo Mobile Team"
        def applicationId = android.defaultConfig.getProperty("applicationId")
        def applicationName = android.defaultConfig.manifestPlaceholders.get("applicationName")
        println "Odoo Mobile : Pre checking package and application name"
        print "Current Application Id   : $applicationId"
        print "Current Application Name : $applicationName"
        if (applicationId == testId || applicationName == testName) {
            throw new StopExecutionException(packageWarning)
        }
    }
}
