Merge branch '2.5.x' into 2.6.x
Closes gh-30790
This commit is contained in:
@@ -110,7 +110,8 @@ public class BootJar extends Jar implements BootArchive {
|
||||
private void moveMetaInfToRoot(CopySpec spec) {
|
||||
spec.eachFile((file) -> {
|
||||
String path = file.getRelativeSourcePath().getPathString();
|
||||
if (path.startsWith("META-INF/") && !path.equals("META-INF/aop.xml") && !path.endsWith(".kotlin_module")) {
|
||||
if (path.startsWith("META-INF/") && !path.equals("META-INF/aop.xml") && !path.endsWith(".kotlin_module")
|
||||
&& !path.startsWith("META-INF/services/")) {
|
||||
this.support.moveToRoot(file);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -163,6 +163,27 @@ class BootJarTests extends AbstractBootArchiveTests<BootJar> {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void metaInfServicesEntryIsPackagedBeneathClassesDirectory() throws IOException {
|
||||
getTask().getMainClass().set("com.example.Main");
|
||||
File classpathDirectory = new File(this.temp, "classes");
|
||||
File service = new File(classpathDirectory, "META-INF/services/com.example.Service");
|
||||
service.getParentFile().mkdirs();
|
||||
service.createNewFile();
|
||||
File applicationClass = new File(classpathDirectory, "com/example/Application.class");
|
||||
applicationClass.getParentFile().mkdirs();
|
||||
applicationClass.createNewFile();
|
||||
getTask().classpath(classpathDirectory);
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry("BOOT-INF/classes/com/example/Application.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("com/example/Application.class")).isNull();
|
||||
assertThat(jarFile.getEntry("BOOT-INF/classes/META-INF/services/com.example.Service")).isNotNull();
|
||||
assertThat(jarFile.getEntry("META-INF/services/com.example.Service")).isNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private File createPopulatedJar() throws IOException {
|
||||
addContent();
|
||||
executeTask();
|
||||
|
||||
Reference in New Issue
Block a user