build.gradle.kts 3.3 KB

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