2
0

build.gradle.kts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. plugins {
  11. id("com.android.library")
  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()
  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("androidMain")?.apply {
  57. dependencies {
  58. compileOnly(`android-runtime`)
  59. // api1(`ktor-client-android`)
  60. }
  61. }
  62. findByName("jvmMain")?.apply {
  63. }
  64. findByName("jvmTest")?.apply {
  65. dependencies {
  66. implementation(`kotlinx-coroutines-debug`)
  67. runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
  68. }
  69. }
  70. findByName("nativeMain")?.apply {
  71. dependencies {
  72. // implementation("com.soywiz.korlibs.krypto:krypto:2.4.12") // ':mirai-core-utils:compileNativeMainKotlinMetadata' fails because compiler cannot find reference
  73. }
  74. }
  75. }
  76. }
  77. if (tasks.findByName("androidMainClasses") != null) {
  78. tasks.register("checkAndroidApiLevel") {
  79. doFirst {
  80. analyzes.AndroidApiLevelCheck.check(
  81. buildDir.resolve("classes/kotlin/android/main"),
  82. project.property("mirai.android.target.api.level")!!.toString().toInt(),
  83. project
  84. )
  85. }
  86. group = "verification"
  87. this.mustRunAfter("androidMainClasses")
  88. }
  89. tasks.getByName("androidBaseTest").dependsOn("checkAndroidApiLevel")
  90. }
  91. //configureMppPublishing()
  92. //mavenCentralPublish {
  93. // artifactId = "mirai-core-utils"
  94. // githubProject("mamoe", "mirai")
  95. // developer("Mamoe Technologies", email = "[email protected]", url = "https://github.com/mamoe")
  96. // licenseFromGitHubProject("AGPLv3", "dev")
  97. // publishPlatformArtifactsInRootModule = "jvm"
  98. //}
  99. android {
  100. namespace = "net.mamoe.mirai.utils"
  101. }