Allow users to opt out of including the layer tools in a layered jar

For Maven, the layer configuration is now an additional configuration
option instead of a layout type.

Closes gh-19866
This commit is contained in:
Madhura Bhave
2020-02-07 16:02:35 -08:00
parent 56475c19fb
commit 15cd590f7f
19 changed files with 408 additions and 22 deletions

View File

@@ -287,3 +287,18 @@ The jar will then be split into layer folders which may include:
* `snapshots-dependencies`
* `dependencies`
When you create a layered jar, the `spring-boot-layertools` jar will be added as a dependency to your jar.
With this jar on the classpath, you can launch your application in a special mode which allows the bootstrap code to run something entirely different from your application, for example, something that extracts the layers.
If you wish to exclude this dependency, you can do so in the following manner:
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
.Groovy
----
include::../gradle/packaging/boot-jar-layered-exclude-tools.gradle[tags=layered]
----
[source,kotlin,indent=0,subs="verbatim,attributes",role="secondary"]
.Kotlin
----
include::../gradle/packaging/boot-jar-layered-exclude-tools.gradle.kts[tags=layered]
----

View File

@@ -0,0 +1,16 @@
plugins {
id 'java'
id 'org.springframework.boot' version '{version}'
}
bootJar {
mainClassName 'com.example.ExampleApplication'
}
// tag::layered[]
bootJar {
layered {
includeLayerTools = false
}
}
// end::layered[]

View File

@@ -0,0 +1,18 @@
import org.springframework.boot.gradle.tasks.bundling.BootJar
plugins {
java
id("org.springframework.boot") version "{version}"
}
tasks.getByName<BootJar>("bootJar") {
mainClassName = "com.example.ExampleApplication"
}
// tag::layered[]
tasks.getByName<BootJar>("bootJar") {
layered {
includeLayerTools = false
}
}
// end::layered[]