build.gradle.kts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
  2. plugins {
  3. id("com.github.johnrengelman.shadow")
  4. id("otel.java-conventions")
  5. }
  6. description = "opentelemetry-api shaded for internal javaagent usage"
  7. group = "io.opentelemetry.javaagent"
  8. val latestDeps by configurations.creating {
  9. isCanBeResolved = true
  10. isCanBeConsumed = false
  11. }
  12. val v1_10Deps by configurations.creating {
  13. isCanBeResolved = true
  14. isCanBeConsumed = false
  15. // exclude the bom added by dependencyManagement
  16. exclude("io.opentelemetry", "opentelemetry-bom")
  17. }
  18. // configuration for publishing the shadowed artifact
  19. val v1_10 by configurations.creating {
  20. isCanBeConsumed = true
  21. isCanBeResolved = false
  22. }
  23. dependencies {
  24. latestDeps("io.opentelemetry:opentelemetry-api")
  25. listOf("opentelemetry-api", "opentelemetry-context").forEach {
  26. v1_10Deps("io.opentelemetry:$it") {
  27. version {
  28. strictly("1.10.0")
  29. }
  30. }
  31. }
  32. }
  33. // OpenTelemetry API shaded so that it can be used in instrumentation of OpenTelemetry API itself,
  34. // and then its usage can be unshaded after OpenTelemetry API is shaded
  35. // (see more explanation in opentelemetry-api-1.0.gradle)
  36. tasks {
  37. withType<ShadowJar>().configureEach {
  38. relocate("io.opentelemetry", "application.io.opentelemetry")
  39. }
  40. shadowJar {
  41. configurations = listOf(latestDeps)
  42. }
  43. val v1_10Shadow by registering(ShadowJar::class) {
  44. configurations = listOf(v1_10Deps)
  45. archiveClassifier.set("v1_10")
  46. }
  47. artifacts {
  48. add(v1_10.name, v1_10Shadow)
  49. }
  50. }