pluginManagement {
    resolutionStrategy {
        eachPlugin {
            switch (requested.id.id) {
                case "org.jetbrains.kotlin.multiplatform": useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${requested.version}"); break
                case "com.android.library": useModule("com.android.tools.build:gradle:${requested.version}"); break
                case "com.jfrog.bintray": useModule("com.jfrog.bintray.gradle:gradle-bintray-plugin:${requested.version}")
            }
        }
    }

    repositories {
        mavenLocal()
        jcenter()
        google()
        mavenCentral()
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
    }
}

rootProject.name = 'mirai-console'

include(':mirai-console')
include(':mirai-console-terminal')
include(':mirai-console-wrapper')

try{
    def javaVersion = System.getProperty("java.version")
    def versionPos = javaVersion.indexOf(".")
    if (versionPos==-1) versionPos = javaVersion.indexOf("-")
    if (versionPos==-1){
        println("jdk version unknown")
    }else{
        def javaVersionNum = javaVersion.substring(0, versionPos).toInteger()
        if (javaVersionNum >= 11) {
            include(':mirai-console-graphical')
        } else {
            println("jdk版本为 "+ javaVersionNum)
            println("当前使用的 JDK 版本为 ${System.getProperty("java.version")}, 最低需要 JDK 11 才能引入模块 `:mirai-console-graphical`")
        }
    }
}catch(Exception ignored){
    println("无法确定 JDK 版本, 将不会引入 `:mirai-console-graphical`")
}


enableFeaturePreview('GRADLE_METADATA')