2
0

build.gradle.kts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. // id("me.him188.maven-central-publish")
  16. `maven-publish`
  17. }
  18. description = "mirai-core utilities"
  19. kotlin {
  20. explicitApi()
  21. configureJvmTargetsHierarchical()
  22. configureNativeTargetsHierarchical(project)
  23. sourceSets {
  24. val commonMain by getting {
  25. dependencies {
  26. api(kotlin("reflect"))
  27. api(`kotlinx-serialization-core`)
  28. api(`kotlinx-serialization-json`)
  29. api(`kotlinx-coroutines-core`)
  30. implementation(`kotlinx-atomicfu`)
  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. compileOnly(`android-runtime`)
  49. // api1(`ktor-client-android`)
  50. }
  51. }
  52. findByName("jvmMain")?.apply {
  53. }
  54. findByName("jvmTest")?.apply {
  55. dependencies {
  56. runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
  57. }
  58. }
  59. findByName("nativeMain")?.apply {
  60. dependencies {
  61. // implementation("com.soywiz.korlibs.krypto:krypto:2.4.12") // ':mirai-core-utils:compileNativeMainKotlinMetadata' fails because compiler cannot find reference
  62. }
  63. }
  64. }
  65. }
  66. if (tasks.findByName("androidMainClasses") != null) {
  67. tasks.register("checkAndroidApiLevel") {
  68. doFirst {
  69. analyzes.AndroidApiLevelCheck.check(
  70. buildDir.resolve("classes/kotlin/android/main"),
  71. project.property("mirai.android.target.api.level")!!.toString().toInt(),
  72. project
  73. )
  74. }
  75. group = "verification"
  76. this.mustRunAfter("androidMainClasses")
  77. }
  78. tasks.getByName("androidTest").dependsOn("checkAndroidApiLevel")
  79. }
  80. configureMppPublishing()
  81. //mavenCentralPublish {
  82. // artifactId = "mirai-core-utils"
  83. // githubProject("mamoe", "mirai")
  84. // developer("Mamoe Technologies", email = "[email protected]", url = "https://github.com/mamoe")
  85. // licenseFromGitHubProject("AGPLv3", "dev")
  86. // publishPlatformArtifactsInRootModule = "jvm"
  87. //}