settings.gradle.kts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright 2019-2021 Mamoe Technologies and contributors.
  3. *
  4. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
  5. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
  6. *
  7. * https://github.com/mamoe/mirai/blob/master/LICENSE
  8. */
  9. pluginManagement {
  10. repositories {
  11. mavenLocal()
  12. gradlePluginPortal()
  13. mavenCentral()
  14. jcenter()
  15. google()
  16. maven(url = "https://dl.bintray.com/kotlin/kotlin-eap")
  17. maven(url = "https://dl.bintray.com/kotlin/kotlin-dev")
  18. maven(url = "https://dl.bintray.com/jetbrains/kotlin-native-dependencies")
  19. maven(url = "https://kotlin.bintray.com/kotlinx")
  20. }
  21. }
  22. rootProject.name = "mirai"
  23. include(":mirai-core-utils")
  24. include(":mirai-core-api")
  25. include(":mirai-core")
  26. include(":mirai-core-all")
  27. include(":binary-compatibility-validator")
  28. fun includeConsoleProjects() {
  29. val disableOldFrontEnds = true
  30. fun includeConsoleProject(projectPath: String, path: String? = null) {
  31. include(projectPath)
  32. if (path != null) project(projectPath).projectDir = file("mirai-console/$path")
  33. }
  34. includeConsoleProject(":mirai-console-compiler-annotations", "tools/compiler-annotations")
  35. includeConsoleProject(":mirai-console", "backend/mirai-console")
  36. includeConsoleProject(":mirai-console.codegen", "backend/codegen")
  37. includeConsoleProject(":mirai-console-terminal", "frontend/mirai-console-terminal")
  38. includeConsoleProject(":mirai-console-compiler-common", "tools/compiler-common")
  39. includeConsoleProject(":mirai-console-intellij", "tools/intellij-plugin")
  40. includeConsoleProject(":mirai-console-gradle", "tools/gradle-plugin")
  41. @Suppress("ConstantConditionIf")
  42. if (!disableOldFrontEnds) {
  43. includeConsoleProject(":mirai-console-terminal", "frontend/mirai-console-terminal")
  44. val jdkVersion = kotlin.runCatching {
  45. System.getProperty("java.version").let { v ->
  46. v.toIntOrNull() ?: v.removePrefix("1.").substringBefore("-").toIntOrNull()
  47. }
  48. }.getOrNull() ?: -1
  49. println("JDK version: $jdkVersion")
  50. if (jdkVersion >= 9) {
  51. includeConsoleProject(":mirai-console-graphical", "frontend/mirai-console-graphical")
  52. } else {
  53. println("当前使用的 JDK 版本为 ${System.getProperty("java.version")}, 请使用 JDK 9 以上版本引入模块 `:mirai-console-graphical`\n")
  54. }
  55. }
  56. }
  57. fun isMiraiConsoleCloned(): Boolean {
  58. return file("mirai-console/build.gradle.kts").exists()
  59. }
  60. if (isMiraiConsoleCloned()) {
  61. includeConsoleProjects()
  62. } else {
  63. logger.warn(
  64. """
  65. [mirai] mirai-console submodule is not configured.
  66. Please execute `git submodule init` and `git submodule update --remote` to include mirai-console build if you want.
  67. If you develop only on mirai-core, it's not compulsory to include mirai-console.
  68. """.trimIndent()
  69. )
  70. }