Gradle layered JARs option doesn't work in 2.3.0.BUILD-SNAPSHOT. It was layered() in 2.3.0.M3, but it seems to be changed to layers(). I tried with it, but it failed as follows:

$ ./gradlew clean bootJar

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/user/IdeaProjects/spring-boot-throwaway-branches/build.gradle' line: 44

* What went wrong:
A problem occurred evaluating root project 'spring-boot-throwaway-branches'.
> Could not find method layers() for arguments [] on task ':bootJar' of type org.springframework.boot.gradle.tasks.bundling.BootJar.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 725ms
$

This is a sample project I used: https://github.com/izeye/spring-boot-throwaway-branches/tree/minimal-layered-jar

Comment From: wilkinsona

Thanks for the sample, @izeye. Unfortunately it works for me:

[$ minimal-layered-jar]: ./gradlew clean build

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 2s
6 actionable tasks: 6 executed

Note that I removed mavenLocal() from build.gradle to avoid a locally published snapshot from influencing the outcome of the build:

[$ minimal-layered-jar]: git diff
diff --git a/build.gradle b/build.gradle
index 16712a6..e4b48a4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -28,7 +28,6 @@ repositories {
     maven { url "https://repo.spring.io/libs-release" }
     maven { url "https://repo.spring.io/libs-milestone" }
     maven { url "https://repo.spring.io/snapshot" }
-    mavenLocal()
 }

 dependencies {

I wonder if that's what caused the problem in your case?

Comment From: izeye

@wilkinsona Ah, you're right. I should have double-checked it. It was due to mavenLocal() in buildscript.repositories block: https://github.com/izeye/spring-boot-throwaway-branches/blob/947473fcb914e8439a644855a3d0164cd7534677/build.gradle#L3

Sorry for the noise.