Combine application and resources layers into a single layer
Closes gh-20562
This commit is contained in:
@@ -284,11 +284,10 @@ By default, the following layers are created:
|
||||
|
||||
* `dependencies` for any dependency whose version does not contain `SNAPSHOT`.
|
||||
* `snapshot-dependencies` for any dependency whose version contains `SNAPSHOT`.
|
||||
* `resources` for static resources at the default locations, i.e. `META-INF/resources/`, `resources/`, `static/`, `public/`.
|
||||
* `application` for any other classes and resources.
|
||||
* `application` for application classes and resources.
|
||||
|
||||
The layers order is important as it determines how likely previous layers can be cached when part of the application changes.
|
||||
The default order is `dependencies`, `snapshot-dependencies`, `resources`, and `application`.
|
||||
The default order is `dependencies`, `snapshot-dependencies`, and `application`.
|
||||
Content that is least likely to change should be added first, followed by layers that are more likely to change.
|
||||
|
||||
When you create a layered jar, the `spring-boot-layertools` jar will be added as a dependency to your jar.
|
||||
@@ -328,7 +327,7 @@ include::../gradle/packaging/boot-jar-layered-custom.gradle.kts[tags=layered]
|
||||
|
||||
Each `layerContent` closure defines a strategy to include or exclude an entry of the jar in a layer.
|
||||
When an entry matches a strategy, it is included in the layer and further strategies are ignored.
|
||||
This is illustrated by the `dependencies` and `application` layers that have a "catch-all" include filter used to add any libraries or classes that were not processed by previous strategies.
|
||||
This is illustrated by the `dependencies` layer that has a "catch-all" include filter used to add any libraries that were not processed by previous strategies.
|
||||
|
||||
The content of a `libraries` layer can be customized using filters to `include` or `exclude` based on the dependency coordinates.
|
||||
The format is `groupId:artifactId[:version]`.
|
||||
|
||||
@@ -10,7 +10,7 @@ bootJar {
|
||||
// tag::layered[]
|
||||
bootJar {
|
||||
layers {
|
||||
layersOrder "dependencies", "snapshot-dependencies", "resources", "application"
|
||||
layersOrder "dependencies", "snapshot-dependencies", "application"
|
||||
libraries {
|
||||
layerContent("snapshot-dependencies") {
|
||||
coordinates {
|
||||
@@ -24,12 +24,6 @@ bootJar {
|
||||
}
|
||||
}
|
||||
application {
|
||||
layerContent("resources") {
|
||||
locations {
|
||||
include "META-INF/resources/**", "resources/**"
|
||||
include "static/**", "public/**"
|
||||
}
|
||||
}
|
||||
layerContent("application") {
|
||||
locations {
|
||||
include "**"
|
||||
|
||||
@@ -8,7 +8,7 @@ plugins {
|
||||
// tag::layered[]
|
||||
tasks.getByName<BootJar>("bootJar") {
|
||||
layers {
|
||||
layersOrder("dependencies", "snapshot-dependencies", "resources", "application")
|
||||
layersOrder("dependencies", "snapshot-dependencies", "application")
|
||||
libraries {
|
||||
layerContent("snapshot-dependencies") {
|
||||
coordinates {
|
||||
@@ -22,12 +22,6 @@ tasks.getByName<BootJar>("bootJar") {
|
||||
}
|
||||
}
|
||||
application {
|
||||
layerContent("resources") {
|
||||
locations {
|
||||
include("META-INF/resources/**", "resources/**")
|
||||
include("static/**", "public/**")
|
||||
}
|
||||
}
|
||||
layerContent("application") {
|
||||
locations {
|
||||
include("**")
|
||||
|
||||
Reference in New Issue
Block a user