@@ -23,12 +23,20 @@ sourceSets {
23
23
setSrcDirs(listOf (" src/main/javaSpring3" ))
24
24
}
25
25
}
26
+ create(" javaSpring4" ) {
27
+ java {
28
+ setSrcDirs(listOf (" src/main/javaSpring4" ))
29
+ }
30
+ }
26
31
}
27
32
28
33
configurations {
29
34
named(" javaSpring3CompileOnly" ) {
30
35
extendsFrom(configurations[" compileOnly" ])
31
36
}
37
+ named(" javaSpring4CompileOnly" ) {
38
+ extendsFrom(configurations[" compileOnly" ])
39
+ }
32
40
}
33
41
34
42
dependencies {
@@ -106,6 +114,14 @@ dependencies {
106
114
add(" javaSpring3CompileOnly" , " io.opentelemetry:opentelemetry-sdk-extension-autoconfigure" )
107
115
add(" javaSpring3CompileOnly" , project(" :instrumentation:spring:spring-web:spring-web-3.1:library" ))
108
116
add(" javaSpring3CompileOnly" , project(" :instrumentation:spring:spring-webmvc:spring-webmvc-6.0:library" ))
117
+
118
+ // give access to common classes, e.g. InstrumentationConfigUtil
119
+ add(" javaSpring4CompileOnly" , files(sourceSets.main.get().output.classesDirs))
120
+ add(" javaSpring4CompileOnly" , " org.springframework.boot:spring-boot-starter-web:4.0.0-M1" )
121
+ add(" javaSpring4CompileOnly" , " org.springframework.boot:spring-boot-starter-restclient:4.0.0-M1" )
122
+ add(" javaSpring4CompileOnly" , " io.opentelemetry:opentelemetry-sdk-extension-autoconfigure" )
123
+ add(" javaSpring4CompileOnly" , project(" :instrumentation:spring:spring-web:spring-web-3.1:library" ))
124
+ add(" javaSpring4CompileOnly" , project(" :instrumentation:spring:spring-webmvc:spring-webmvc-6.0:library" ))
109
125
}
110
126
111
127
val latestDepTest = findProperty(" testLatestDeps" ) as Boolean
@@ -119,6 +135,7 @@ if (latestDepTest) {
119
135
120
136
val testJavaVersion = gradle.startParameter.projectProperties[" testJavaVersion" ]?.let (JavaVersion ::toVersion)
121
137
val testSpring3 = (testJavaVersion == null || testJavaVersion.compareTo(JavaVersion .VERSION_17 ) >= 0 )
138
+ val testSpring4 = (testJavaVersion == null || testJavaVersion.compareTo(JavaVersion .VERSION_17 ) >= 0 )
122
139
123
140
testing {
124
141
suites {
@@ -173,6 +190,20 @@ testing {
173
190
}
174
191
}
175
192
}
193
+
194
+ val testSpring4 by registering(JvmTestSuite ::class ) {
195
+ dependencies {
196
+ implementation(project())
197
+ implementation(" org.springframework.boot:spring-boot-starter-web:4.0.0-M1" )
198
+ implementation(" io.opentelemetry:opentelemetry-sdk-extension-autoconfigure" )
199
+ implementation(project(" :instrumentation:spring:spring-web:spring-web-3.1:library" ))
200
+ implementation(project(" :instrumentation:spring:spring-webmvc:spring-webmvc-6.0:library" ))
201
+ implementation(" jakarta.servlet:jakarta.servlet-api:5.0.0" )
202
+ implementation(" org.springframework.boot:spring-boot-starter-test:4.0.0-M1" ) {
203
+ exclude(" org.junit.vintage" , " junit-vintage-engine" )
204
+ }
205
+ }
206
+ }
176
207
}
177
208
}
178
209
@@ -219,6 +250,30 @@ tasks {
219
250
from(sourceSets[" javaSpring3" ].java)
220
251
}
221
252
253
+ named<JavaCompile >(" compileJavaSpring4Java" ) {
254
+ sourceCompatibility = " 17"
255
+ targetCompatibility = " 17"
256
+ options.release.set(17 )
257
+ }
258
+
259
+ named<JavaCompile >(" compileTestSpring4Java" ) {
260
+ sourceCompatibility = " 17"
261
+ targetCompatibility = " 17"
262
+ options.release.set(17 )
263
+ }
264
+
265
+ named<Test >(" testSpring4" ) {
266
+ isEnabled = testSpring4
267
+ }
268
+
269
+ named<Jar >(" jar" ) {
270
+ from(sourceSets[" javaSpring4" ].output)
271
+ }
272
+
273
+ named<Jar >(" sourcesJar" ) {
274
+ from(sourceSets[" javaSpring4" ].java)
275
+ }
276
+
222
277
val testStableSemconv by registering(Test ::class ) {
223
278
jvmArgs(" -Dotel.semconv-stability.opt-in=database" )
224
279
}
0 commit comments