apply plugin: 'com.android.application'
apply plugin: 'realm-android'


android {
    signingConfigs {
        relsease {
            storeFile file('elaWallet.jks')
            storePassword 'elaWallet'
            keyAlias = 'elaWallet'
            keyPassword 'elaWallet'
        }
    }
    flavorDimensions "default"
    productFlavors {
        applicationVariants.all { variant ->
            variant.outputs.all { output ->

                if (!variant.buildType.isDebuggable()) {
                    if (variant.flavorName == "MainNet") {
                        def fileName = "ELAWallet-${variant.versionName}"
                        outputFileName = fileName + ".apk";
                    } else {
                        def fileName = "ELAWallet-${variant.versionName}-${variant.flavorName}"
                        outputFileName = fileName + ".apk";
                    }
                } else {
                    def fileName = "ELAWallet-${variant.versionName}-${variant.flavorName}-debug"
                    outputFileName = fileName + ".apk";
                }
            }
        }

        MainNet {
            dimension "default"
            applicationId "org.elastos.unionsquare.android"
            resValue "string", "app_name", "ELA Wallet"
        }

        MainNetAlpha {
            dimension "default"
            applicationId "org.elastos.unionsquare"
            resValue "string", "app_name", "ELAAlpha"
        }

        TestNet {
            dimension "default"
            applicationId "org.elastos.unionsquare.testnet"
            resValue "string", "app_name", "ELATest"
        }
        RegTest {
            dimension "default"
            applicationId "org.elastos.unionsquare.regtest"
            resValue "string", "app_name", "ELARegTest"
        }
        PrvNet {
            dimension "default"
            applicationId "org.elastos.unionsquare.prvNet"
            resValue "string", "app_name", "ELAPrvNet"
        }
    }

    /*
     * Gets the version name from the latest Git tag
     */
    def getVersionName = { ->
        def stdout = new ByteArrayOutputStream()
        exec {
            commandLine 'git', 'describe', '--dirty', '--always', '--tags'
            standardOutput = stdout
        }

        return stdout.toString().trim()
    }

    def getCommitCount = { ->
        def stdout = new ByteArrayOutputStream()
        exec {
            commandLine 'git', 'rev-list', '--count', 'HEAD'
            standardOutput = stdout
        }
        def taskNames = gradle.startParameter.taskNames
        for (def name : taskNames) {
            if (name.toString().toLowerCase().contains('debug')) {
                return 10000
            } else {
                return stdout.toString().trim().toInteger()
            }
        }
    }

    compileSdkVersion 28
    defaultConfig {
        applicationId "org.elastos.unionsquare"
        resValue "string", "app_name", "ELAWallet"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode getCommitCount()
        versionName getVersionName()
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
        }
        externalNativeBuild {
            cmake {
                cppFlags "-Wl,--no-warn-search-mismatch"
            }
        }
        signingConfig signingConfigs.relsease
        sourceSets {
            main {
                jniLibs.srcDirs = ['src/main/jni/libs']
            }
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.relsease
        }
        debug {
            signingConfig signingConfigs.relsease
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    //implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    //retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    //rxjava2
    implementation 'io.reactivex.rxjava2:rxjava:2.1.16'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
    implementation 'com.trello.rxlifecycle2:rxlifecycle:2.1.0'
    implementation 'com.trello.rxlifecycle2:rxlifecycle-components:2.1.0'
    //dagger2
    implementation 'com.google.dagger:dagger:2.16'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.16'
    //butterknife
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    //fragmentation
    implementation 'me.yokeyword:fragmentation:1.3.8'
    implementation 'me.yokeyword:fragmentation-swipeback:1.3.8'
    //
    implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.34'
    //recyclerview
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    //cardview
    implementation 'com.android.support:cardview-v7:28.0.0'
    //utilcode
    implementation 'com.blankj:utilcode:1.25.9'
    //BottomBarLayout
    implementation 'com.github.chaychan:BottomBarLayout:1.1.2'
    //banner
    implementation 'com.youth.banner:banner:1.4.10'
    //glide
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
    //agentweb
/*    implementation 'com.just.agentweb:agentweb:4.0.2'*/
    //loadview
    implementation 'com.classic.common:multiple-status-view:1.5.1'
    //eventbus
    implementation 'org.greenrobot:eventbus:3.1.1'
    implementation 'com.qmuiteam:qmui:1.1.3'
    implementation 'com.jaeger.statusbarutil:library:1.5.1'
    /* implementation 'cn.bingoogolapple:bga-qrcode-zxing:1.3.4'*/
    implementation 'com.github.lygttpod:SuperTextView:2.2.2'
    implementation 'com.alibaba:fastjson:1.1.70.android'
    implementation 'com.github.hotchemi:permissionsdispatcher:2.3.1'
    annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:2.3.1'
    //  implementation(project(path: ":ELY"))
    implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.5.1'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.5.0'
    implementation project(':qrcodelib')
    implementation "com.github.bumptech.glide:okhttp3-integration:4.9.0"
    //bug
    //implementation 'com.tencent.bugly:crashreport:latest.release'
    //其中latest.release指代最新Bugly SDK版本号，也可以指定明确的版本号，例如2.1.9
    //implementation 'com.tencent.bugly:nativecrashreport:latest.release'
    implementation 'org.elastos.did:didsdk:1.1'
    implementation 'com.caverock:androidsvg:1.3'
    /*implementation 'io.jsonwebtoken:jjwt-api:0.11.0'
    runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.0'
    runtimeOnly('io.jsonwebtoken:jjwt-orgjson:0.11.0') {
        exclude group: 'org.json', module: 'json' //provided by Android natively
    }*/
    // Uncomment the next line if you want to use RSASSA-PSS (PS256, PS384, PS512) algorithms:
    //runtimeOnly 'org.bouncycastle:bcprov-jdk15on:1.60'

    //implementation 'com.auth0.android:jwtdecode:1.4.0'
    //implementation 'com.auth0:jwks-rsa:0.10.0'
    //implementation 'com.fasterxml.jackson.core:jackson-core:2.10.1'
    //implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.1'
}
repositories {
    mavenCentral()
}
