settings.gradle.kts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. if (System.getProperty("use.maven.local") == "true") {
  12. mavenLocal()
  13. }
  14. gradlePluginPortal()
  15. mavenCentral()
  16. google()
  17. }
  18. }
  19. val allProjects = mutableListOf<ProjectDescriptor>()
  20. rootProject.name = "mirai"
  21. fun includeProject(projectPath: String, dir: String? = null) {
  22. include(projectPath)
  23. if (dir != null) project(projectPath).projectDir = file(dir)
  24. allProjects.add(project(projectPath))
  25. }
  26. includeProject(":mirai-core-utils")
  27. includeProject(":mirai-core-api")
  28. includeProject(":mirai-core")
  29. includeProject(":mirai-core-all")
  30. includeProject(":mirai-bom")
  31. includeProject(":mirai-dokka")
  32. //includeProject(":binary-compatibility-validator")
  33. //includeProject(":binary-compatibility-validator-android", "binary-compatibility-validator/android")
  34. includeProject(":mirai-logging-log4j2", "logging/mirai-logging-log4j2")
  35. includeProject(":mirai-logging-slf4j", "logging/mirai-logging-slf4j")
  36. includeProject(":mirai-logging-slf4j-simple", "logging/mirai-logging-slf4j-simple")
  37. includeProject(":mirai-logging-slf4j-logback", "logging/mirai-logging-slf4j-logback")
  38. val disableOldFrontEnds = true
  39. fun includeConsoleProject(projectPath: String, dir: String? = null) =
  40. includeProject(projectPath, "mirai-console/$dir")
  41. includeConsoleProject(":mirai-console-compiler-annotations", "tools/compiler-annotations")
  42. includeConsoleProject(":mirai-console", "backend/mirai-console")
  43. includeConsoleProject(":mirai-console.codegen", "backend/codegen")
  44. includeConsoleProject(":mirai-console-terminal", "frontend/mirai-console-terminal")
  45. // region mirai-console.integration-test
  46. includeConsoleProject(":mirai-console.integration-test", "backend/integration-test")
  47. val consoleIntegrationTestSubPluginBuildGradleKtsTemplate by lazy {
  48. rootProject.projectDir
  49. .resolve("mirai-console/backend/integration-test/testers")
  50. .resolve("tester.template.gradle.kts")
  51. .readText()
  52. }
  53. @Suppress("SimpleRedundantLet")
  54. fun includeConsoleITPlugin(prefix: String, path: File) {
  55. path.resolve("build.gradle.kts").takeIf { !it.isFile }?.let { initScript ->
  56. initScript.writeText(consoleIntegrationTestSubPluginBuildGradleKtsTemplate)
  57. }
  58. val projectPath = "$prefix${path.name}"
  59. include(projectPath)
  60. project(projectPath).projectDir = path
  61. path.listFiles()?.asSequence().orEmpty()
  62. .filter { it.isDirectory }
  63. .filter { it.resolve(".nested-module.txt").exists() }
  64. .forEach { includeConsoleITPlugin("${projectPath}:", it) }
  65. }
  66. rootProject.projectDir
  67. .resolve("mirai-console/backend/integration-test/testers")
  68. .listFiles()?.asSequence().orEmpty()
  69. .filter { it.isDirectory }
  70. .forEach { includeConsoleITPlugin(":mirai-console.integration-test:", it) }
  71. // endregion
  72. includeConsoleProject(":mirai-console-compiler-common", "tools/compiler-common")
  73. includeConsoleProject(":mirai-console-intellij", "tools/intellij-plugin")
  74. includeConsoleProject(":mirai-console-gradle", "tools/gradle-plugin")
  75. @Suppress("ConstantConditionIf")
  76. if (!disableOldFrontEnds) {
  77. includeConsoleProject(":mirai-console-terminal", "frontend/mirai-console-terminal")
  78. println("JDK version: ${JavaVersion.current()}")
  79. if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
  80. includeConsoleProject(":mirai-console-graphical", "frontend/mirai-console-graphical")
  81. } else {
  82. println("当前使用的 JDK 版本为 ${System.getProperty("java.version")}, 请使用 JDK 9 以上版本引入模块 `:mirai-console-graphical`\n")
  83. }
  84. }
  85. includeProject(":ci-release-helper")
  86. val result = mutableListOf<ProjectDescriptor>()
  87. for (project in allProjects) {
  88. val validationDir = project.projectDir.resolve("compatibility-validation")
  89. if (!validationDir.exists()) continue
  90. validationDir.listFiles().orEmpty<File>().forEach { dir ->
  91. if (dir.resolve("build.gradle.kts").isFile) {
  92. val path = ":validator" + project.path + ":${dir.name}"
  93. include(path)
  94. project(path).projectDir = dir
  95. // project(path).name = "${project.name}-validator-${dir.name}"
  96. result.add(project(path))
  97. }
  98. }
  99. }