Browse Source

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 6 years ago
parent
commit
3f806aa513
  1. 2
      spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootJarTests.java
  2. 5
      spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/ImplicitLayerResolver.java
  3. 6
      spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/StandardLayers.java
  4. 4
      spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/ImplicitLayerResolverTests.java

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

@ -100,7 +100,7 @@ class BootJarTests extends AbstractBootArchiveTests<TestBootJar> { @@ -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");
}
}

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

@ -24,8 +24,13 @@ package org.springframework.boot.loader.tools; @@ -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;
}

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

@ -41,6 +41,11 @@ public abstract class StandardLayers implements Layers { @@ -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 { @@ -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);

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

@ -34,8 +34,8 @@ class ImplicitLayerResolverTests { @@ -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