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 f9e93049512..d5d78a40811 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 61998904493..b2f6842f21f 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 @@ -175,18 +175,20 @@ public abstract 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; } @@ -195,8 +197,8 @@ public abstract class LayeredSpec { this.intoLayers.add(this.specFactory.apply(layer)); } - 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); } @@ -330,7 +332,7 @@ public abstract 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 { @Inject public ApplicationSpec() { @@ -364,7 +366,7 @@ public abstract 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 { @Inject public DependenciesSpec() { @@ -384,10 +386,11 @@ public abstract 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); }