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'

include(':mirai-demos')

try {
    def keyProps = new Properties()
    def keyFile = file("local.properties")
    if (keyFile.exists()) keyFile.withInputStream { keyProps.load(it) }
    if (!keyProps.getProperty("sdk.dir", "").isEmpty()) {
        include(':mirai-demos:mirai-demo-android')
        project(':mirai-demos:mirai-demo-android').projectDir = file('mirai-demos/mirai-demo-android')
    } else {
        println("Android SDK 可能未安装. \n将不会加载模块 `mirai-demo-android`, 但这并不影响其他 demo 的加载 ")
        println("Android SDK might not be installed. \nModule `mirai-demo-android` will not be included, but other demos will not be influenced")
    }
} catch (Exception e) {
    e.printStackTrace()
}

include(':mirai-core')
//include(':mirai-core-timpc')
include(':mirai-core-qqandroid')

include(':mirai-japt')
include(':mirai-console')
include(':mirai-console-graphical')
include(':mirai-console-terminal')
//include(':mirai-api')
include(':mirai-api-http')
include(':mirai-demos:mirai-demo-1')
include(':mirai-demos:mirai-demo-gentleman')
include(':mirai-demos:mirai-demo-java')
include(':mirai-plugins')
include(':mirai-plugins:image-sender')

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) {
        println("jdk版本为 "+ javaVersionNum)
        //include(':mirai-debug')
    } else {
        println("当前使用的 JDK 版本为 ${System.getProperty("java.version")}, 最低需要 JDK 11 才能引入模块 `:mirai-debug`")
    }
}

project(':mirai-demos:mirai-demo-1').projectDir = file('mirai-demos/mirai-demo-1')
project(':mirai-demos:mirai-demo-gentleman').projectDir = file('mirai-demos/mirai-demo-gentleman')
project(':mirai-demos:mirai-demo-java').projectDir = file('mirai-demos/mirai-demo-java')
project(':mirai-plugins:image-sender').projectDir = file('mirai-plugins/image-sender')

enableFeaturePreview('GRADLE_METADATA')