build.gradle.kts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 shadow.relocateImplementation
  11. plugins {
  12. kotlin("multiplatform")
  13. kotlin("plugin.serialization")
  14. id("kotlinx-atomicfu")
  15. id("me.him188.kotlin-jvm-blocking-bridge")
  16. // id("me.him188.maven-central-publish")
  17. `maven-publish`
  18. }
  19. description = "mirai-core utilities"
  20. kotlin {
  21. explicitApi()
  22. apply(plugin = "explicit-api")
  23. configureJvmTargetsHierarchical("net.mamoe.mirai.utils")
  24. sourceSets {
  25. val commonMain by getting {
  26. dependencies {
  27. api(kotlin("reflect"))
  28. api(`kotlinx-serialization-core`)
  29. api(`kotlinx-serialization-json`)
  30. api(`kotlinx-coroutines-core`)
  31. implementation(`kotlinx-serialization-protobuf`)
  32. relocateImplementation(`ktor-io_relocated`)
  33. }
  34. }
  35. val commonTest by getting {
  36. dependencies {
  37. api(yamlkt)
  38. implementation(`kotlinx-coroutines-test`)
  39. }
  40. }
  41. findByName("jvmBaseMain")?.apply {
  42. dependencies {
  43. implementation(`jetbrains-annotations`)
  44. }
  45. }
  46. findByName("androidMain")?.apply {
  47. dependencies {
  48. implementation(`androidx-annotation`)
  49. }
  50. }
  51. findByName("jvmMain")?.apply {
  52. }
  53. findByName("jvmTest")?.apply {
  54. dependencies {
  55. implementation(`kotlinx-coroutines-debug`)
  56. runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
  57. }
  58. }
  59. }
  60. }
  61. if (tasks.findByName("androidMainClasses") != null) {
  62. tasks.register("checkAndroidApiLevel") {
  63. doFirst {
  64. analyzes.AndroidApiLevelCheck.check(
  65. buildDir.resolve("classes/kotlin/android/main"),
  66. project.property("mirai.android.target.api.level")!!.toString().toInt(),
  67. project
  68. )
  69. }
  70. group = "verification"
  71. this.mustRunAfter("androidMainClasses")
  72. }
  73. tasks.findByName("androidTest")?.dependsOn("checkAndroidApiLevel")
  74. }
  75. configureMppPublishing()
  76. //mavenCentralPublish {
  77. // artifactId = "mirai-core-utils"
  78. // githubProject("mamoe", "mirai")
  79. // developer("Mamoe Technologies", email = "[email protected]", url = "https://github.com/mamoe")
  80. // licenseFromGitHubProject("AGPLv3", "dev")
  81. // publishPlatformArtifactsInRootModule = "jvm"
  82. //}