diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/gradle/packaging/boot-jar-layered-custom.gradle.kts b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/gradle/packaging/boot-jar-layered-custom.gradle.kts index 851ee90179..a4f53d2be1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/gradle/packaging/boot-jar-layered-custom.gradle.kts +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/gradle/packaging/boot-jar-layered-custom.gradle.kts @@ -19,6 +19,9 @@ tasks.named("bootJar") { intoLayer("application") } dependencies { + intoLayer("application") { + includeProjectDependencies() + } intoLayer("snapshot-dependencies") { include("*:*:*SNAPSHOT") } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LayeredSpec.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LayeredSpec.java index f27954c6d9..bf2c55ea45 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LayeredSpec.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LayeredSpec.java @@ -223,18 +223,20 @@ public class LayeredSpec { /** * Base class for specs that control the layers to which a category of content should * belong. + * + * @param the type of {@link IntoLayerSpec} used by this spec */ - public abstract static class IntoLayersSpec implements Serializable { + public abstract static class IntoLayersSpec implements Serializable { private final List intoLayers; - private final Function specFactory; + private final Function specFactory; boolean isEmpty() { return this.intoLayers.isEmpty(); } - IntoLayersSpec(Function specFactory, IntoLayerSpec... spec) { + IntoLayersSpec(Function specFactory, IntoLayerSpec... spec) { this.intoLayers = new ArrayList<>(Arrays.asList(spec)); this.specFactory = specFactory; } @@ -247,8 +249,8 @@ public class LayeredSpec { intoLayer(layer, Closures.asAction(closure)); } - public void intoLayer(String layer, Action action) { - IntoLayerSpec spec = this.specFactory.apply(layer); + public void intoLayer(String layer, Action action) { + S spec = this.specFactory.apply(layer); action.execute(spec); this.intoLayers.add(spec); } @@ -384,7 +386,7 @@ public class LayeredSpec { * An {@link IntoLayersSpec} that controls the layers to which application classes and * resources belong. */ - public static class ApplicationSpec extends IntoLayersSpec { + public static class ApplicationSpec extends IntoLayersSpec { /** * Creates a new {@code ApplicationSpec} with the given {@code contents}. @@ -413,7 +415,7 @@ public class LayeredSpec { /** * An {@link IntoLayersSpec} that controls the layers to which dependencies belong. */ - public static class DependenciesSpec extends IntoLayersSpec implements Serializable { + public static class DependenciesSpec extends IntoLayersSpec implements Serializable { /** * Creates a new {@code DependenciesSpec} with the given {@code contents}. @@ -428,10 +430,11 @@ public class LayeredSpec { (spec) -> ((DependenciesIntoLayerSpec) spec).asLibrarySelector(LibraryContentFilter::new)); } - private static final class IntoLayerSpecFactory implements Function, Serializable { + private static final class IntoLayerSpecFactory + implements Function, Serializable { @Override - public IntoLayerSpec apply(String layer) { + public DependenciesIntoLayerSpec apply(String layer) { return new DependenciesIntoLayerSpec(layer); }