build.gradle.kts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. plugins {
  2. id("otel.javaagent-testing")
  3. }
  4. val testServer by configurations.creating
  5. dependencies {
  6. testImplementation("javax:javaee-api:7.0")
  7. testImplementation(project(":instrumentation:jaxrs:jaxrs-2.0:jaxrs-2.0-arquillian-testing"))
  8. testRuntimeOnly("org.wildfly.arquillian:wildfly-arquillian-container-embedded:2.2.0.Final")
  9. testInstrumentation(project(":instrumentation:servlet:servlet-3.0:javaagent"))
  10. testInstrumentation(project(":instrumentation:jaxrs:jaxrs-2.0:jaxrs-2.0-common:javaagent"))
  11. testInstrumentation(project(":instrumentation:jaxrs:jaxrs-2.0:jaxrs-2.0-resteasy-3.0:javaagent"))
  12. // wildfly version used to run tests
  13. testServer("org.wildfly:wildfly-dist:18.0.0.Final@zip")
  14. }
  15. tasks {
  16. // extract wildfly dist, path is used from arquillian.xml
  17. val setupServer by registering(Copy::class) {
  18. from(zipTree(testServer.singleFile))
  19. into(file("build/server/"))
  20. }
  21. // logback-classic contains /META-INF/services/javax.servlet.ServletContainerInitializer
  22. // that breaks deploy on embedded wildfly
  23. // create a copy of logback-classic jar that does not have this file
  24. val modifyLogbackJar by registering(Jar::class) {
  25. destinationDirectory.set(file("$buildDir/tmp"))
  26. archiveFileName.set("logback-classic-modified.jar")
  27. exclude("/META-INF/services/javax.servlet.ServletContainerInitializer")
  28. doFirst {
  29. configurations.configureEach {
  30. if (name.toLowerCase().endsWith("testruntimeclasspath")) {
  31. val logbackJar = find { it.name.contains("logback-classic") }
  32. from(zipTree(logbackJar))
  33. }
  34. }
  35. }
  36. }
  37. test {
  38. dependsOn(modifyLogbackJar)
  39. dependsOn(setupServer)
  40. doFirst {
  41. // --add-modules is unrecognized on jdk8, ignore it instead of failing
  42. jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
  43. // needed for java 11 to avoid org.jboss.modules.ModuleNotFoundException: java.se
  44. jvmArgs("--add-modules=java.se")
  45. // add offset to default port values
  46. jvmArgs("-Djboss.socket.binding.port-offset=200")
  47. // remove logback-classic from classpath
  48. classpath = classpath.filter {
  49. !it.absolutePath.contains("logback-classic")
  50. }
  51. // add modified copy of logback-classic to classpath
  52. classpath = classpath.plus(files("$buildDir/tmp/logback-classic-modified.jar"))
  53. }
  54. }
  55. }