subprojects { apply plugin: 'java' apply plugin: 'idea' // 配置Java版本 java { toolchain { languageVersion.set(JavaLanguageVersion.of(8)) // 设置 JDK 8 } } 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 // 启用增量编译 } // 任务:复制所有依赖到指定目录 tasks.register('copyAllDependencies', Copy) { description = 'Copies all runtime dependencies to the libs directory' group = 'build' // 将任务归类到构建任务组中 from(configurations.runtimeClasspath) // 使用 runtimeClasspath into("${buildDir}/libs/lib") } // 可选:启用 Gradle 缓存和并行化构建 gradle.projectsEvaluated { tasks.withType(JavaCompile).configureEach { options.fork = true // 启用编译器分叉,提高性能 } } }