build.gradle.kts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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("UnusedImport")
  10. import shadow.configureRelocatedShadowJarForJvmProject
  11. import shadow.relocateImplementation
  12. plugins {
  13. kotlin("jvm")
  14. kotlin("plugin.serialization")
  15. `maven-publish`
  16. id("me.him188.kotlin-jvm-blocking-bridge")
  17. }
  18. version = Versions.project
  19. description = "Mirai core shadowed"
  20. dependencies {
  21. api(project(":mirai-core"))
  22. api(project(":mirai-core-api"))
  23. api(project(":mirai-core-utils"))
  24. implementation(`slf4j-api`) // Required by mirai-console
  25. relocateImplementation(project, `kt-bignum_relocated`)
  26. relocateImplementation(project, `ktor-client-core_relocated`)
  27. relocateImplementation(project, `ktor-client-okhttp_relocated`)
  28. relocateImplementation(project, `ktor-io_relocated`)
  29. }
  30. val shadow = configureRelocatedShadowJarForJvmProject(kotlin)
  31. if (System.getenv("MIRAI_IS_SNAPSHOTS_PUBLISHING")?.toBoolean() != true) {
  32. // Do not publish `-all` jars to snapshot server since they are too large.
  33. configurePublishing("mirai-core-all", addShadowJar = false)
  34. publications {
  35. getByName("mavenJava", MavenPublication::class) {
  36. artifact(shadow)
  37. }
  38. }
  39. tasks.getByName("publishMavenJavaPublicationToMavenLocal").dependsOn(shadow)
  40. tasks.findByName("publishMavenJavaPublicationToMavenCentralRepository")?.dependsOn(shadow)
  41. }
  42. //
  43. //// WARNING: You must also consider relocating transitive dependencies.
  44. //// Otherwise, user will get NoClassDefFound error when using mirai as a classpath dependency. See #2263.
  45. //
  46. //val includeInRuntime = true
  47. //relocateAllFromGroupId("io.ktor", includeInRuntime, "io.ktor")
  48. //relocateAllFromGroupId("com.squareup.okhttp3", includeInRuntime, listOf("okhttp3"))
  49. //relocateAllFromGroupId("com.squareup.okio", includeInRuntime, listOf("okio"))