Skip to content

Commit f3d41bf

Browse files
committed
Minimize Jetty and Tomcat runtimes' dependencies
1 parent 8b1e937 commit f3d41bf

File tree

19 files changed

+116
-23
lines changed

19 files changed

+116
-23
lines changed

build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/examples/packaging/war-container-dependency.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ apply plugin: 'io.spring.dependency-management'
2424
// tag::dependencies[]
2525
dependencies {
2626
implementation('org.springframework.boot:spring-boot-starter-web')
27-
providedRuntime('org.springframework.boot:spring-boot-tomcat-runtime')
27+
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat-runtime')
2828
}
2929
// end::dependencies[]

build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/examples/packaging/war-container-dependency.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ apply(plugin = "io.spring.dependency-management")
88
// tag::dependencies[]
99
dependencies {
1010
implementation("org.springframework.boot:spring-boot-starter-web")
11-
providedRuntime("org.springframework.boot:spring-boot-tomcat-runtime")
11+
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat-runtime")
1212
}
1313
// end::dependencies[]

documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/deployment/traditional-deployment.adoc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ If you use Maven, the following example marks the servlet runtime (Tomcat, in th
4141
----
4242
<dependencies>
4343
<!-- ... -->
44+
<dependency>
45+
<groupId>org.springframework.boot</groupId>
46+
<artifactId>spring-boot-starter-tomcat-runtime</artifactId>
47+
<scope>provided</scope>
48+
</dependency>
4449
<dependency>
4550
<groupId>org.springframework.boot</groupId>
4651
<artifactId>spring-boot-tomcat-runtime</artifactId>
@@ -50,17 +55,21 @@ If you use Maven, the following example marks the servlet runtime (Tomcat, in th
5055
</dependencies>
5156
----
5257

58+
NOTE: If you are not using Spring Boot's starters, only `spring-boot-tomcat-runtime` needs to be declared in `provided` scope.
59+
5360
If you use Gradle, the following example marks the servlet runtime (Tomcat, in this case) as being provided:
5461

5562
[source,gradle]
5663
----
5764
dependencies {
5865
// ...
59-
providedRuntime 'org.springframework.boot:spring-boot-tomcat-runtime'
66+
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat-runtime'
6067
// ...
6168
}
6269
----
6370

71+
NOTE: If you are not using Spring Boot's starters, declare a `providedRuntime` dependency on `spring-boot-tomcat-runtime` instead.
72+
6473
TIP: `providedRuntime` is preferred to Gradle's `compileOnly` configuration.
6574
Among other limitations, `compileOnly` dependencies are not on the test classpath, so any web-based integration tests fail.
6675

module/spring-boot-jetty-runtime/build.gradle

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,4 @@ dependencies {
3535
api("org.eclipse.jetty.ee11:jetty-ee11-webapp") {
3636
exclude group: "org.slf4j", module: "slf4j-api"
3737
}
38-
api("org.eclipse.jetty.ee11.websocket:jetty-ee11-websocket-jakarta-server") {
39-
exclude group: "jakarta.el", module: "jakarta.el-api"
40-
exclude group: "org.eclipse.jetty", module: "jetty-jndi"
41-
exclude group: "org.slf4j", module: "slf4j-api"
42-
}
43-
api("org.eclipse.jetty.ee11.websocket:jetty-ee11-websocket-jetty-server") {
44-
exclude group: "jakarta.el", module: "jakarta.el-api"
45-
exclude group: "org.eclipse.jetty", module: "jetty-jndi"
46-
exclude group: "org.slf4j", module: "slf4j-api"
47-
}
4838
}

module/spring-boot-jetty/build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ dependencies {
3636
optional(project(":module:spring-boot-micrometer-metrics"))
3737
optional("org.apache.tomcat.embed:tomcat-embed-jasper")
3838
optional("org.eclipse.jetty:jetty-alpn-conscrypt-server")
39+
optional("org.eclipse.jetty.ee11.websocket:jetty-ee11-websocket-jakarta-server") {
40+
exclude group: "jakarta.el", module: "jakarta.el-api"
41+
exclude group: "org.eclipse.jetty", module: "jetty-jndi"
42+
exclude group: "org.slf4j", module: "slf4j-api"
43+
}
44+
optional("org.eclipse.jetty.ee11.websocket:jetty-ee11-websocket-jetty-server") {
45+
exclude group: "jakarta.el", module: "jakarta.el-api"
46+
exclude group: "org.eclipse.jetty", module: "jetty-jndi"
47+
exclude group: "org.slf4j", module: "slf4j-api"
48+
}
3949
optional("org.eclipse.jetty.http2:jetty-http2-server")
4050
optional("org.springframework:spring-webflux")
4151

module/spring-boot-tomcat-runtime/build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,4 @@ dependencies {
2525
api("org.apache.tomcat.embed:tomcat-embed-core") {
2626
exclude group: "org.apache.tomcat", module: "tomcat-annotations-api"
2727
}
28-
api("org.apache.tomcat.embed:tomcat-embed-el")
29-
api("org.apache.tomcat.embed:tomcat-embed-websocket") {
30-
exclude group: "org.apache.tomcat", module: "tomcat-annotations-api"
31-
}
3228
}

module/spring-boot-tomcat/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ dependencies {
3939
optional(project(":module:spring-boot-micrometer-metrics"))
4040
optional("io.micrometer:micrometer-core")
4141
optional("org.apache.tomcat.embed:tomcat-embed-jasper")
42+
optional("org.apache.tomcat.embed:tomcat-embed-websocket") {
43+
exclude group: "org.apache.tomcat", module: "tomcat-annotations-api"
44+
}
4245
optional("org.springframework:spring-webflux")
4346

4447
runtimeOnly("jakarta.annotation:jakarta.annotation-api")

platform/spring-boot-dependencies/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,6 +2185,7 @@ bom {
21852185
"spring-boot-starter-jersey",
21862186
"spring-boot-starter-jersey-test",
21872187
"spring-boot-starter-jetty",
2188+
"spring-boot-starter-jetty-runtime",
21882189
"spring-boot-starter-jms",
21892190
"spring-boot-starter-jms-test",
21902191
"spring-boot-starter-jooq",
@@ -2250,6 +2251,7 @@ bom {
22502251
"spring-boot-starter-thymeleaf",
22512252
"spring-boot-starter-thymeleaf-test",
22522253
"spring-boot-starter-tomcat",
2254+
"spring-boot-starter-tomcat-runtime",
22532255
"spring-boot-starter-validation",
22542256
"spring-boot-starter-validation-test",
22552257
"spring-boot-starter-web",

settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ include "starter:spring-boot-starter-jdbc-test"
283283
include "starter:spring-boot-starter-jersey"
284284
include "starter:spring-boot-starter-jersey-test"
285285
include "starter:spring-boot-starter-jetty"
286+
include "starter:spring-boot-starter-jetty-runtime"
286287
include "starter:spring-boot-starter-jms"
287288
include "starter:spring-boot-starter-jms-test"
288289
include "starter:spring-boot-starter-jooq"
@@ -349,6 +350,7 @@ include "starter:spring-boot-starter-test-classic"
349350
include "starter:spring-boot-starter-thymeleaf"
350351
include "starter:spring-boot-starter-thymeleaf-test"
351352
include "starter:spring-boot-starter-tomcat"
353+
include "starter:spring-boot-starter-tomcat-runtime"
352354
include "starter:spring-boot-starter-validation"
353355
include "starter:spring-boot-starter-validation-test"
354356
include "starter:spring-boot-starter-web"

smoke-test/spring-boot-smoke-test-tomcat-jsp/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ configurations {
2929
dependencies {
3030
implementation(project(":starter:spring-boot-starter-webmvc"))
3131

32-
providedRuntime(project(":module:spring-boot-tomcat-runtime"))
32+
providedRuntime(project(":starter:spring-boot-starter-tomcat-runtime"))
3333
providedRuntime("org.glassfish.web:jakarta.servlet.jsp.jstl")
3434
providedRuntime("org.apache.tomcat.embed:tomcat-embed-jasper")
3535

0 commit comments

Comments
 (0)