Relocate launcher classes
Create alternative launcher classes under the package `org.springframework.boot.loader.launch` and use them in favor of the previous location. This update is designed to improve compatibility with future changes in the loader. Closes gh-37667
This commit is contained in:
@@ -166,7 +166,7 @@ class PackagingDocumentationTests {
|
||||
assertThat(file).isFile();
|
||||
try (JarFile jar = new JarFile(file)) {
|
||||
assertThat(jar.getManifest().getMainAttributes().getValue("Main-Class"))
|
||||
.isEqualTo("org.springframework.boot.loader.PropertiesLauncher");
|
||||
.isEqualTo("org.springframework.boot.loader.launch.PropertiesLauncher");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -270,7 +270,9 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
void loaderIsWrittenToTheRootOfTheJarWhenUsingThePropertiesLauncher() throws IOException {
|
||||
this.task.getMainClass().set("com.example.Main");
|
||||
executeTask();
|
||||
this.task.getManifest().getAttributes().put("Main-Class", "org.springframework.boot.loader.PropertiesLauncher");
|
||||
this.task.getManifest()
|
||||
.getAttributes()
|
||||
.put("Main-Class", "org.springframework.boot.loader.launch.PropertiesLauncher");
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry("org/springframework/boot/loader/LaunchedURLClassLoader.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("org/springframework/boot/loader/")).isNotNull();
|
||||
@@ -362,7 +364,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class"))
|
||||
.isEqualTo("com.example.CustomLauncher");
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class")).isEqualTo("com.example.Main");
|
||||
assertThat(jarFile.getEntry("org/springframework/boot/loader/LaunchedURLClassLoader.class")).isNull();
|
||||
assertThat(jarFile.getEntry("org/springframework/boot/loader/launch/LaunchedClassLoader.class")).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class BootJarTests extends AbstractBootArchiveTests<BootJar> {
|
||||
|
||||
BootJarTests() {
|
||||
super(BootJar.class, "org.springframework.boot.loader.JarLauncher", "BOOT-INF/lib/", "BOOT-INF/classes/",
|
||||
super(BootJar.class, "org.springframework.boot.loader.launch.JarLauncher", "BOOT-INF/lib/", "BOOT-INF/classes/",
|
||||
"BOOT-INF/");
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
|
||||
BootWarTests() {
|
||||
super(BootWar.class, "org.springframework.boot.loader.WarLauncher", "WEB-INF/lib/", "WEB-INF/classes/",
|
||||
super(BootWar.class, "org.springframework.boot.loader.launch.WarLauncher", "WEB-INF/lib/", "WEB-INF/classes/",
|
||||
"WEB-INF/");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user