build.gradle.kts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. plugins {
  2. id("otel.javaagent-instrumentation")
  3. }
  4. muzzle {
  5. pass {
  6. group.set("org.apache.logging.log4j")
  7. module.set("log4j-core")
  8. versions.set("[2.0,)")
  9. assertInverse.set(true)
  10. }
  11. }
  12. val testLatestDeps = findProperty("testLatestDeps") as Boolean
  13. dependencies {
  14. library("org.apache.logging.log4j:log4j-core:2.17.0")
  15. compileOnly(project(":javaagent-bootstrap"))
  16. implementation(project(":instrumentation:log4j:log4j-appender-2.17:library"))
  17. testImplementation("org.awaitility:awaitility")
  18. // this dependency is needed for the slf4j->log4j test
  19. if (testLatestDeps) {
  20. testImplementation("org.apache.logging.log4j:log4j-slf4j2-impl:2.19.0")
  21. } else {
  22. // log4j 2.17 doesn't have an slf4j2 bridge
  23. testImplementation("org.apache.logging.log4j:log4j-slf4j-impl:2.17.0")
  24. testImplementation("org.slf4j:slf4j-api") {
  25. version {
  26. strictly("1.7.36")
  27. }
  28. }
  29. }
  30. // this is needed for the async logging test
  31. testImplementation("com.lmax:disruptor:3.4.2")
  32. }
  33. tasks.withType<Test>().configureEach {
  34. systemProperty("testLatestDeps", testLatestDeps)
  35. }
  36. tasks {
  37. val testAsync by registering(Test::class) {
  38. jvmArgs("-DLog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector")
  39. }
  40. check {
  41. dependsOn(testAsync)
  42. }
  43. }
  44. tasks.withType<Test>().configureEach {
  45. // TODO run tests both with and without experimental log attributes
  46. jvmArgs("-Dotel.instrumentation.log4j-appender.experimental.capture-map-message-attributes=true")
  47. jvmArgs("-Dotel.instrumentation.log4j-appender.experimental.capture-context-data-attributes=*")
  48. jvmArgs("-Dotel.instrumentation.log4j-appender.experimental-log-attributes=true")
  49. jvmArgs("-Dotel.instrumentation.log4j-appender.experimental.capture-marker-attribute=true")
  50. }
  51. configurations {
  52. testImplementation {
  53. // this is needed for the slf4j->log4j test
  54. exclude("ch.qos.logback", "logback-classic")
  55. }
  56. }