build.gradle.kts 2.0 KB

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