build.gradle.kts 6.9 KB

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