|
| 1 | +plugins { |
| 2 | + id("otel.library-instrumentation") |
| 3 | + id("otel.japicmp-conventions") |
| 4 | +} |
| 5 | + |
| 6 | +base.archivesName.set("opentelemetry-spring-boot-autoconfigure-4.0") |
| 7 | +group = "io.opentelemetry.instrumentation" |
| 8 | + |
| 9 | +val springBootVersion = "4.0.0-M1" |
| 10 | + |
| 11 | +// r2dbc-proxy is shadowed to prevent org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration |
| 12 | +// 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. |
| 13 | +sourceSets { |
| 14 | + main { |
| 15 | + val shadedDep = project(":instrumentation:r2dbc-1.0:library-instrumentation-shaded") |
| 16 | + output.dir( |
| 17 | + shadedDep.file("build/extracted/shadow-spring"), |
| 18 | + "builtBy" to ":instrumentation:r2dbc-1.0:library-instrumentation-shaded:extractShadowJarSpring", |
| 19 | + ) |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +dependencies { |
| 24 | + compileOnly("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion") |
| 25 | + annotationProcessor("org.springframework.boot:spring-boot-autoconfigure-processor:$springBootVersion") |
| 26 | + annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:$springBootVersion") |
| 27 | + implementation("javax.validation:validation-api") |
| 28 | + |
| 29 | + implementation(project(":instrumentation-annotations-support")) |
| 30 | + implementation(project(":instrumentation:kafka:kafka-clients:kafka-clients-2.6:library")) |
| 31 | + implementation(project(":instrumentation:mongo:mongo-3.1:library")) |
| 32 | + compileOnly(project(path = ":instrumentation:r2dbc-1.0:library-instrumentation-shaded", configuration = "shadow")) |
| 33 | + implementation(project(":instrumentation:spring:spring-kafka-2.7:library")) |
| 34 | + implementation(project(":instrumentation:spring:spring-web:spring-web-3.1:library")) |
| 35 | + implementation(project(":instrumentation:spring:spring-webmvc:spring-webmvc-5.3:library")) |
| 36 | + compileOnly("jakarta.servlet:jakarta.servlet-api:5.0.0") |
| 37 | + implementation(project(":instrumentation:spring:spring-webflux:spring-webflux-5.3:library")) |
| 38 | + implementation(project(":instrumentation:micrometer:micrometer-1.5:library")) |
| 39 | + implementation(project(":instrumentation:log4j:log4j-appender-2.17:library")) |
| 40 | + compileOnly("org.apache.logging.log4j:log4j-core:2.17.0") |
| 41 | + implementation(project(":instrumentation:logback:logback-appender-1.0:library")) |
| 42 | + implementation(project(":instrumentation:logback:logback-mdc-1.0:library")) |
| 43 | + compileOnly("ch.qos.logback:logback-classic:1.0.0") |
| 44 | + implementation(project(":instrumentation:jdbc:library")) |
| 45 | + implementation(project(":instrumentation:runtime-telemetry:runtime-telemetry-java8:library")) |
| 46 | + implementation(project(":instrumentation:runtime-telemetry:runtime-telemetry-java17:library")) |
| 47 | + compileOnly("org.springframework.boot:spring-boot-starter-kafka:$springBootVersion") |
| 48 | + compileOnly("org.springframework.boot:spring-boot-starter-mongodb:$springBootVersion") |
| 49 | + compileOnly("org.springframework.boot:spring-boot-starter-jdbc:$springBootVersion") |
| 50 | + |
| 51 | + library("org.springframework.kafka:spring-kafka:2.9.0") |
| 52 | + library("org.springframework.boot:spring-boot-starter-actuator:$springBootVersion") |
| 53 | + library("org.springframework.boot:spring-boot-starter-aop:$springBootVersion") |
| 54 | + library("org.springframework.boot:spring-boot-starter-web:$springBootVersion") |
| 55 | + library("org.springframework.boot:spring-boot-starter-webflux:$springBootVersion") |
| 56 | + library("org.springframework.boot:spring-boot-starter-data-mongodb:$springBootVersion") |
| 57 | + library("org.springframework.boot:spring-boot-starter-data-r2dbc:$springBootVersion") |
| 58 | + |
| 59 | + implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") |
| 60 | + implementation(project(":sdk-autoconfigure-support")) |
| 61 | + compileOnly("io.opentelemetry:opentelemetry-extension-trace-propagators") |
| 62 | + compileOnly("io.opentelemetry.contrib:opentelemetry-aws-xray-propagator") |
| 63 | + compileOnly("io.opentelemetry:opentelemetry-exporter-logging") |
| 64 | + compileOnly("io.opentelemetry:opentelemetry-exporter-otlp") |
| 65 | + compileOnly("io.opentelemetry:opentelemetry-exporter-zipkin") |
| 66 | + compileOnly(project(":instrumentation-annotations")) |
| 67 | + |
| 68 | + compileOnly(project(":instrumentation:resources:library")) |
| 69 | + annotationProcessor("com.google.auto.service:auto-service") |
| 70 | + compileOnly("com.google.auto.service:auto-service-annotations") |
| 71 | + |
| 72 | + testLibrary("org.springframework.boot:spring-boot-starter-test:$springBootVersion") { |
| 73 | + exclude("org.junit.vintage", "junit-vintage-engine") |
| 74 | + } |
| 75 | +// testImplementation("javax.servlet:javax.servlet-api:3.1.0") |
| 76 | + testImplementation("jakarta.servlet:jakarta.servlet-api:5.0.0") |
| 77 | + testRuntimeOnly("com.h2database:h2:1.4.197") |
| 78 | + testRuntimeOnly("io.r2dbc:r2dbc-h2:1.0.0.RELEASE") |
| 79 | + |
| 80 | + testImplementation(project(":testing-common")) |
| 81 | + testImplementation("io.opentelemetry:opentelemetry-sdk") |
| 82 | + testImplementation("io.opentelemetry:opentelemetry-sdk-testing") |
| 83 | + testImplementation(project(":instrumentation:resources:library")) |
| 84 | + testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi") |
| 85 | + testImplementation("io.opentelemetry:opentelemetry-extension-trace-propagators") |
| 86 | + testImplementation("io.opentelemetry.contrib:opentelemetry-aws-xray-propagator") |
| 87 | + testImplementation("io.opentelemetry:opentelemetry-exporter-logging") |
| 88 | + testImplementation("io.opentelemetry:opentelemetry-exporter-otlp") |
| 89 | + testImplementation("io.opentelemetry:opentelemetry-exporter-zipkin") |
| 90 | + testImplementation(project(":instrumentation-annotations")) |
| 91 | + |
| 92 | + implementation(project(":instrumentation:spring:spring-webmvc:spring-webmvc-6.0:library")) |
| 93 | + compileOnly("org.springframework.boot:spring-boot-starter-restclient:$springBootVersion") |
| 94 | +} |
| 95 | + |
| 96 | +val latestDepTest = findProperty("testLatestDeps") as Boolean |
| 97 | + |
| 98 | +// spring 6 (spring boot 3) requires java 17 |
| 99 | +if (latestDepTest) { |
| 100 | + otelJava { |
| 101 | + minJavaVersionSupported.set(JavaVersion.VERSION_17) |
| 102 | + } |
| 103 | +} |
| 104 | + |
| 105 | +val testJavaVersion = gradle.startParameter.projectProperties["testJavaVersion"]?.let(JavaVersion::toVersion) |
| 106 | + |
| 107 | +testing { |
| 108 | + suites { |
| 109 | + val testLogbackAppender by registering(JvmTestSuite::class) { |
| 110 | + dependencies { |
| 111 | + implementation(project()) |
| 112 | + implementation(project(":testing-common")) |
| 113 | + implementation("io.opentelemetry:opentelemetry-sdk") |
| 114 | + implementation("io.opentelemetry:opentelemetry-sdk-testing") |
| 115 | + implementation("org.mockito:mockito-inline") |
| 116 | + implementation("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion") |
| 117 | + |
| 118 | + implementation(project(":instrumentation:logback:logback-appender-1.0:library")) |
| 119 | + implementation(project(":instrumentation:logback:logback-mdc-1.0:library")) |
| 120 | + // using the same versions as in the spring-boot-autoconfigure |
| 121 | + implementation("ch.qos.logback:logback-classic") { |
| 122 | + version { |
| 123 | + strictly("1.2.11") |
| 124 | + } |
| 125 | + } |
| 126 | + implementation("org.slf4j:slf4j-api") { |
| 127 | + version { |
| 128 | + strictly("1.7.32") |
| 129 | + } |
| 130 | + } |
| 131 | + } |
| 132 | + } |
| 133 | + |
| 134 | + val testLogbackMissing by registering(JvmTestSuite::class) { |
| 135 | + dependencies { |
| 136 | + implementation(project()) |
| 137 | + implementation("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion") |
| 138 | + |
| 139 | + implementation("org.slf4j:slf4j-api") { |
| 140 | + version { |
| 141 | + strictly("1.7.32") |
| 142 | + } |
| 143 | + } |
| 144 | + } |
| 145 | + } |
| 146 | + } |
| 147 | +} |
| 148 | + |
| 149 | +configurations.configureEach { |
| 150 | + if (name.contains("testLogbackMissing")) { |
| 151 | + exclude("ch.qos.logback", "logback-classic") |
| 152 | + } |
| 153 | +} |
| 154 | + |
| 155 | +java { |
| 156 | + sourceCompatibility = JavaVersion.VERSION_17 |
| 157 | + targetCompatibility = JavaVersion.VERSION_17 |
| 158 | +// options.release.set(17) |
| 159 | +} |
| 160 | + |
| 161 | +otelJava { |
| 162 | + minJavaVersionSupported.set(JavaVersion.VERSION_17) |
| 163 | +} |
| 164 | + |
| 165 | +tasks { |
| 166 | + compileTestJava { |
| 167 | + options.compilerArgs.add("-parameters") |
| 168 | + } |
| 169 | + |
| 170 | + withType<Test>().configureEach { |
| 171 | + systemProperty("testLatestDeps", latestDepTest) |
| 172 | + |
| 173 | + // required on jdk17 |
| 174 | + jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") |
| 175 | + jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") |
| 176 | + } |
| 177 | + |
| 178 | + val testStableSemconv by registering(Test::class) { |
| 179 | + jvmArgs("-Dotel.semconv-stability.opt-in=database") |
| 180 | + } |
| 181 | + |
| 182 | + check { |
| 183 | + dependsOn(testing.suites) |
| 184 | + dependsOn(testStableSemconv) |
| 185 | + } |
| 186 | +} |
0 commit comments