@@ -8,13 +8,15 @@ description = "gRPC: Jakarta Servlet"
88// Set up classpaths and source directories for different servlet tests
99sourceSets {
1010
11- // Only run these tests if java 11+ is being used
12- if (JavaVersion . current(). isJava11Compatible( )) {
11+ // Only run these tests if the required minimum Java version is being used
12+ if (JavaVersion . current(). isCompatibleWith( JavaVersion . VERSION_17 )) {
1313 jettyTest {
1414 java {
1515 include ' **/Jetty*.java'
1616 }
1717 }
18+ }
19+ if (JavaVersion . current(). isJava11Compatible()) {
1820 tomcatTest {
1921 java {
2022 include ' **/Tomcat*.java'
@@ -59,9 +61,11 @@ def migrate(String name, String inputDir, SourceSet sourceSet) {
5961
6062migrate(' main' , ' ../src/main/java' , sourceSets. main)
6163
62- // Only build sourceSets and classpaths for tests if using Java 11
63- if (JavaVersion . current(). isJava11Compatible( )) {
64+ // Only build sourceSets and classpaths for tests if using the required minimum Java version
65+ if (JavaVersion . current(). isCompatibleWith( JavaVersion . VERSION_17 )) {
6466 migrate(' jettyTest' , ' ../src/jettyTest/java' , sourceSets. jettyTest)
67+ }
68+ if (JavaVersion . current(). isJava11Compatible()) {
6569 migrate(' tomcatTest' , ' ../src/tomcatTest/java' , sourceSets. tomcatTest)
6670 migrate(' undertowTest' , ' ../src/undertowTest/java' , sourceSets. undertowTest)
6771}
@@ -106,12 +110,16 @@ dependencies {
106110
107111// Set up individual classpaths for each test, to avoid any mismatch,
108112// and ensure they are only used when supported by the current jvm
109- if (JavaVersion . current(). isJava11Compatible( )) {
113+ if (JavaVersion . current(). isCompatibleWith( JavaVersion . VERSION_17 )) {
110114 def jetty11Test = tasks. register(' jetty11Test' , Test ) {
111115 classpath = sourceSets. jettyTest. runtimeClasspath
112116 testClassesDirs = sourceSets. jettyTest. output. classesDirs
113117 }
114-
118+ tasks. named(" check" ). configure {
119+ dependsOn jetty11Test
120+ }
121+ }
122+ if (JavaVersion . current(). isJava11Compatible()) {
115123 def tomcat10Test = tasks. register(' tomcat10Test' , Test ) {
116124 classpath = sourceSets. tomcatTest. runtimeClasspath
117125 testClassesDirs = sourceSets. tomcatTest. output. classesDirs
@@ -136,6 +144,6 @@ if (JavaVersion.current().isJava11Compatible()) {
136144 }
137145
138146 tasks. named(" check" ). configure {
139- dependsOn jetty11Test, tomcat10Test, undertowTest
147+ dependsOn tomcat10Test, undertowTest
140148 }
141149}
0 commit comments