2
0

build.gradle.kts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. plugins {
  11. kotlin("multiplatform")
  12. kotlin("plugin.serialization")
  13. id("kotlinx-atomicfu")
  14. id("me.him188.kotlin-jvm-blocking-bridge")
  15. `maven-publish`
  16. }
  17. description = "mirai-core utilities"
  18. kotlin {
  19. explicitApi()
  20. configureHMPPJvm()
  21. sourceSets {
  22. val commonMain by getting {
  23. dependencies {
  24. api(kotlin("reflect"))
  25. api(`kotlinx-serialization-core`)
  26. api(`kotlinx-serialization-json`)
  27. api(`kotlinx-coroutines-core`)
  28. implementation(`kotlinx-atomicfu`)
  29. implementation(`kotlinx-serialization-protobuf`)
  30. implementation(`ktor-io`)
  31. }
  32. }
  33. val commonTest by getting {
  34. dependencies {
  35. api(yamlkt)
  36. }
  37. }
  38. val jvmBaseMain by getting {
  39. dependencies {
  40. }
  41. }
  42. if (isAndroidSDKAvailable) {
  43. val androidMain by getting {
  44. //
  45. dependencies {
  46. compileOnly(`android-runtime`)
  47. // api1(`ktor-client-android`)
  48. }
  49. }
  50. }
  51. val jvmMain by getting
  52. val jvmTest by getting {
  53. dependencies {
  54. runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
  55. }
  56. }
  57. val nativeMain by getting {
  58. dependencies {
  59. }
  60. }
  61. }
  62. }
  63. if (isAndroidSDKAvailable) {
  64. tasks.register("checkAndroidApiLevel") {
  65. doFirst {
  66. analyzes.AndroidApiLevelCheck.check(
  67. buildDir.resolve("classes/kotlin/android/main"),
  68. project.property("mirai.android.target.api.level")!!.toString().toInt(),
  69. project
  70. )
  71. }
  72. group = "verification"
  73. this.mustRunAfter("androidMainClasses")
  74. }
  75. tasks.getByName("androidTest").dependsOn("checkAndroidApiLevel")
  76. }
  77. fun org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler.implementation1(dependencyNotation: String) =
  78. implementation(dependencyNotation) {
  79. exclude("org.jetbrains.kotlin", "kotlin-stdlib")
  80. exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core")
  81. exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-common")
  82. exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-jvm")
  83. exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-metadata")
  84. }
  85. fun org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler.api1(dependencyNotation: String) =
  86. api(dependencyNotation) {
  87. exclude("org.jetbrains.kotlin", "kotlin-stdlib")
  88. exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core")
  89. exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-common")
  90. exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-jvm")
  91. exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-metadata")
  92. }
  93. configureMppPublishing()