build.gradle.kts 2.2 KB

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