Allow bootWar to package webapp resources in dirs that overlap loader
Previously, the presence of a src/main/webapp/org directory would cause the execution of BootWar to fail due to an attempt to write a duplicate org/ entry to the zip output stream. This commit updates BootZipCopyAction so that FileTreeElements that match a directory entry created while writing the loader classes are skipped. Closes gh-8972
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.boot.gradle.tasks.bundling;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
@@ -76,4 +77,21 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void webappResourcesInDirectoriesThatOverlapWithLoaderCanBePackaged()
|
||||
throws IOException {
|
||||
File webappFolder = this.temp.newFolder("src", "main", "webapp");
|
||||
File orgFolder = new File(webappFolder, "org");
|
||||
orgFolder.mkdir();
|
||||
new File(orgFolder, "foo.txt").createNewFile();
|
||||
getTask().from(webappFolder);
|
||||
getTask().setMainClass("com.example.Main");
|
||||
getTask().execute();
|
||||
assertThat(getTask().getArchivePath().exists());
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchivePath())) {
|
||||
assertThat(jarFile.getEntry("org/")).isNotNull();
|
||||
assertThat(jarFile.getEntry("org/foo.txt")).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user