build.gradle.kts 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. // r2dbc-proxy is shadowed to prevent org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration
  10. // from being loaded by Spring Boot (by the presence of META-INF/services/io.r2dbc.spi.ConnectionFactoryProvider) - even if the user doesn't want to use R2DBC.
  11. sourceSets {
  12. main {
  13. val shadedDep = project(":instrumentation:r2dbc-1.0:library-instrumentation-shaded")
  14. output.dir(
  15. shadedDep.file("build/extracted/shadow-spring"),
  16. "builtBy" to ":instrumentation:r2dbc-1.0:library-instrumentation-shaded:extractShadowJarSpring",
  17. )
  18. }
  19. }
  20. dependencies {
  21. implementation("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion")
  22. annotationProcessor("org.springframework.boot:spring-boot-autoconfigure-processor:$springBootVersion")
  23. annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:$springBootVersion")
  24. implementation("javax.validation:validation-api")
  25. implementation(project(":instrumentation-annotations-support"))
  26. implementation(project(":instrumentation:kafka:kafka-clients:kafka-clients-2.6:library"))
  27. implementation(project(":instrumentation:mongo:mongo-3.1:library"))
  28. compileOnly(project(path = ":instrumentation:r2dbc-1.0:library-instrumentation-shaded", configuration = "shadow"))
  29. implementation(project(":instrumentation:spring:spring-kafka-2.7:library"))
  30. implementation(project(":instrumentation:spring:spring-web:spring-web-3.1:library"))
  31. implementation(project(":instrumentation:spring:spring-webmvc:spring-webmvc-5.3:library"))
  32. implementation(project(":instrumentation:spring:spring-webmvc:spring-webmvc-6.0:library"))
  33. compileOnly("javax.servlet:javax.servlet-api:3.1.0")
  34. compileOnly("jakarta.servlet:jakarta.servlet-api:5.0.0")
  35. implementation(project(":instrumentation:spring:spring-webflux:spring-webflux-5.3:library"))
  36. implementation(project(":instrumentation:micrometer:micrometer-1.5:library"))
  37. implementation(project(":instrumentation:log4j:log4j-appender-2.17:library"))
  38. compileOnly("org.apache.logging.log4j:log4j-core:2.17.0")
  39. implementation(project(":instrumentation:logback:logback-appender-1.0:library"))
  40. compileOnly("ch.qos.logback:logback-classic:1.0.0")
  41. implementation(project(":instrumentation:jdbc:library"))
  42. library("org.springframework.kafka:spring-kafka:2.9.0")
  43. library("org.springframework.boot:spring-boot-starter-actuator:$springBootVersion")
  44. library("org.springframework.boot:spring-boot-starter-aop:$springBootVersion")
  45. library("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
  46. library("org.springframework.boot:spring-boot-starter-webflux:$springBootVersion")
  47. library("org.springframework.boot:spring-boot-starter-data-mongodb:$springBootVersion")
  48. library("org.springframework.boot:spring-boot-starter-data-r2dbc:$springBootVersion")
  49. implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
  50. implementation(project(":sdk-autoconfigure-support"))
  51. compileOnly("io.opentelemetry:opentelemetry-extension-trace-propagators")
  52. compileOnly("io.opentelemetry.contrib:opentelemetry-aws-xray-propagator")
  53. compileOnly("io.opentelemetry:opentelemetry-exporter-logging")
  54. compileOnly("io.opentelemetry:opentelemetry-exporter-otlp")
  55. compileOnly("io.opentelemetry:opentelemetry-exporter-zipkin")
  56. compileOnly(project(":instrumentation-annotations"))
  57. compileOnly(project(":instrumentation:resources:library"))
  58. annotationProcessor("com.google.auto.service:auto-service")
  59. compileOnly("com.google.auto.service:auto-service-annotations")
  60. testLibrary("org.springframework.boot:spring-boot-starter-test:$springBootVersion") {
  61. exclude("org.junit.vintage", "junit-vintage-engine")
  62. }
  63. testImplementation("javax.servlet:javax.servlet-api:3.1.0")
  64. testImplementation("jakarta.servlet:jakarta.servlet-api:5.0.0")
  65. testRuntimeOnly("com.h2database:h2:1.4.197")
  66. testRuntimeOnly("io.r2dbc:r2dbc-h2:1.0.0.RELEASE")
  67. testImplementation(project(":testing-common"))
  68. testImplementation("io.opentelemetry:opentelemetry-sdk")
  69. testImplementation("io.opentelemetry:opentelemetry-sdk-testing")
  70. testImplementation(project(":instrumentation:resources:library"))
  71. testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
  72. testImplementation("io.opentelemetry:opentelemetry-extension-trace-propagators")
  73. testImplementation("io.opentelemetry.contrib:opentelemetry-aws-xray-propagator")
  74. testImplementation("io.opentelemetry:opentelemetry-exporter-logging")
  75. testImplementation("io.opentelemetry:opentelemetry-exporter-otlp")
  76. testImplementation("io.opentelemetry:opentelemetry-exporter-zipkin")
  77. testImplementation(project(":instrumentation-annotations"))
  78. }
  79. val latestDepTest = findProperty("testLatestDeps") as Boolean
  80. // spring 6 (spring boot 3) requires java 17
  81. if (latestDepTest) {
  82. otelJava {
  83. minJavaVersionSupported.set(JavaVersion.VERSION_17)
  84. }
  85. }
  86. testing {
  87. suites {
  88. val testLogbackAppender by registering(JvmTestSuite::class) {
  89. dependencies {
  90. implementation(project())
  91. implementation(project(":testing-common"))
  92. implementation("io.opentelemetry:opentelemetry-sdk")
  93. implementation("io.opentelemetry:opentelemetry-sdk-testing")
  94. implementation("org.mockito:mockito-inline")
  95. implementation("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion")
  96. implementation(project(":instrumentation:logback:logback-appender-1.0:library"))
  97. // using the same versions as in the spring-boot-autoconfigure
  98. implementation("ch.qos.logback:logback-classic") {
  99. version {
  100. strictly("1.2.11")
  101. }
  102. }
  103. implementation("org.slf4j:slf4j-api") {
  104. version {
  105. strictly("1.7.32")
  106. }
  107. }
  108. }
  109. }
  110. }
  111. suites {
  112. val testLogbackMissing by registering(JvmTestSuite::class) {
  113. dependencies {
  114. implementation(project())
  115. implementation("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion")
  116. implementation("org.slf4j:slf4j-api") {
  117. version {
  118. strictly("1.7.32")
  119. }
  120. }
  121. }
  122. }
  123. }
  124. }
  125. configurations.configureEach {
  126. if (name.contains("testLogbackMissing")) {
  127. exclude("ch.qos.logback", "logback-classic")
  128. }
  129. }
  130. tasks {
  131. check {
  132. dependsOn(testing.suites)
  133. }
  134. compileTestJava {
  135. options.compilerArgs.add("-parameters")
  136. }
  137. withType<Test>().configureEach {
  138. systemProperty("testLatestDeps", latestDepTest)
  139. // required on jdk17
  140. jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
  141. jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
  142. }
  143. }