build.gradle.kts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. implementation(project(":instrumentation:log4j:log4j-appender-2.17:library"))
  25. compileOnly("org.apache.logging.log4j:log4j-core:2.17.0")
  26. implementation(project(":instrumentation:logback:logback-appender-1.0:library"))
  27. compileOnly("ch.qos.logback:logback-classic:1.0.0")
  28. implementation(project(":instrumentation:jdbc:library"))
  29. library("org.springframework.kafka:spring-kafka:2.9.0")
  30. library("org.springframework.boot:spring-boot-starter-actuator:$springBootVersion")
  31. library("org.springframework.boot:spring-boot-starter-aop:$springBootVersion")
  32. library("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
  33. library("org.springframework.boot:spring-boot-starter-webflux:$springBootVersion")
  34. compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
  35. compileOnly("io.opentelemetry:opentelemetry-extension-annotations")
  36. compileOnly("io.opentelemetry:opentelemetry-extension-trace-propagators")
  37. compileOnly("io.opentelemetry.contrib:opentelemetry-aws-xray-propagator")
  38. compileOnly("io.opentelemetry:opentelemetry-exporter-logging")
  39. compileOnly("io.opentelemetry:opentelemetry-exporter-jaeger")
  40. compileOnly("io.opentelemetry:opentelemetry-exporter-otlp")
  41. compileOnly("io.opentelemetry:opentelemetry-exporter-zipkin")
  42. compileOnly(project(":instrumentation-annotations"))
  43. compileOnly(project(":instrumentation:resources:library"))
  44. annotationProcessor("com.google.auto.service:auto-service")
  45. compileOnly("com.google.auto.service:auto-service-annotations")
  46. testLibrary("org.springframework.boot:spring-boot-starter-test:$springBootVersion") {
  47. exclude("org.junit.vintage", "junit-vintage-engine")
  48. }
  49. testImplementation("org.testcontainers:kafka")
  50. testImplementation("javax.servlet:javax.servlet-api:3.1.0")
  51. testImplementation("jakarta.servlet:jakarta.servlet-api:5.0.0")
  52. testImplementation(project(":testing-common"))
  53. testImplementation("io.opentelemetry:opentelemetry-sdk")
  54. testImplementation("io.opentelemetry:opentelemetry-sdk-testing")
  55. testImplementation(project(":instrumentation:resources:library"))
  56. testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
  57. testImplementation("io.opentelemetry:opentelemetry-extension-annotations")
  58. testImplementation("io.opentelemetry:opentelemetry-extension-trace-propagators")
  59. testImplementation("io.opentelemetry.contrib:opentelemetry-aws-xray-propagator")
  60. testImplementation("io.opentelemetry:opentelemetry-exporter-logging")
  61. testImplementation("io.opentelemetry:opentelemetry-exporter-jaeger")
  62. testImplementation("io.opentelemetry:opentelemetry-exporter-otlp")
  63. testImplementation("io.opentelemetry:opentelemetry-exporter-zipkin")
  64. testImplementation(project(":instrumentation-annotations"))
  65. }
  66. val latestDepTest = findProperty("testLatestDeps") as Boolean
  67. // spring 6 (spring boot 3) requires java 17
  68. if (latestDepTest) {
  69. otelJava {
  70. minJavaVersionSupported.set(JavaVersion.VERSION_17)
  71. }
  72. }
  73. testing {
  74. suites {
  75. val testLogbackAppender by registering(JvmTestSuite::class) {
  76. dependencies {
  77. implementation(project())
  78. implementation(project(":testing-common"))
  79. implementation("io.opentelemetry:opentelemetry-sdk")
  80. implementation("io.opentelemetry:opentelemetry-sdk-testing")
  81. implementation("org.mockito:mockito-inline")
  82. implementation("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion")
  83. implementation(project(":instrumentation:logback:logback-appender-1.0:library"))
  84. // using the same versions as in the spring-boot-autoconfigure
  85. implementation("ch.qos.logback:logback-classic") {
  86. version {
  87. strictly("1.2.11")
  88. }
  89. }
  90. implementation("org.slf4j:slf4j-api") {
  91. version {
  92. strictly("1.7.32")
  93. }
  94. }
  95. }
  96. }
  97. }
  98. }
  99. tasks {
  100. check {
  101. dependsOn(testing.suites)
  102. }
  103. compileTestJava {
  104. options.compilerArgs.add("-parameters")
  105. }
  106. test {
  107. usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
  108. }
  109. withType<Test>().configureEach {
  110. systemProperty("testLatestDeps", latestDepTest)
  111. // required on jdk17
  112. jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
  113. jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
  114. // disable tests on openj9 18 because they often crash JIT compiler
  115. val testJavaVersion = gradle.startParameter.projectProperties["testJavaVersion"]?.let(JavaVersion::toVersion)
  116. val testOnOpenJ9 = gradle.startParameter.projectProperties["testJavaVM"]?.run { this == "openj9" }
  117. ?: false
  118. if (testOnOpenJ9 && testJavaVersion?.majorVersion == "18") {
  119. enabled = false
  120. }
  121. }
  122. }