@@ -23,12 +23,20 @@ sourceSets {
2323 setSrcDirs(listOf (" src/main/javaSpring3" ))
2424 }
2525 }
26+ create(" javaSpring4" ) {
27+ java {
28+ setSrcDirs(listOf (" src/main/javaSpring4" ))
29+ }
30+ }
2631}
2732
2833configurations {
2934 named(" javaSpring3CompileOnly" ) {
3035 extendsFrom(configurations[" compileOnly" ])
3136 }
37+ named(" javaSpring4CompileOnly" ) {
38+ extendsFrom(configurations[" compileOnly" ])
39+ }
3240}
3341
3442dependencies {
@@ -106,6 +114,14 @@ dependencies {
106114 add(" javaSpring3CompileOnly" , " io.opentelemetry:opentelemetry-sdk-extension-autoconfigure" )
107115 add(" javaSpring3CompileOnly" , project(" :instrumentation:spring:spring-web:spring-web-3.1:library" ))
108116 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" ))
109125}
110126
111127val latestDepTest = findProperty(" testLatestDeps" ) as Boolean
@@ -119,6 +135,7 @@ if (latestDepTest) {
119135
120136val testJavaVersion = gradle.startParameter.projectProperties[" testJavaVersion" ]?.let (JavaVersion ::toVersion)
121137val testSpring3 = (testJavaVersion == null || testJavaVersion.compareTo(JavaVersion .VERSION_17 ) >= 0 )
138+ val testSpring4 = (testJavaVersion == null || testJavaVersion.compareTo(JavaVersion .VERSION_17 ) >= 0 )
122139
123140testing {
124141 suites {
@@ -173,6 +190,20 @@ testing {
173190 }
174191 }
175192 }
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+ }
176207 }
177208}
178209
@@ -219,6 +250,30 @@ tasks {
219250 from(sourceSets[" javaSpring3" ].java)
220251 }
221252
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+
222277 val testStableSemconv by registering(Test ::class ) {
223278 jvmArgs(" -Dotel.semconv-stability.opt-in=database" )
224279 }
0 commit comments