build.gradle.kts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright 2019-2023 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("UNUSED_VARIABLE")
  10. import BinaryCompatibilityConfigurator.configureBinaryValidators
  11. import shadow.relocateCompileOnly
  12. plugins {
  13. id("com.android.library")
  14. kotlin("multiplatform")
  15. kotlin("plugin.serialization")
  16. id("kotlinx-atomicfu")
  17. id("signing")
  18. id("me.him188.kotlin-jvm-blocking-bridge")
  19. id("me.him188.kotlin-dynamic-delegation")
  20. // id("me.him188.maven-central-publish")
  21. `maven-publish`
  22. }
  23. description = "Mirai API module"
  24. kotlin {
  25. explicitApi()
  26. apply(plugin = "explicit-api")
  27. configureJvmTargetsHierarchical()
  28. configureNativeTargetsHierarchical(project)
  29. sourceSets {
  30. val commonMain by getting {
  31. dependencies {
  32. api(kotlin("reflect"))
  33. api(`kotlinx-serialization-core`)
  34. api(`kotlinx-serialization-json`)
  35. api(`kotlinx-coroutines-core`) // don't remove it, otherwise IDE will complain
  36. implementation(project(":mirai-core-utils"))
  37. implementation(project(":mirai-console-compiler-annotations"))
  38. implementation(`kotlinx-serialization-protobuf`)
  39. implementation(`kotlinx-atomicfu`)
  40. // runtime from mirai-core-utils
  41. relocateCompileOnly(`ktor-io_relocated`)
  42. implementation(`kotlin-jvm-blocking-bridge`)
  43. implementation(`kotlin-dynamic-delegation`)
  44. }
  45. }
  46. commonTest {
  47. dependencies {
  48. runtimeOnly(`log4j-core`)
  49. implementation(`kotlinx-coroutines-test`)
  50. }
  51. }
  52. findByName("jvmBaseMain")?.apply {
  53. dependencies {
  54. implementation(`jetbrains-annotations`)
  55. implementation(`log4j-api`)
  56. compileOnly(`slf4j-api`)
  57. }
  58. }
  59. afterEvaluate {
  60. findByName("androidUnitTest")?.apply {
  61. dependencies {
  62. runtimeOnly(`slf4j-api`)
  63. }
  64. }
  65. }
  66. findByName("jvmMain")?.apply {
  67. }
  68. findByName("jvmTest")?.apply {
  69. dependencies {
  70. runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
  71. }
  72. }
  73. findByName("nativeMain")?.apply {
  74. dependencies {
  75. }
  76. }
  77. }
  78. }
  79. atomicfu {
  80. transformJvm = false
  81. }
  82. if (tasks.findByName("androidMainClasses") != null) {
  83. tasks.register("checkAndroidApiLevel") {
  84. doFirst {
  85. analyzes.AndroidApiLevelCheck.check(
  86. buildDir.resolve("classes/kotlin/android/main"),
  87. project.property("mirai.android.target.api.level")!!.toString().toInt(),
  88. project
  89. )
  90. }
  91. group = "verification"
  92. this.mustRunAfter("androidMainClasses")
  93. }
  94. tasks.getByName("androidBaseTest").dependsOn("checkAndroidApiLevel")
  95. }
  96. configureMppPublishing()
  97. configureBinaryValidators(setOf("jvm", "android").filterTargets())
  98. //mavenCentralPublish {
  99. // artifactId = "mirai-core-api"
  100. // githubProject("mamoe", "mirai")
  101. // developer("Mamoe Technologies", email = "[email protected]", url = "https://github.com/mamoe")
  102. // licenseFromGitHubProject("AGPLv3", "dev")
  103. // publishPlatformArtifactsInRootModule = "jvm"
  104. //}
  105. android {
  106. namespace = "net.mamoe.mirai"
  107. }