2
0

build.gradle.kts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright 2019-2022 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/dev/LICENSE
  8. */
  9. @file:Suppress("UnusedImport")
  10. import java.util.*
  11. plugins {
  12. kotlin("jvm")
  13. kotlin("plugin.serialization")
  14. id("java")
  15. }
  16. version = Versions.console
  17. description = "Mirai Console Backend Real-Time Testing Unit"
  18. kotlin {
  19. explicitApiWarning()
  20. }
  21. dependencies {
  22. api(project(":mirai-core-api"))
  23. api(project(":mirai-core-utils"))
  24. testRuntimeOnly(project(":mirai-core"))
  25. api(project(":mirai-console-compiler-annotations"))
  26. api(project(":mirai-console"))
  27. api(project(":mirai-console-frontend-base"))
  28. api(project(":mirai-console-terminal"))
  29. api(`kotlin-stdlib-jdk8`)
  30. api(`kotlinx-atomicfu`)
  31. api(`kotlinx-coroutines-core`)
  32. api(`kotlinx-serialization-core`)
  33. api(`kotlinx-serialization-json`)
  34. api(`kotlin-reflect`)
  35. api(`kotlin-test-junit5`)
  36. api(`yamlkt`)
  37. api(`jetbrains-annotations`)
  38. api(`caller-finder`)
  39. api(`kotlinx-coroutines-jdk8`)
  40. val asmVersion = Versions.asm
  41. fun asm(module: String) = "org.ow2.asm:asm-$module:$asmVersion"
  42. api(asm("tree"))
  43. api(asm("util"))
  44. api(asm("commons"))
  45. }
  46. // requires manual run
  47. val deleteSandbox = tasks.register("deleteSandbox", Delete::class.java) {
  48. group = "mirai"
  49. delete("build/IntegrationTest")
  50. }
  51. //tasks.getByName("clean").dependsOn(deleteSandbox)
  52. val subplugins = mutableListOf<TaskProvider<Jar>>()
  53. val mcit_test = tasks.named<Test>("test")
  54. mcit_test.configure {
  55. val test0 = this
  56. doFirst {
  57. // For IDEA Debugging
  58. @Suppress("UNNECESSARY_NOT_NULL_ASSERTION")
  59. val extArgs = test0.jvmArgs!!.asSequence().map { extArg ->
  60. Base64.getEncoder().encodeToString(extArg.toByteArray())
  61. }.joinToString(",")
  62. test0.jvmArgs = mutableListOf()
  63. test0.environment("IT_ARGS", extArgs)
  64. // For plugins coping
  65. val jars = subplugins.asSequence()
  66. .map { it.get() }
  67. .flatMap { it.outputs.files.files.asSequence() }
  68. .toList()
  69. test0.environment("IT_PLUGINS", jars.size)
  70. jars.forEachIndexed { index, jar ->
  71. test0.environment("IT_PLUGINS_$index", jar.absolutePath)
  72. }
  73. }
  74. }
  75. val crtProject = project
  76. allprojects {
  77. if (project != crtProject) {
  78. if (project.file(".module-group.txt").exists()) return@allprojects
  79. project.afterEvaluate {
  80. runCatching {
  81. val tk = tasks.named<Jar>("jar")
  82. subplugins.add(tk)
  83. mcit_test.configure { dependsOn(tk) }
  84. }
  85. }
  86. }
  87. }