// SunnyBeach-Kotlin 版本
// 导入配置文件
apply from: 'configs.gradle'

buildscript {

    // 导入通用的 Maven 库配置
    apply from: 'maven.gradle'

    ext.kotlin_version = "1.9.22"
    ext.agcp_version = "1.9.1.303"
    ext.hilt_version = "2.47"
    ext.android_aop_version = "1.4.7"

    repositories {
        // 阿里云云效仓库（Gradle 插件）：https://maven.aliyun.com/mvn/guide
        // 可能会出现编译错误：Could not find android-aop-plugin-1.4.0.jar (io.github.FlyJingFish.AndroidAop:android-aop-plugin:1.4.0)
        // maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        maven { url 'https://mirrors.cloud.tencent.com/gradle/' }
        // maven { url 'https://services.gradle.org/distributions/' }
        addCommonMaven(repositories)
    }

    // Studio 插件推荐：https://github.com/getActivity/StudioPlugins
    dependencies {
        // Gradle 插件版本说明：https://developer.android.google.cn/studio/releases/gradle-plugin.html#updating-plugin
        classpath 'com.android.tools.build:gradle:8.6.1'
        // Kotlin 插件：https://plugins.jetbrains.com/plugin/6954-kotlin
        // noinspection GradleDependency
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:1.9.22-1.0.17"
        classpath "io.github.FlyJingFish.AndroidAop:android-aop-plugin:${android_aop_version}"
        // 增加agcp插件配置
        classpath "com.huawei.agconnect:agcp:$agcp_version"
        classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
    }
}

allprojects {

    repositories {
        // 友盟远程仓库：https://info.umeng.com/detail?id=443&cateId=1
        maven { url 'https://repo1.maven.org/maven2' }
        addCommonMaven(repositories)
    }

    tasks.withType(JavaCompile).configureEach {
        // 设置全局编码
        options.encoding = 'UTF-8'
    }
    tasks.withType(Javadoc).configureEach {
        // 设置文档编码
        options {
            encoding 'UTF-8'
            charSet 'UTF-8'
            links 'http://docs.oracle.com/javase/7/docs/api'
        }
    }

    // 将构建文件统一输出到项目根目录下的 build 文件夹
    layout.buildDirectory.set(file("$rootDir/build/${path.replace(':', '/')}"))
}

tasks.register('clean', Delete) {
    delete rootProject.layout.buildDirectory
}