apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply plugin: 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'

android {
    compileSdkVersion 35
    buildToolsVersion "33.0.3"
    namespace "com.igo.user"
    //签名
    signingConfigs {
        release {
            storeFile file("gopost_user.jks")
            storePassword "gopost"
            keyAlias "gopost"
            keyPassword "gopost"
        }
    }

    defaultConfig {
        applicationId "com.gopost.user"
        minSdkVersion 23
        targetSdkVersion 35
        versionCode 15
        versionName "1.15"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

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

    compileOptions {
        // Flag to enable support for the new language APIs
        coreLibraryDesugaringEnabled true
        // Sets Java compatibility to Java 8
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = "17"  // 与上面保持一致
    }

    //netty 必须屏蔽这几个文件
    packagingOptions {
        jniLibs {
            useLegacyPackaging true
        }
        exclude 'META-INF/NOTICE' // will not include NOTICE file
        exclude 'META-INF/LICENSE' // will not include LICENSE file
        //netty files
        exclude 'META-INF/INDEX.LIST' // will not include this file
        exclude 'META-INF/io.netty.versions.properties' // will not include this file
    }

    buildFeatures {
        viewBinding true
        buildConfig = true  // 显式启用 BuildConfig
    }

}
// 在文件末尾添加
afterEvaluate {
    android.applicationVariants.all { variant ->
        def variantName = variant.name
        // 找到对应变体的bundle任务
        def bundleTask = tasks.findByName("bundle${variantName.capitalize()}")
        if (bundleTask != null) {
            bundleTask.doLast {
                // 输出目录
                def outputDir = file("${rootDir}/app/${variantName}/")
                if (outputDir.exists()) {
                    outputDir.listFiles().each { file ->
                        if (file.name.endsWith('.aab')) {
                            // 获取当前时间戳
                            def timestamp = new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("GMT+08"))

                            // 构建新的文件名
                            def newName = file.name.replace("app-${variantName}", "GoPost_user-${variant.versionName}-${variant.buildType.name}-${timestamp}")

                            // 重命名文件
                            def newFile = new File(file.parentFile, newName)

                            if (file.renameTo(newFile)) {
                                println "✅ 文件重命名成功: ${file.name} -> ${newFile.name}"
                                println "📁 文件路径: ${newFile.absolutePath}"
                            } else {
                                println "❌ 文件重命名失败: ${file.name}"
                            }
                        }
                    }
                } else {
                    println "⚠️ 目录不存在: ${outputDir.absolutePath}"
                }
            }
        }
        // 找到对应变体的package任务
        def packageTask = tasks.findByName("package${variantName.capitalize()}")
        if (packageTask != null) {
            packageTask.doLast {
                // 输出目录
                def outputDir = file("${rootDir}/app/${variantName}/")
                if (outputDir.exists()) {
                    outputDir.listFiles().each { file ->
                        if (file.name.endsWith('.apk')) {
                            // 获取当前时间戳
                            def timestamp = new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("GMT+08"))

                            // 构建新的文件名
                            def newName = file.name.replace("app-${variantName}", "GoPost_user-${variant.versionName}-${variant.buildType.name}-${timestamp}")

                            // 重命名文件
                            def newFile = new File(file.parentFile, newName)

                            if (file.renameTo(newFile)) {
                                println "✅ 文件重命名成功: ${file.name} -> ${newFile.name}"
                                println "📁 文件路径: ${newFile.absolutePath}"
                            } else {
                                println "❌ 文件重命名失败: ${file.name}"
                            }
                        }
                    }
                } else {
                    println "⚠️ 目录不存在: ${outputDir.absolutePath}"
                }
            }
        }
    }
}
repositories {
    flatDir {
        dirs 'libs'
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    api "androidx.appcompat:appcompat:$support_version"
    implementation 'androidx.core:core-ktx:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1")
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.activity:activity:1.8.0'
    implementation("androidx.activity:activity-ktx:1.7.2")
    implementation 'com.google.android.gms:play-services-recaptcha:17.1.0'
    testImplementation 'junit:junit:4.12'
    //  androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    // androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation project(path: ':xldutils-kotlin')
    implementation 'com.google.android.material:material:1.3.0-alpha01'
    implementation project(path: ':rxnetty')
//    implementation project(path: ':umeng_sdk')
    implementation 'com.youth.banner:banner:2.0.11'
    implementation 'com.github.promeg:tinypinyin:2.0.3'
    implementation 'top.zibin:Luban:1.1.8'
    implementation 'com.aliyun.dpa:oss-android-sdk:2.9.3'
    implementation "com.daimajia.swipelayout:library:1.2.0@aar"
    implementation 'cn.bingoogolapple:bga-qrcode-zxing:1.3.7'//二维码
    implementation 'com.haibin:calendarview:3.6.9'//日历
    implementation project(path: ':download')
    implementation 'com.google.android.libraries.places:places:2.7.0'
    implementation 'com.facebook.android:facebook-share:12.2.0' //脸书分享
    implementation 'com.facebook.android:facebook-login:12.2.0' //脸书登录
    implementation 'com.twitter.sdk.android:twitter:3.1.1'
    implementation 'org.greenrobot:eventbus:3.1.1'


    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs_nio:2.0.3'

    //谷歌地图和乘客端sdk
    implementation 'com.google.android.gms:play-services-maps:18.1.0'
    implementation 'com.google.android.libraries.mapsplatform.transportation:transportation-consumer:3.0.0'


    implementation 'com.github.bumptech.glide:glide:4.9.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'

    implementation 'com.tencent.mm.opensdk:wechat-sdk-android:6.8.34' //微信官方依赖库

}
