apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'
apply plugin: 'com.jakewharton.butterknife'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    defaultConfig {
        applicationId "com.freddy.kulachat"
        minSdkVersion 24
        targetSdkVersion 29
        versionCode 1
        versionName "0.1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    signingConfigs {
        release {
            keyAlias("KulaChat")
            keyPassword("1088299709")
            storeFile file("../kula_chat.jks")
            storePassword("1088299709")
        }

        debug {
            keyAlias("KulaChat")
            keyPassword("1088299709")
            storeFile file("../kula_chat.jks")
            storePassword("1088299709")
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            buildConfigField("boolean", "LOG_DEBUG", "false")
            buildConfigField("String", "SERVER_URL", "\"http://192.168.0.93:8088/\"")
            signingConfig signingConfigs.release
        }

        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            buildConfigField("boolean", "LOG_DEBUG", "true")
            buildConfigField("String", "SERVER_URL", "\"http://192.168.0.93:8088/\"")
            signingConfig signingConfigs.debug
        }
    }

    sourceSets {
        main {
            res.srcDirs = [
                    "src/main/res/layouts/common",
                    "src/main/res/layouts/main",
                    "src/main/res/layouts/home",
                    "src/main/res/layouts/user",
                    "src/main/res/layouts/chat",
                    "src/main/res/layouts/widget",
                    "src/main/res/layouts",
                    "src/main/res"
            ]
            jniLibs.srcDirs = ['libs']
        }
    }

    android.applicationVariants.all { variant ->
        variant.outputs.all { output ->
            def outputFile = output.outputFile
            def date = new Date().format("yyyyMMddHHmm")
            project.logger.debug("outputFile = ${outputFile}")
            project.logger.debug("buildTypeName = ${variant.buildType.name}")
            if (outputFile != null && outputFile.name.endsWith('.apk')) {
                def buildType
                if (variant.buildType.name == "release") {
                    buildType = "release"
                } else if (variant.buildType.name == "debug") {
                    buildType = "debug"
                }
                if (buildType != null) {
                    outputFileName = "KulaChat_v${project.android.defaultConfig.versionName}.${project.android.defaultConfig.versionCode}_${buildType}_${date}.apk"
                }
            }
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

greendao {
    schemaVersion 1// 数据库版本号
    daoPackage "${project.android.defaultConfig.applicationId}.database.greendao"// 设置包名
    targetGenDir 'src/main/java'
    // targetGenDirTest：设置生成单元测试目录
    // generateTests：设置自动生成单元测试用例
}

//configurations.all {
//    resolutionStrategy.dependencySubstitution {
//        substitute module("io.reactivex.rxjava2:rxjava") with module("io.reactivex.rxjava3:rxjava:3.0.7")
//    }
//}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'io.reactivex.rxjava3:rxjava:3.0.7'
    implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.github.akarnokd:rxjava3-retrofit-adapter:3.0.0'
    implementation 'org.greenrobot:greendao:3.3.0'

    def dagger_version = "2.27"
    implementation "com.google.dagger:dagger:$dagger_version"
    implementation "com.google.dagger:dagger-android:$dagger_version"
    implementation "com.google.dagger:dagger-android-support:$dagger_version"
    annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
    annotationProcessor "com.google.dagger:dagger-android-processor:$dagger_version"

    implementation 'com.jakewharton:butterknife:10.2.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
    implementation('com.jaeger.statusbarutil:library:1.5.1') {
        exclude group: 'com.google.android.material', module: 'material'
    }
    implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4'
    implementation 'me.jessyan:autosize:1.2.1'
    implementation 'com.alibaba:fastjson:1.1.71.android'
    implementation 'com.github.ihsanbal:LoggingInterceptor:3.1.0-rc5'
    implementation 'com.github.tbruyelle:rxpermissions:0.12'
    implementation 'com.github.GrenderG:Toasty:1.4.2'
    implementation 'com.noober.background:core:1.6.5'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.viewpager2:viewpager2:1.0.0'
    implementation 'com.freddy:eventcenter_lib:1.0.1'
    implementation 'com.github.SheHuan:NiceImageView:1.0.5'
    implementation 'com.github.yijiebuyi:3DWheelPicker:v1.1.0'
    implementation 'com.aliyun.dpa:oss-android-sdk:2.9.4'
    debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
    implementation project(':ims_kula')
}
