build.gradle.kts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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-terminal"))
  28. api(`kotlin-stdlib-jdk8`)
  29. api(`kotlinx-atomicfu-jvm`)
  30. api(`kotlinx-coroutines-core-jvm`)
  31. api(`kotlinx-serialization-core-jvm`)
  32. api(`kotlinx-serialization-json-jvm`)
  33. api(`kotlin-reflect`)
  34. api(`kotlin-test-junit5`)
  35. api(`yamlkt-jvm`)
  36. api(`jetbrains-annotations`)
  37. api(`caller-finder`)
  38. api(`kotlinx-coroutines-jdk8`)
  39. val asmVersion = Versions.asm
  40. fun asm(module: String) = "org.ow2.asm:asm-$module:$asmVersion"
  41. api(asm("tree"))
  42. api(asm("util"))
  43. api(asm("commons"))
  44. }
  45. // requires manual run
  46. val deleteSandbox = tasks.register("deleteSandbox", Delete::class.java) {
  47. group = "mirai"
  48. delete("build/IntegrationTest")
  49. }
  50. //tasks.getByName("clean").dependsOn(deleteSandbox)
  51. val subplugins = mutableListOf<TaskProvider<Jar>>()
  52. val mcit_test = tasks.named<Test>("test")
  53. mcit_test.configure {
  54. val test0 = this
  55. doFirst {
  56. // For IDEA Debugging
  57. @Suppress("UNNECESSARY_NOT_NULL_ASSERTION")
  58. val extArgs = test0.jvmArgs!!.asSequence().map { extArg ->
  59. Base64.getEncoder().encodeToString(extArg.toByteArray())
  60. }.joinToString(",")
  61. test0.jvmArgs = mutableListOf()
  62. test0.environment("IT_ARGS", extArgs)
  63. // For plugins coping
  64. val jars = subplugins.asSequence()
  65. .map { it.get() }
  66. .flatMap { it.outputs.files.files.asSequence() }
  67. .toList()
  68. test0.environment("IT_PLUGINS", jars.size)
  69. jars.forEachIndexed { index, jar ->
  70. test0.environment("IT_PLUGINS_$index", jar.absolutePath)
  71. }
  72. }
  73. }
  74. val crtProject = project
  75. allprojects {
  76. if (project != crtProject) {
  77. project.afterEvaluate {
  78. val tk = tasks.named<Jar>("jar")
  79. subplugins.add(tk)
  80. mcit_test.configure { dependsOn(tk) }
  81. }
  82. }
  83. }