Util { public static Map<URL, List<URL>> mapManifestHeaderResources(final String headerName, final ClassLoader classLoader) throws IOException { Map<URL, List<URL>> map = new LinkedHashMap<>(); Enumeration<URL> resEnum = classLoader.getResources(JarFile.MANIFEST_NAME); while (resEnum.hasMoreElements()) { URL url = resEnum.nextElement(); try (InputStream is = url.openStream()) { Manifest manifest = new Manifest(is); List<URL> headerResources = resolveManifestResources(url, getManifestHeaderValues(manifest, headerName)); map.put(url, headerResources); } } return map; } private  Util(); static Session wrapSessionReadOnly(final Session session); static List<String> getManifestHeaderValues(final Manifest manifest, final String headerName); static String escapeManifestHeaderValue(final @NotNull String... values); static String escapeManifestHeaderValues(final @NotNull List<String> values); static List<URL> resolveManifestResources(final URL manifestUrl, final List<String> resources); static Map<URL, List<URL>> mapManifestHeaderResources(final String headerName, final ClassLoader classLoader); static Map<URL, List<URL>> mapManifestHeaderResources(final String headerName, final List<File> files); static Map<URL, List<URL>> mapManifestHeaderResources(final String headerName, final URL manifestUrl); static Predicate<T> debugFilter(final Logger logger, final String format); static Predicate<T> traceFilter(final Logger logger, final String format); @Deprecated static Function<T, M> composeTry(final Function<R, M> monadUnit,
                                                      final Supplier<M> monadZero,
                                                      final TryFunction<T, R> onElement,
                                                      final BiConsumer<T, Exception> onError); @Deprecated static Function<T, Optional<R>> optFunc(final Function<T, R> inputFunc); @Deprecated static Function<T, R> compose(final Function<T, I> before, final Function<I, R> after);  }
@Test public void testMapManifestHeaderResources() throws Exception { final Logger logger = getLoggerFactory().getLogger(Util.class); final Level oldLevel = logger.getLevel(); final File mfDir = new File("src/test/resources/utiljar"); final File mfFile = new File(mfDir, JarFile.MANIFEST_NAME); try (InputStream mfStream = new FileInputStream(mfFile)) { Manifest manifest = new Manifest(mfStream); final File targetDir = new File("target/test-temp"); targetDir.mkdirs(); final File mfJar = new File(targetDir, "utiljar.jar"); if (mfJar.exists()) { mfJar.delete(); } try (JarOutputStream mfJarOut = new JarOutputStream(new FileOutputStream(mfJar), manifest)) { } Map<URL, List<URL>> dirMapped = Util.mapManifestHeaderResources("Good-RelPaths", Collections.singletonList(mfDir)); assertEquals("Expect two good paths for directory manifest: " + dirMapped, 2, dirMapped.values().iterator().next().size()); Map<URL, List<URL>> mapped = Util.mapManifestHeaderResources("Good-RelPaths", Collections.singletonList(mfJar)); assertEquals("Expect two good paths for jar manifest: " + mapped, 2, mapped.values().iterator().next().size()); Map<URL, List<URL>> bothMapped = Util.mapManifestHeaderResources("Good-RelPaths", Arrays.asList(mfDir, mfJar)); assertEquals("Expect two entries in both mapped: " + bothMapped, 2, bothMapped.size()); assertTrue("Expect two good paths for all entries when both mapped: " + bothMapped, bothMapped.values().stream().allMatch(resources -> resources.size() == 2)); } finally { logger.setLevel(oldLevel); } }