Skip to content

Commit 3f806aa

Browse files
committed
Create a new layer for loader classes
Create a dedicated layer that is used to hold the launcher support classes. The layer sits between `dependencies` and `snapshot-dependencies` so that the layer is sensible for both SNAPSHOT and RELEASE versions of Spring Boot Closes gh-20529
1 parent 7bc7d86 commit 3f806aa

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootJarTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void whenJarIsLayeredThenManifestContainsEntryForLayersIndexInPlaceOfClassesAndL
100100
@Test
101101
void whenJarIsLayeredThenLayersIndexIsPresentAndListsLayersInOrder() throws IOException {
102102
try (JarFile jarFile = new JarFile(createLayeredJar())) {
103-
assertThat(entryLines(jarFile, "BOOT-INF/layers.idx")).containsExactly("dependencies",
103+
assertThat(entryLines(jarFile, "BOOT-INF/layers.idx")).containsExactly("dependencies", "spring-boot-loader",
104104
"snapshot-dependencies", "application");
105105
}
106106
}

spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/ImplicitLayerResolver.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@
2424
*/
2525
class ImplicitLayerResolver extends StandardLayers {
2626

27+
private static final String SPRING_BOOT_LOADER_PREFIX = "org/springframework/boot/loader/";
28+
2729
@Override
2830
public Layer getLayer(String name) {
31+
if (name.startsWith(SPRING_BOOT_LOADER_PREFIX)) {
32+
return SPRING_BOOT_LOADER;
33+
}
2934
return APPLICATION;
3035
}
3136

spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/StandardLayers.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public abstract class StandardLayers implements Layers {
4141
*/
4242
public static final Layer DEPENDENCIES = new Layer("dependencies");
4343

44+
/**
45+
* The spring boot loader layer.
46+
*/
47+
public static final Layer SPRING_BOOT_LOADER = new Layer("spring-boot-loader");
48+
4449
/**
4550
* The snapshot dependencies layer.
4651
*/
@@ -55,6 +60,7 @@ public abstract class StandardLayers implements Layers {
5560
static {
5661
List<Layer> layers = new ArrayList<>();
5762
layers.add(DEPENDENCIES);
63+
layers.add(SPRING_BOOT_LOADER);
5864
layers.add(SNAPSHOT_DEPENDENCIES);
5965
layers.add(APPLICATION);
6066
LAYERS = Collections.unmodifiableList(layers);

spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/ImplicitLayerResolverTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class ImplicitLayerResolverTests {
3434

3535
@Test
3636
void iteratorReturnsLayers() {
37-
assertThat(this.layers).containsExactly(StandardLayers.DEPENDENCIES, StandardLayers.SNAPSHOT_DEPENDENCIES,
38-
StandardLayers.APPLICATION);
37+
assertThat(this.layers).containsExactly(StandardLayers.DEPENDENCIES, StandardLayers.SPRING_BOOT_LOADER,
38+
StandardLayers.SNAPSHOT_DEPENDENCIES, StandardLayers.APPLICATION);
3939
}
4040

4141
@Test

0 commit comments

Comments
 (0)