Use Gradle JavaVersion API (#325)

This commit is contained in:
Bo Zhang 2021-04-07 23:38:50 +08:00 committed by GitHub
parent d50f34e2b7
commit d75b6a061c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 8 deletions

0
gradlew vendored Normal file → Executable file
View File

View File

@ -6,6 +6,7 @@
* *
* https://github.com/mamoe/mirai/blob/master/LICENSE * https://github.com/mamoe/mirai/blob/master/LICENSE
*/ */
import org.gradle.api.JavaVersion
pluginManagement { pluginManagement {
repositories { repositories {
@ -38,15 +39,9 @@ includeProject(":mirai-console-gradle", "tools/gradle-plugin")
if (!disableOldFrontEnds) { if (!disableOldFrontEnds) {
includeProject(":mirai-console-terminal", "frontend/mirai-console-terminal") includeProject(":mirai-console-terminal", "frontend/mirai-console-terminal")
val jdkVersion = kotlin.runCatching { println("JDK version: ${JavaVersion.current()}")
System.getProperty("java.version").let { v ->
v.toIntOrNull() ?: v.removePrefix("1.").substringBefore("-").toIntOrNull()
}
}.getOrNull() ?: -1
println("JDK version: $jdkVersion") if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
if (jdkVersion >= 9) {
includeProject(":mirai-console-graphical", "frontend/mirai-console-graphical") includeProject(":mirai-console-graphical", "frontend/mirai-console-graphical")
} else { } else {
println("当前使用的 JDK 版本为 ${System.getProperty("java.version")}, 请使用 JDK 9 以上版本引入模块 `:mirai-console-graphical`\n") println("当前使用的 JDK 版本为 ${System.getProperty("java.version")}, 请使用 JDK 9 以上版本引入模块 `:mirai-console-graphical`\n")