build.gradle.kts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. plugins {
  2. id("com.github.johnrengelman.shadow")
  3. id("otel.java-conventions")
  4. }
  5. dependencies {
  6. implementation("com.linecorp.armeria:armeria-junit5:1.26.4")
  7. }
  8. tasks {
  9. shadowJar {
  10. dependencies {
  11. exclude(dependency("org.slf4j:slf4j-api"))
  12. exclude(dependency("org.junit.jupiter:junit-jupiter-api"))
  13. exclude(dependency("org.junit.platform:junit-platform-commons"))
  14. }
  15. // Ensures tests are not affected by Armeria instrumentation
  16. relocate("com.linecorp.armeria", "io.opentelemetry.testing.internal.armeria")
  17. relocate("com.fasterxml.jackson", "io.opentelemetry.testing.internal.jackson")
  18. // Allows tests of Netty instrumentations which would otherwise conflict.
  19. // The relocation must end with io.netty to allow Netty to detect shaded native libraries.
  20. // https://github.com/netty/netty/blob/e69107ceaf247099ad9a198b8ef557bdff994a99/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java#L120
  21. relocate("io.netty", "io.opentelemetry.testing.internal.io.netty")
  22. exclude("META-INF/maven/**")
  23. relocate("META-INF/native/libnetty", "META-INF/native/libio_opentelemetry_testing_internal_netty")
  24. relocate("META-INF/native/netty", "META-INF/native/io_opentelemetry_testing_internal_netty")
  25. // relocate micrometer and its dependencies so that it doesn't conflict with instrumentation tests
  26. relocate("io.micrometer", "io.opentelemetry.testing.internal.io.micrometer")
  27. relocate("org.HdrHistogram", "io.opentelemetry.testing.internal.org.hdrhistogram")
  28. relocate("org.LatencyUtils", "io.opentelemetry.testing.internal.org.latencyutils")
  29. mergeServiceFiles()
  30. }
  31. val extractShadowJar by registering(Copy::class) {
  32. dependsOn(shadowJar)
  33. // there's both "LICENSE" file and "license" and without excluding one of these build fails on case insensitive file systems
  34. // there's a LICENSE.txt file that has the same contents anyway, so we're not losing anything excluding that
  35. from(zipTree(shadowJar.get().archiveFile)) {
  36. exclude("META-INF/LICENSE")
  37. }
  38. into("build/extracted/shadow")
  39. includeEmptyDirs = false
  40. }
  41. }