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
pull/20830/head
Phillip Webb 5 years ago
parent 7bc7d86ad4
commit 3f806aa513

@ -100,7 +100,7 @@ class BootJarTests extends AbstractBootArchiveTests<TestBootJar> {
@Test
void whenJarIsLayeredThenLayersIndexIsPresentAndListsLayersInOrder() throws IOException {
try (JarFile jarFile = new JarFile(createLayeredJar())) {
assertThat(entryLines(jarFile, "BOOT-INF/layers.idx")).containsExactly("dependencies",
assertThat(entryLines(jarFile, "BOOT-INF/layers.idx")).containsExactly("dependencies", "spring-boot-loader",
"snapshot-dependencies", "application");
}
}

@ -24,8 +24,13 @@ package org.springframework.boot.loader.tools;
*/
class ImplicitLayerResolver extends StandardLayers {
private static final String SPRING_BOOT_LOADER_PREFIX = "org/springframework/boot/loader/";
@Override
public Layer getLayer(String name) {
if (name.startsWith(SPRING_BOOT_LOADER_PREFIX)) {
return SPRING_BOOT_LOADER;
}
return APPLICATION;
}

@ -41,6 +41,11 @@ public abstract class StandardLayers implements Layers {
*/
public static final Layer DEPENDENCIES = new Layer("dependencies");
/**
* The spring boot loader layer.
*/
public static final Layer SPRING_BOOT_LOADER = new Layer("spring-boot-loader");
/**
* The snapshot dependencies layer.
*/
@ -55,6 +60,7 @@ public abstract class StandardLayers implements Layers {
static {
List<Layer> layers = new ArrayList<>();
layers.add(DEPENDENCIES);
layers.add(SPRING_BOOT_LOADER);
layers.add(SNAPSHOT_DEPENDENCIES);
layers.add(APPLICATION);
LAYERS = Collections.unmodifiableList(layers);

@ -34,8 +34,8 @@ class ImplicitLayerResolverTests {
@Test
void iteratorReturnsLayers() {
assertThat(this.layers).containsExactly(StandardLayers.DEPENDENCIES, StandardLayers.SNAPSHOT_DEPENDENCIES,
StandardLayers.APPLICATION);
assertThat(this.layers).containsExactly(StandardLayers.DEPENDENCIES, StandardLayers.SPRING_BOOT_LOADER,
StandardLayers.SNAPSHOT_DEPENDENCIES, StandardLayers.APPLICATION);
}
@Test

Loading…
Cancel
Save