build.gradle.kts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. configureNativeTargetsHierarchical(project)
  25. sourceSets {
  26. val commonMain by getting {
  27. dependencies {
  28. api(kotlin("reflect"))
  29. api(`kotlinx-serialization-core`)
  30. api(`kotlinx-serialization-json`)
  31. api(`kotlinx-coroutines-core`)
  32. implementation(`kotlinx-serialization-protobuf`)
  33. relocateImplementation(`ktor-io_relocated`)
  34. }
  35. }
  36. configure(NATIVE_TARGETS.map { getByName(it + "Main") }
  37. + NATIVE_TARGETS.map { getByName(it + "Test") }) {
  38. dependencies {
  39. // no relocation in native
  40. implementation(`ktor-io`) {
  41. exclude(ExcludeProperties.`slf4j-api`)
  42. }
  43. }
  44. }
  45. val commonTest by getting {
  46. dependencies {
  47. api(yamlkt)
  48. implementation(`kotlinx-coroutines-test`)
  49. }
  50. }
  51. findByName("jvmBaseMain")?.apply {
  52. dependencies {
  53. implementation(`jetbrains-annotations`)
  54. }
  55. }
  56. findByName("jvmMain")?.apply {
  57. }
  58. findByName("jvmTest")?.apply {
  59. dependencies {
  60. implementation(`kotlinx-coroutines-debug`)
  61. runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
  62. }
  63. }
  64. findByName("nativeMain")?.apply {
  65. dependencies {
  66. // implementation("com.soywiz.korlibs.krypto:krypto:2.4.12") // ':mirai-core-utils:compileNativeMainKotlinMetadata' fails because compiler cannot find reference
  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("androidBaseTest").dependsOn("checkAndroidApiLevel")
  84. }
  85. configureMppPublishing()
  86. //mavenCentralPublish {
  87. // artifactId = "mirai-core-utils"
  88. // githubProject("mamoe", "mirai")
  89. // developer("Mamoe Technologies", email = "support@mamoe.net", url = "https://github.com/mamoe")
  90. // licenseFromGitHubProject("AGPLv3", "dev")
  91. // publishPlatformArtifactsInRootModule = "jvm"
  92. //}