Spring boot 2.3.0 has the layered fat jars which are optimized for container image builds. Now, the Spring documentation discusses only Maven build tool, and not Gradle.
Please, what do we need to do to the Gradle plugin to allow it to build a "layered jar" for spring boot?
For example: if extracting a jar with the command java -Djarmode=layertools -jar app.jar extract
which has been made with Gradle Spring boot plugin id("org.springframework.boot") version "2.3.0.RELEASE"
it fails with message: Unsupported jarmode 'layertools'
. Basically if the jar has been built with ./gradlew bootJar
it seems layered jar is not active by default.
Extracting a layered jar should result in the following directories, and these are then copied into another container image for execution, and only if lower layers have changed does the caching system have to re-read them. Layered jar extracted with -Djarmode=layertools
flag:
./dependencies/
./snapshot-dependencies/
./resources/
./application/
The blog at spring Spring Blog 2.3.0.ML discusses Maven build tool and the configuration:
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>LAYERED_JAR</layout>
</configuration>
How do we enable the same configuration for Gradle plugin?