apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    compileOptions {
        targetCompatibility = "8"
        sourceCompatibility = "8"
    }

    defaultConfig {
        applicationId "com.v2ray.ang"
        minSdkVersion 17
        targetSdkVersion Integer.parseInt("$targetSdkVer")
        multiDexEnabled true
        versionCode 212
        versionName "1.0.2"
    }

    signingConfigs {
        release {
            storeFile file("../key.jks")
            keyAlias 'ang'
            keyPassword '123456'
            storePassword '123456'
        }
        debug {
            storeFile file("../key.jks")
            keyAlias 'ang'
            keyPassword '123456'
            storePassword '123456'
        }
    }

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

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    splits {
        abi {
            enable true
            reset()
            include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' //select ABIs to build APKs for
            universalApk true //generate an additional APK that contains all the ABIs
        }
    }

    // map for the version code
    project.ext.versionCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86': 3, 'x86_64': 4]

    android.applicationVariants.all { variant ->
        // assign different version code for each output
        variant.outputs.each { output ->
            output.versionCodeOverride =
                    project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) *
                            1000000 + android.defaultConfig.versionCode
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    implementation project(':dpreference')
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
    // Android support library
    implementation "com.android.support:support-v4:$supportLibVersion"
    implementation "com.android.support:appcompat-v7:$supportLibVersion"
    implementation "com.android.support:design:$supportLibVersion"
    implementation "com.android.support:cardview-v7:$supportLibVersion"
    implementation "com.android.support:preference-v7:$supportLibVersion"
    implementation "com.android.support:recyclerview-v7:$supportLibVersion"
    // DSL
    implementation "org.jetbrains.anko:anko-sdk15:$ankoVersion"
    implementation "org.jetbrains.anko:anko-support-v4:$ankoVersion"
    implementation "org.jetbrains.anko:anko-appcompat-v7:$ankoVersion"
    implementation "org.jetbrains.anko:anko-design:$ankoVersion"
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'io.reactivex:rxjava:1.3.4'
    implementation 'io.reactivex:rxandroid:1.2.1'
    implementation 'com.tbruyelle.rxpermissions:rxpermissions:0.9.4@aar'
    implementation 'com.dinuscxj:recycleritemdecoration:1.0.0'
    implementation 'io.reactivex:rxkotlin:0.60.0'
    implementation 'me.dm7.barcodescanner:core:1.9.8'
    implementation 'me.dm7.barcodescanner:zxing:1.9.8'
    implementation 'com.github.jorgecastilloprz:fabprogresscircle:1.01@aar'
    implementation 'com.beust:klaxon:3.0.1'
    implementation 'com.android.support:multidex:1.0.3'

    implementation(name: 'libv2ray', ext: 'aar')
    //implementation(name: 'tun2socks', ext: 'aar')
}

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.google.com' }
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlinVersion"
    }
}
repositories {
    flatDir {
        dirs 'libs'
    }
}