plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'kotlin-parcelize'
    id 'androidx.navigation.safeargs.kotlin'
    id 'org.jetbrains.kotlin.android'
    id 'com.google.devtools.ksp'
    id "io.sentry.android.gradle" version "5.3.0"
}
android {
    namespace 'com.hao.heji'
    compileSdk 35
    defaultConfig {
        applicationId "com.hao.heji"
        minSdk 24
        targetSdk 35
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [
                        "room.schemaLocation"  : "$projectDir/schemas".toString(),
                        "room.incremental"     : "true",
                        "room.expandProjection": "true"]
            }
        }

    }
    signingConfigs {
        single {
            storeFile file('..//heji.keystore')
            storePassword 'password'
            keyPassword 'password'
            keyAlias 'heji'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.single
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        release {
            signingConfig signingConfigs.single
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    // For Kotlin projects
    kotlinOptions {
        jvmTarget = "1.8"
    }
    buildFeatures {
        viewBinding true
        buildConfig = true
    }
    flavorDimensions = ["network"]

    productFlavors {
        local {
            dimension "network"
            applicationId "com.hao.heji_test"
            buildConfigField 'String', 'HTTP_URL', LOCALHOST
            resValue "string", "app_name", "合記开发版"
        }
        cloud {
            dimension "network"
            applicationId "com.hao.heji"
            buildConfigField 'String', 'HTTP_URL', HJSERVER
            resValue "string", "app_name", "合記"
        }
    }

    applicationVariants.configureEach { variant ->
        variant.outputs.configureEach {
            def time = new Date().format("yyyyMMddHHmm", TimeZone.getTimeZone("GMT+08:00"))
            def productFlavors = variant.productFlavors[0].name
            def buildTypes = variant.buildType.name
            def versionName = variant.versionName
            def gitVersion = 'git rev-parse --short HEAD'.execute().text.trim()
            outputFileName = "${productFlavors}-${buildTypes}-${versionName}-${gitVersion}-${time}.apk"
            //产品维度-产品类型-构建类型-版本号-git commit id-打包时间-后缀名
            print(outputFileName)
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    //implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
    implementation 'androidx.appcompat:appcompat:1.7.0'
    implementation 'com.google.android.material:material:1.12.0'
    implementation "androidx.constraintlayout:constraintlayout:2.2.1"
    implementation 'androidx.annotation:annotation:1.9.1'
    implementation "androidx.recyclerview:recyclerview:1.4.0"
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.datastore:datastore-core:1.1.4'

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.2.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'

    //navigation kotlin language implementation
    implementation 'androidx.navigation:navigation-fragment-ktx:2.8.9'
    implementation 'androidx.navigation:navigation-ui-ktx:2.8.9'

    // (work Java only)
    implementation 'androidx.work:work-runtime:2.10.0'

    implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.6'

    def retrofit ="2.9.0"
    //implementation "com.squareup.retrofit2:converter-gson:$rootProject.retrofit"
    implementation "com.squareup.retrofit2:converter-moshi:$retrofit"
    implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.8'
    //图片加载
    //annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
    ksp 'com.github.bumptech.glide:ksp:4.14.2'
    //implementation 'com.squareup.okhttp3:okhttp:3.12.0'
    implementation 'com.github.bumptech.glide:glide:4.15.1'
    implementation 'com.github.bumptech.glide:okhttp3-integration:4.15.1'
    //implementation 'com.zhihu.android:matisse:0.5.3-beta3'
    implementation 'com.github.lwj1994:Matisse:0.5.3-20220115'
    //implementation 'com.github.bumptech.glide:glide:4.11.0'
    //更人性化的权限
    implementation 'com.guolindev.permissionx:permissionx:1.8.0'
    //cardview
    implementation "androidx.cardview:cardview:1.0.0"
    // Kotlin
    implementation('androidx.core:core-ktx:1.15.0')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.20"
    //Lifecycles livedata  viewmodel
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.8.7"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.8.7"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7"
    //---------room-------------
    def room_version = "2.6.1"
    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"
    implementation "androidx.room:room-ktx:$room_version"
    ksp "androidx.room:room-compiler:$room_version"
    //ksp("androidx.room:room-compiler:$room_version")

    //spinner
    //implementation 'com.github.arcadefire:nice-spinner:1.4.4'
    //工具框架
    implementation 'com.blankj:utilcodex:1.31.1'
    //xpopup
    implementation 'com.github.li-xiaojun:XPopup:2.10.0'
    //日历
    implementation 'com.github.angcyo:CalendarView:3.7.1.37'
    // preferences  datastore
    implementation "androidx.datastore:datastore-preferences:1.1.4"
    //图表统计
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
    //---Toolbaer 工具
// 基础依赖包，必须要依赖
    implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2'
// kotlin扩展（可选）
    implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.2'

    implementation('com.squareup.moshi:moshi-kotlin:1.15.1')
    implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
    //database debug test
    debugImplementation 'com.guolindev.glance:glance:1.1.0'
    //excel
    implementation 'net.sourceforge.jexcelapi:jxl:2.6.12'
    implementation 'com.opencsv:opencsv:5.7.1'
    implementation 'com.google.protobuf:protobuf-java:3.24.4'
    implementation 'com.google.protobuf:protoc:3.24.4'
}
