@Override public Map<ArchivePath, Node> getContent() { return delegate.getContent(); }
@Override public Map<ArchivePath, Node> getContent(Filter<ArchivePath> filter) { return delegate.getContent(filter); }
private static Map<ArchivePath, Node> getMatchingFilesFromJar(List<String> patterns, JavaArchive archive) { return archive.getContent(path -> { for (String pattern : patterns) { if (SelectorUtils.match(pattern, path.get())) { return true; } } return false; }); } }
private ArrayList<String> getPaths(JavaArchive archive2) { ArrayList<String> rc = new ArrayList<String>(); for (ArchivePath path : archive2.getContent().keySet()) { String file = path.get(); file = file.substring(1); // to strip the leading / rc.add(file); } return rc; }
protected List<Properties> extractPomProperties(final Node node) { final List<Properties> properties = new ArrayList<>(); try (final InputStream in = node.getAsset().openStream()) { ShrinkWrap.create(ZipImporter.class) .importFrom(in) .as(JavaArchive.class) .getContent(p -> POM_PROPERTIES.matcher(p.get()).matches()) .values() .forEach(propNode -> { final Properties props = new Properties(); try (final InputStream in2 = propNode.getAsset().openStream()) { props.load(in2); } catch (IOException e) { throw new RuntimeException(e); } properties.add(props); }); } catch (IOException e) { throw new RuntimeException(e); } return properties; }
Map<ArchivePath, Node> content = archive.getContent(); for (ArchivePath path : content.keySet()) { if (path.get().endsWith(".class") && !path.get().endsWith("module-info.class")) {
Map<ArchivePath, Node> content = archive.getContent(); for (ArchivePath path : content.keySet()) { if (path.get().endsWith(".class") && !path.get().endsWith("module-info.class")) {
Map<ArchivePath, Node> content = archive.getContent(); for (ArchivePath path : content.keySet()) { if (path.get().endsWith(".class") && !path.get().endsWith("module-info.class")) {
public static void write(File dir, File jar, Class<?>... clazzes) { JavaArchive jarArchieve; Map<ArchivePath, Node> contents = null; if (jar.exists()) { if(OS.isWindows()){ jar.delete(); } else { JavaArchive old = ShrinkWrap.createFromZipFile(JavaArchive.class, jar); contents = old.getContent(); // TODO: windows cannot delete jar at this point (return false) // calling delete even cause NPE in shrink wrap for unknown reason jar.delete(); } } jarArchieve = ShrinkWrap.create(JavaArchive.class, jar.getName()); if (contents != null) { for (Node n : filter(contents, clazzes)) { jarArchieve.add(n.getAsset(), n.getPath()); } } for (Class<?> clazz : clazzes) { jarArchieve.addClass(clazz); } jarArchieve.as(ZipExporter.class).exportTo(jar, true); }
for (Node content : resourceRoot.getContent().values()) { final String path = content.getPath().get(); if (path.endsWith(".class")) {
/** * Makes sure classes in the default package, and only in the default package, are added. * * SHRINKWRAP-233, SHRINKWRAP-302 */ @Test public void testAddDefaultPackage() { JavaArchive archive = ShrinkWrap.create(JavaArchive.class); archive.addDefaultPackage(); assertClassesWereAdded(archive); /* * It should have added only the following three classes: 1. /DefaultPackageAddTestCase.class 2. * /ClassInDefaultPackage.class 3. /ClassInDefaultPackage$InnerClassInDefaultPackage.class */ final int expectedSize = 3; final int size = archive.getContent().size(); Assert.assertEquals("Not the expected number of assets added to the archive", expectedSize, size); }