Files
wushu/android/build.gradle.kts
2026-04-02 07:06:55 +08:00

111 lines
2.9 KiB
Kotlin

import org.gradle.api.JavaVersion
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.AppExtension
allprojects {
repositories {
google()
mavenCentral()
}
}
allprojects {
buildscript {
repositories {
google()
mavenCentral()
}
}
}
allprojects {
configurations.all {
resolutionStrategy.eachDependency {
if (requested.group == "org.ow2.asm" && requested.name == "asm-util") {
useVersion("9.6")
because("jcenter is deprecated, using mavenCentral version")
}
}
}
}
// 统一设置 JVM 版本
allprojects {
tasks.withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "17"
}
}
}
// 为所有子项目(包括依赖的模块)设置统一的 JVM 目标版本
subprojects {
tasks.withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "17"
}
}
}
// 为所有模块设置统一的 JVM 目标版本
subprojects {
afterEvaluate {
// 为 Java 编译任务设置 JVM 版本
tasks.withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
}
// 为 Kotlin 编译任务设置 JVM 版本
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "17"
}
}
// 为 Android 模块设置编译选项
if (plugins.hasPlugin("com.android.library") || plugins.hasPlugin("com.android.application")) {
extensions.findByType<com.android.build.gradle.LibraryExtension>()?.apply {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
extensions.findByType<com.android.build.gradle.AppExtension>()?.apply {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
}
}
}
val newBuildDir: Directory =
rootProject.layout.buildDirectory
.dir("../../build")
.get()
rootProject.layout.buildDirectory.value(newBuildDir)
subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}