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

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

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

    // 排除不必要的依赖,恢复配置
//    configurations {
//        all {
//            exclude group: 'ch.qos.logback'
//        }
//    }

    // 配置编译选项
    tasks.withType(JavaCompile).configureEach {
        options.encoding = 'UTF-8'
    }

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