Fix building on higher version of jdk

This commit is contained in:
LoveSy 2024-07-10 22:09:05 +08:00 committed by John Wu
parent ddae568741
commit 0185ddf577

View File

@ -16,7 +16,6 @@ import org.gradle.api.DefaultTask
import org.gradle.api.JavaVersion import org.gradle.api.JavaVersion
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.DirectoryProperty
import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.provider.Property import org.gradle.api.provider.Property
import org.gradle.api.tasks.Delete import org.gradle.api.tasks.Delete
import org.gradle.api.tasks.Input import org.gradle.api.tasks.Input
@ -26,7 +25,6 @@ import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.StopExecutionException import org.gradle.api.tasks.StopExecutionException
import org.gradle.api.tasks.Sync import org.gradle.api.tasks.Sync
import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.assign
import org.gradle.kotlin.dsl.exclude import org.gradle.kotlin.dsl.exclude
import org.gradle.kotlin.dsl.filter import org.gradle.kotlin.dsl.filter
import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.get
@ -35,8 +33,9 @@ import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.provideDelegate import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.register import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.registering import org.gradle.kotlin.dsl.registering
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.File import java.io.File
import java.security.KeyStore import java.security.KeyStore
@ -54,11 +53,6 @@ private fun Project.androidBase(configure: Action<BaseExtension>) =
private fun Project.android(configure: Action<BaseAppModuleExtension>) = private fun Project.android(configure: Action<BaseAppModuleExtension>) =
extensions.configure("android", configure) extensions.configure("android", configure)
private fun BaseExtension.kotlin(configure: Action<KotlinAndroidProjectExtension>) =
(this as ExtensionAware).extensions.findByName("kotlin")?.let {
configure.execute(it as KotlinAndroidProjectExtension)
}
private val Project.androidApp: BaseAppModuleExtension private val Project.androidApp: BaseAppModuleExtension
get() = extensions["android"] as BaseAppModuleExtension get() = extensions["android"] as BaseAppModuleExtension
@ -86,22 +80,18 @@ fun Project.setupCommon() {
packagingOptions { packagingOptions {
resources { resources {
excludes += "/META-INF/*" excludes += arrayOf(
excludes += "/META-INF/versions/**" "/META-INF/*",
excludes += "/org/bouncycastle/**" "/META-INF/versions/**",
excludes += "org/apache/commons/**" "/org/bouncycastle/**",
excludes += "/kotlin/**" "/org/apache/commons/**",
excludes += "/kotlinx/**" "/kotlin/**",
excludes += "/okhttp3/**" "/kotlinx/**",
excludes += "/*.txt" "/okhttp3/**",
excludes += "/*.bin" "/*.txt",
excludes += "/*.json" "/*.bin",
} "/*.json",
} )
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_17
} }
} }
} }
@ -110,6 +100,12 @@ fun Project.setupCommon() {
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk7") exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk7")
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8") exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
} }
tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
} }
fun Project.setupCoreLib() { fun Project.setupCoreLib() {