build.gradle.kts 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. plugins {
  2. id("otel.library-instrumentation")
  3. }
  4. // Name the Spring Boot modules in accordance with https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.developing-auto-configuration.custom-starter
  5. base.archivesName.set("opentelemetry-spring-boot")
  6. group = "io.opentelemetry.instrumentation"
  7. val versions: Map<String, String> by project
  8. val springBootVersion = versions["org.springframework.boot"]
  9. dependencies {
  10. implementation("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion")
  11. annotationProcessor("org.springframework.boot:spring-boot-autoconfigure-processor:$springBootVersion")
  12. annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:$springBootVersion")
  13. implementation("javax.validation:validation-api")
  14. implementation(project(":instrumentation-annotations-support"))
  15. implementation(project(":instrumentation:kafka:kafka-clients:kafka-clients-2.6:library"))
  16. implementation(project(":instrumentation:spring:spring-kafka-2.7:library"))
  17. implementation(project(":instrumentation:spring:spring-web:spring-web-3.1:library"))
  18. implementation(project(":instrumentation:spring:spring-webmvc:spring-webmvc-5.3:library"))
  19. implementation(project(":instrumentation:spring:spring-webmvc:spring-webmvc-6.0:library"))
  20. compileOnly("javax.servlet:javax.servlet-api:3.1.0")
  21. compileOnly("jakarta.servlet:jakarta.servlet-api:5.0.0")
  22. implementation(project(":instrumentation:spring:spring-webflux:spring-webflux-5.3:library"))
  23. implementation(project(":instrumentation:micrometer:micrometer-1.5:library"))
  24. library("org.springframework.kafka:spring-kafka:2.9.0")
  25. library("org.springframework.boot:spring-boot-starter-actuator:$springBootVersion")
  26. library("org.springframework.boot:spring-boot-starter-aop:$springBootVersion")
  27. library("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
  28. library("org.springframework.boot:spring-boot-starter-webflux:$springBootVersion")
  29. compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
  30. compileOnly("io.opentelemetry:opentelemetry-extension-annotations")
  31. compileOnly("io.opentelemetry:opentelemetry-extension-trace-propagators")
  32. compileOnly("io.opentelemetry.contrib:opentelemetry-aws-xray-propagator")
  33. compileOnly("io.opentelemetry:opentelemetry-exporter-logging")
  34. compileOnly("io.opentelemetry:opentelemetry-exporter-jaeger")
  35. compileOnly("io.opentelemetry:opentelemetry-exporter-otlp")
  36. compileOnly("io.opentelemetry:opentelemetry-exporter-zipkin")
  37. compileOnly(project(":instrumentation-annotations"))
  38. compileOnly(project(":instrumentation:resources:library"))
  39. annotationProcessor("com.google.auto.service:auto-service")
  40. compileOnly("com.google.auto.service:auto-service-annotations")
  41. testLibrary("org.springframework.boot:spring-boot-starter-test:$springBootVersion") {
  42. exclude("org.junit.vintage", "junit-vintage-engine")
  43. }
  44. testImplementation("org.testcontainers:kafka")
  45. testImplementation("javax.servlet:javax.servlet-api:3.1.0")
  46. testImplementation("jakarta.servlet:jakarta.servlet-api:5.0.0")
  47. testImplementation(project(":testing-common"))
  48. testImplementation("io.opentelemetry:opentelemetry-sdk")
  49. testImplementation("io.opentelemetry:opentelemetry-sdk-testing")
  50. testImplementation(project(":instrumentation:resources:library"))
  51. testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
  52. testImplementation("io.opentelemetry:opentelemetry-extension-annotations")
  53. testImplementation("io.opentelemetry:opentelemetry-extension-trace-propagators")
  54. testImplementation("io.opentelemetry.contrib:opentelemetry-aws-xray-propagator")
  55. testImplementation("io.opentelemetry:opentelemetry-exporter-logging")
  56. testImplementation("io.opentelemetry:opentelemetry-exporter-jaeger")
  57. testImplementation("io.opentelemetry:opentelemetry-exporter-otlp")
  58. testImplementation("io.opentelemetry:opentelemetry-exporter-zipkin")
  59. testImplementation(project(":instrumentation-annotations"))
  60. }
  61. val latestDepTest = findProperty("testLatestDeps") as Boolean
  62. // spring 6 (spring boot 3) requires java 17
  63. if (latestDepTest) {
  64. otelJava {
  65. minJavaVersionSupported.set(JavaVersion.VERSION_17)
  66. }
  67. }
  68. tasks.compileTestJava {
  69. options.compilerArgs.add("-parameters")
  70. }
  71. tasks.withType<Test>().configureEach {
  72. usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
  73. systemProperty("testLatestDeps", latestDepTest)
  74. // required on jdk17
  75. jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
  76. jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
  77. // disable tests on openj9 18 because they often crash JIT compiler
  78. val testJavaVersion = gradle.startParameter.projectProperties["testJavaVersion"]?.let(JavaVersion::toVersion)
  79. val testOnOpenJ9 = gradle.startParameter.projectProperties["testJavaVM"]?.run { this == "openj9" }
  80. ?: false
  81. if (testOnOpenJ9 && testJavaVersion?.majorVersion == "18") {
  82. enabled = false
  83. }
  84. }