build.gradle.kts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. if (testLatestDeps) {
  19. // this dependency is needed for the slf4j->log4j test
  20. testImplementation("org.apache.logging.log4j:log4j-slf4j2-impl:+")
  21. testCompileOnly("biz.aQute.bnd:biz.aQute.bnd.annotation:7.0.0")
  22. } else {
  23. // log4j 2.17 doesn't have an slf4j2 bridge
  24. testImplementation("org.apache.logging.log4j:log4j-slf4j-impl:2.17.0")
  25. testImplementation("org.slf4j:slf4j-api") {
  26. version {
  27. strictly("1.7.36")
  28. }
  29. }
  30. }
  31. // this is needed for the async logging test
  32. testImplementation("com.lmax:disruptor:3.4.2")
  33. }
  34. tasks.withType<Test>().configureEach {
  35. systemProperty("testLatestDeps", testLatestDeps)
  36. }
  37. tasks {
  38. val testAsync by registering(Test::class) {
  39. jvmArgs("-DLog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector")
  40. }
  41. check {
  42. dependsOn(testAsync)
  43. }
  44. }
  45. tasks.withType<Test>().configureEach {
  46. // TODO run tests both with and without experimental log attributes
  47. jvmArgs("-Dotel.instrumentation.log4j-appender.experimental.capture-map-message-attributes=true")
  48. jvmArgs("-Dotel.instrumentation.log4j-appender.experimental.capture-context-data-attributes=*")
  49. jvmArgs("-Dotel.instrumentation.log4j-appender.experimental-log-attributes=true")
  50. jvmArgs("-Dotel.instrumentation.log4j-appender.experimental.capture-marker-attribute=true")
  51. }
  52. configurations {
  53. testImplementation {
  54. // this is needed for the slf4j->log4j test
  55. exclude("ch.qos.logback", "logback-classic")
  56. }
  57. }