use of org.springframework.boot.loader.archive.JarFileArchive 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.JarFileArchive 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.JarFileArchive in project spring-boot by spring-projects.
the class Launcher method createArchive.
protected final Archive createArchive() throws Exception {
ProtectionDomain protectionDomain = getClass().getProtectionDomain();
CodeSource codeSource = protectionDomain.getCodeSource();
URI location = (codeSource == null ? null : codeSource.getLocation().toURI());
String path = (location == null ? null : location.getSchemeSpecificPart());
if (path == null) {
throw new IllegalStateException("Unable to determine code source archive");
}
File root = new File(path);
if (!root.exists()) {
throw new IllegalStateException("Unable to determine code source archive from " + root);
}
return (root.isDirectory() ? new ExplodedArchive(root) : new JarFileArchive(root));
}
use of org.springframework.boot.loader.archive.JarFileArchive in project spring-boot by spring-projects.
the class JarLauncherTests method archivedJarHasOnlyBootInfClassesAndContentsOfBootInfLibOnClasspath.
@Test
public void archivedJarHasOnlyBootInfClassesAndContentsOfBootInfLibOnClasspath() throws Exception {
File jarRoot = createJarArchive("archive.jar", "BOOT-INF");
JarLauncher launcher = new JarLauncher(new JarFileArchive(jarRoot));
List<Archive> archives = launcher.getClassPathArchives();
assertThat(archives).hasSize(2);
assertThat(getUrls(archives)).containsOnly(new URL("jar:" + jarRoot.toURI().toURL() + "!/BOOT-INF/classes!/"), new URL("jar:" + jarRoot.toURI().toURL() + "!/BOOT-INF/lib/foo.jar!/"));
}
Aggregations