in src/main/java/org/apache/sling/feature/scanner/impl/BundleDescriptorImpl.java [80:103]
static Manifest getManifest(URL file) throws IOException {
Manifest manifest = null;
try {
if ("file".equals(file.getProtocol()) && new File(file.toURI()).isDirectory()) {
// it's a directory
Path manifestPath = Paths.get(file.toURI()).resolve("META-INF/MANIFEST.MF");
if (Files.exists(manifestPath)) {
try (FileInputStream is = new FileInputStream(manifestPath.toFile())) {
manifest = new Manifest(is);
}
}
} else {
try (JarFile jarFile = IOUtils.getJarFileFromURL(file, true, null)) {
manifest = jarFile.getManifest();
} catch ( final IOException ioe) {
// rethrow with more info
throw new IOException(file + " : " + ioe.getMessage(), ioe);
}
}
} catch (URISyntaxException e) {
throw new IOException("Failed to determine if the file is a directory", e);
}
return manifest;
}