Skip to content

Commit 751fc9f

Browse files
committed
Fix includeProjectDependencies with Kotlin DSL
1 parent 4095f4e commit 751fc9f

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/gradle/packaging/boot-jar-layered-custom.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ tasks.named<BootJar>("bootJar") {
1919
intoLayer("application")
2020
}
2121
dependencies {
22+
intoLayer("application") {
23+
includeProjectDependencies()
24+
}
2225
intoLayer("snapshot-dependencies") {
2326
include("*:*:*SNAPSHOT")
2427
}

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LayeredSpec.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,20 @@ private Layers createLayers() {
223223
/**
224224
* Base class for specs that control the layers to which a category of content should
225225
* belong.
226+
*
227+
* @param <S> the type of {@link IntoLayerSpec} used by this spec
226228
*/
227-
public abstract static class IntoLayersSpec implements Serializable {
229+
public abstract static class IntoLayersSpec<S extends IntoLayerSpec> implements Serializable {
228230

229231
private final List<IntoLayerSpec> intoLayers;
230232

231-
private final Function<String, IntoLayerSpec> specFactory;
233+
private final Function<String, S> specFactory;
232234

233235
boolean isEmpty() {
234236
return this.intoLayers.isEmpty();
235237
}
236238

237-
IntoLayersSpec(Function<String, IntoLayerSpec> specFactory, IntoLayerSpec... spec) {
239+
IntoLayersSpec(Function<String, S> specFactory, IntoLayerSpec... spec) {
238240
this.intoLayers = new ArrayList<>(Arrays.asList(spec));
239241
this.specFactory = specFactory;
240242
}
@@ -247,8 +249,8 @@ public void intoLayer(String layer, Closure<?> closure) {
247249
intoLayer(layer, Closures.asAction(closure));
248250
}
249251

250-
public void intoLayer(String layer, Action<IntoLayerSpec> action) {
251-
IntoLayerSpec spec = this.specFactory.apply(layer);
252+
public void intoLayer(String layer, Action<S> action) {
253+
S spec = this.specFactory.apply(layer);
252254
action.execute(spec);
253255
this.intoLayers.add(spec);
254256
}
@@ -384,7 +386,7 @@ ContentSelector<Library> asLibrarySelector(Function<String, ContentFilter<Librar
384386
* An {@link IntoLayersSpec} that controls the layers to which application classes and
385387
* resources belong.
386388
*/
387-
public static class ApplicationSpec extends IntoLayersSpec {
389+
public static class ApplicationSpec extends IntoLayersSpec<IntoLayerSpec> {
388390

389391
/**
390392
* Creates a new {@code ApplicationSpec} with the given {@code contents}.
@@ -413,7 +415,7 @@ public IntoLayerSpec apply(String layer) {
413415
/**
414416
* An {@link IntoLayersSpec} that controls the layers to which dependencies belong.
415417
*/
416-
public static class DependenciesSpec extends IntoLayersSpec implements Serializable {
418+
public static class DependenciesSpec extends IntoLayersSpec<DependenciesIntoLayerSpec> implements Serializable {
417419

418420
/**
419421
* Creates a new {@code DependenciesSpec} with the given {@code contents}.
@@ -428,10 +430,11 @@ List<ContentSelector<Library>> asSelectors() {
428430
(spec) -> ((DependenciesIntoLayerSpec) spec).asLibrarySelector(LibraryContentFilter::new));
429431
}
430432

431-
private static final class IntoLayerSpecFactory implements Function<String, IntoLayerSpec>, Serializable {
433+
private static final class IntoLayerSpecFactory
434+
implements Function<String, DependenciesIntoLayerSpec>, Serializable {
432435

433436
@Override
434-
public IntoLayerSpec apply(String layer) {
437+
public DependenciesIntoLayerSpec apply(String layer) {
435438
return new DependenciesIntoLayerSpec(layer);
436439
}
437440

0 commit comments

Comments
 (0)