apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    applicationVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "${parent.name}-${variant.name}-${variant.versionName}.apk"
        }
    }

    defaultConfig {
        versionName "2.3.7"
        versionCode = 22
        minSdkVersion 21
        targetSdkVersion 25
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        resConfigs "en"
    }
    signingConfigs {
        release
    }
    buildTypes {
        debug {
            minifyEnabled true
            shrinkResources true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard/proguard-project.pro',
                    'proguard/proguard-google-play-services.pro'
        }
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            shrinkResources true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    getDefaultProguardFile('proguard-android-optimize.txt'),
                    'proguard/proguard-project.pro',
                    'proguard/proguard-google-play-services.pro'
        }
    }
    flavorDimensions "release", "default"
    /*productFlavors {
        free {
            applicationId "com.gigabytedevelopersinc.app.explorer"
            dimension "default"
        }
        pro {
            applicationId "com.gigabytedevelopersinc.app.explorer.pro"
            dimension "default"
        }
        underground {
            applicationId "com.gigabytedevelopersinc.app.explorer.underground"
            dimension "default"
        }
        fdroid {
            applicationId "com.gigabytedevelopersinc.app.explorer"
            dimension "default"
            //ext.enableCrashlytics = false
        }
        google {
            dimension "release"
        }
        amazon {
            dimension "release"
        }
        other {
            dimension "release"
        }
    }*/
    variantFilter { variant ->
        def names = variant.flavors*.name

        if (names.contains("underground") && (names.contains("google") || names.contains("other"))) {
            variant.ignore = true
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/spring.schemas'
        exclude 'META-INF/spring.tooling'
        exclude 'META-INF/spring.handlers'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/INDEX.LIST'
    }
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
    aaptOptions {
        noCompress 'apk'
    }
}

ext {
    supportLibVersion = '27.0.2'
    gmsVersion = '11.8.0'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.jaredrummler:android-processes:1.1.1'
    implementation 'com.github.mjdev:libaums:0.5.5'
    implementation 'org.apache.ftpserver:ftpserver-core:1.1.1'
    implementation 'commons-net:commons-net:3.6'
    implementation 'com.cloudrail:cloudrail-si-android:2.20.0'
    implementation "com.android.support:appcompat-v7:${supportLibVersion}"
    implementation "com.android.support:cardview-v7:${supportLibVersion}"
    implementation "com.android.support:design:${supportLibVersion}"
    implementation "com.android.support:exifinterface:${supportLibVersion}"
    //freeImplementation "com.google.firebase:firebase-crash:${gmsVersion}"
    implementation ('com.crashlytics.sdk.android:crashlytics:2.9.0@aar') {
        transitive = true
    }
    implementation "com.google.firebase:firebase-core:${gmsVersion}"
    implementation "com.google.firebase:firebase-ads:${gmsVersion}"

    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.3'
}

/* def props = new Properties()
props.load(new FileInputStream(rootProject.file("keystore.properties")))
android.signingConfigs.release.storeFile rootProject.file(props.keyStore)
android.signingConfigs.release.storePassword props.keyStorePassword
android.signingConfigs.release.keyAlias props.keyAlias
android.signingConfigs.release.keyPassword props.keyAliasPassword */

/*if (getGradle().getStartParameter().getTaskRequests().toString().contains("Free")) {
    apply plugin: 'com.google.gms.google-services'
}*/

apply plugin: 'com.google.gms.google-services'