subprojects {
    apply plugin: 'java'
    apply plugin: 'idea'

    // 配置Java版本
    java {
        toolchain {
            languageVersion.set(JavaLanguageVersion.of(23))  // 设置 JDK 23
        }
    }

    repositories {
        // 优先使用本地 Maven 缓存
        mavenLocal()
        // 阿里云公共仓库
        maven { url "https://maven.aliyun.com/repository/public" }
        // 阿里云 Gradle 插件仓库
        maven { url "https://maven.aliyun.com/repository/gradle-plugin" }
        // 官方仓库作为备用
        mavenCentral()
    }

    // 配置编译选项
    tasks.withType(JavaCompile).configureEach {
        options.encoding = 'UTF-8'
        options.incremental = true // 启用增量编译
//        options.compilerArgs += ['-Xlint:unchecked', '-Xlint:deprecation']
    }

    // 复制依赖任务,使用更现代的 `runtimeClasspath`
    task copyAllDependencies(type: Copy) {
        from configurations.runtimeClasspath
        into "${buildDir}/libs/lib"
    }
}