private void addNestedEntries(List<Archive> lib) { // The parent archive might have "BOOT-INF/lib/" and "BOOT-INF/classes/" // directories, meaning we are running from an executable JAR. We add nested // entries from there with low priority (i.e. at end). try { lib.addAll(this.parent.getNestedArchives(new EntryFilter() { @Override public boolean matches(Entry entry) { if (entry.isDirectory()) { return entry.getName().startsWith(JarLauncher.BOOT_INF_CLASSES); } return entry.getName().startsWith(JarLauncher.BOOT_INF_LIB); } })); } catch (IOException ex) { // Ignore } }
private Archive getNestedArchive(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; } EntryFilter filter = new PrefixMatchingArchiveFilter(root); if (this.parent.getNestedArchives(filter).isEmpty()) { return null; } // If there are more archives nested in this subdirectory (root) then create a new // virtual archive for them, and have it added to the classpath return new FilteredArchive(this.parent, filter); }
@Override public List<Archive> getNestedArchives(final EntryFilter filter) throws IOException { return this.parent.getNestedArchives(new EntryFilter() { @Override public boolean matches(Entry entry) { return FilteredArchive.this.filter.matches(entry) && filter.matches(entry); } }); }
@Override protected List<Archive> getClassPathArchives() throws Exception { List<Archive> archives = new ArrayList<Archive>( this.archive.getNestedArchives(new EntryFilter() { @Override public boolean matches(Entry entry) { return isNestedArchive(entry); } })); postProcessClassPathArchives(archives); return archives; }
private Archive getNestedArchive(final 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; } EntryFilter filter = new PrefixMatchingArchiveFilter(root); if (this.parent.getNestedArchives(filter).isEmpty()) { return null; } // If there are more archives nested in this subdirectory (root) then create a new // virtual archive for them, and have it added to the classpath return new FilteredArchive(this.parent, filter); }
FilteredArchive(Archive parent, EntryFilter filter) { this.parent = parent; this.filter = filter; }