2
0

build.gradle.kts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. @file:Suppress("UNUSED_VARIABLE")
  10. import BinaryCompatibilityConfigurator.configureBinaryValidators
  11. import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
  12. plugins {
  13. kotlin("multiplatform")
  14. kotlin("plugin.serialization")
  15. //id("kotlinx-atomicfu")
  16. id("signing")
  17. id("me.him188.kotlin-jvm-blocking-bridge")
  18. `maven-publish`
  19. }
  20. description = "Mirai API module"
  21. kotlin {
  22. explicitApi()
  23. if (isAndroidSDKAvailable) {
  24. jvm("android") {
  25. attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.androidJvm)
  26. }
  27. } else {
  28. printAndroidNotInstalled()
  29. }
  30. jvm("common") {
  31. attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.common)
  32. }
  33. jvm("jvm")
  34. sourceSets {
  35. val commonMain by getting {
  36. dependencies {
  37. api(kotlin("reflect"))
  38. api(`kotlinx-serialization-core-jvm`)
  39. api(`kotlinx-serialization-json-jvm`)
  40. api(`kotlinx-coroutines-core-jvm`) // don't remove it, otherwise IDE will complain
  41. api(`kotlinx-coroutines-jdk8`)
  42. api(`ktor-client-okhttp`)
  43. implementation(project(":mirai-core-utils"))
  44. implementation(project(":mirai-console-compiler-annotations"))
  45. implementation(`kotlinx-serialization-protobuf-jvm`)
  46. implementation(`jetbrains-annotations`)
  47. implementation(`log4j-api`)
  48. implementation(`kotlinx-atomicfu-jvm`)
  49. implementationKotlinxIoJvm()
  50. compileOnly(`slf4j-api`)
  51. }
  52. }
  53. commonTest {
  54. dependencies {
  55. runtimeOnly(`log4j-core`)
  56. }
  57. }
  58. if (isAndroidSDKAvailable) {
  59. val androidMain by getting {
  60. dependsOn(commonMain)
  61. dependencies {
  62. compileOnly(`android-runtime`)
  63. // api(`ktor-client-android`)
  64. }
  65. }
  66. }
  67. val jvmMain by getting {
  68. }
  69. val jvmTest by getting {
  70. dependencies {
  71. runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
  72. }
  73. }
  74. }
  75. }
  76. if (isAndroidSDKAvailable) {
  77. tasks.register("checkAndroidApiLevel") {
  78. doFirst {
  79. analyzes.AndroidApiLevelCheck.check(
  80. buildDir.resolve("classes/kotlin/android/main"),
  81. project.property("mirai.android.target.api.level")!!.toString().toInt(),
  82. project
  83. )
  84. }
  85. group = "verification"
  86. this.mustRunAfter("androidMainClasses")
  87. }
  88. tasks.getByName("androidTest").dependsOn("checkAndroidApiLevel")
  89. }
  90. configureMppPublishing()
  91. configureBinaryValidators("jvm", "android")