use of org.springframework.boot.loader.archive.Archive in project spring-boot by spring-projects.
the class WarLauncherTests method explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath.
@Test
public void explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath() throws Exception {
File explodedRoot = explode(createJarArchive("archive.war", "WEB-INF"));
WarLauncher launcher = new WarLauncher(new ExplodedArchive(explodedRoot, true));
List<Archive> archives = launcher.getClassPathArchives();
assertThat(archives).hasSize(2);
assertThat(getUrls(archives)).containsOnly(new File(explodedRoot, "WEB-INF/classes").toURI().toURL(), new URL("jar:" + new File(explodedRoot, "WEB-INF/lib/foo.jar").toURI().toURL() + "!/"));
}
use of org.springframework.boot.loader.archive.Archive in project spring-boot by spring-projects.
the class WarLauncherTests method archivedWarHasOnlyWebInfClassesAndContentsOWebInfLibOnClasspath.
@Test
public void archivedWarHasOnlyWebInfClassesAndContentsOWebInfLibOnClasspath() throws Exception {
File jarRoot = createJarArchive("archive.war", "WEB-INF");
WarLauncher launcher = new WarLauncher(new JarFileArchive(jarRoot));
List<Archive> archives = launcher.getClassPathArchives();
assertThat(archives).hasSize(2);
assertThat(getUrls(archives)).containsOnly(new URL("jar:" + jarRoot.toURI().toURL() + "!/WEB-INF/classes!/"), new URL("jar:" + jarRoot.toURI().toURL() + "!/WEB-INF/lib/foo.jar!/"));
}
use of org.springframework.boot.loader.archive.Archive in project spring-boot by spring-projects.
the class PropertiesLauncher method getNestedArchives.
private List<Archive> getNestedArchives(String root) throws Exception {
if (root.startsWith("/") || this.parent.getUrl().equals(this.home.toURI().toURL())) {
// If home dir is same as parent archive, no need to add it twice.
return null;
}
Archive parent = this.parent;
if (root.startsWith("jar:file:") && root.contains("!")) {
int index = root.indexOf("!");
String file = root.substring("jar:file:".length(), index);
parent = new JarFileArchive(new File(file));
root = root.substring(index + 1, root.length());
while (root.startsWith("/")) {
root = root.substring(1);
}
}
EntryFilter filter = new PrefixMatchingArchiveFilter(root);
return parent.getNestedArchives(filter);
}
use of org.springframework.boot.loader.archive.Archive in project spring-boot by spring-projects.
the class PropertiesLauncher method getClassPathArchives.
@Override
protected List<Archive> getClassPathArchives() throws Exception {
List<Archive> lib = new ArrayList<>();
for (String path : this.paths) {
for (Archive archive : getClassPathArchives(path)) {
if (archive instanceof ExplodedArchive) {
List<Archive> nested = new ArrayList<>(archive.getNestedArchives(new ArchiveEntryFilter()));
nested.add(0, archive);
lib.addAll(nested);
} else {
lib.add(archive);
}
}
}
addNestedEntries(lib);
return lib;
}
use of org.springframework.boot.loader.archive.Archive in project spring-boot by spring-projects.
the class PropertiesLauncher method getClassPathArchives.
private List<Archive> getClassPathArchives(String path) throws Exception {
String root = cleanupPath(stripFileUrlPrefix(path));
List<Archive> lib = new ArrayList<>();
File file = new File(root);
if (!isAbsolutePath(root)) {
file = new File(this.home, root);
}
if (file.isDirectory()) {
debug("Adding classpath entries from " + file);
Archive archive = new ExplodedArchive(file, false);
lib.add(archive);
}
Archive archive = getArchive(file);
if (archive != null) {
debug("Adding classpath entries from archive " + archive.getUrl() + root);
lib.add(archive);
}
List<Archive> nestedArchives = getNestedArchives(root);
if (nestedArchives != null) {
debug("Adding classpath entries from nested " + root);
lib.addAll(nestedArchives);
}
return lib;
}
Aggregations