/** * Converts {@link ArchiveAsset}s in parentDir to {@link ByteArrayAsset}s. * <p> * By default {@link org.jboss.shrinkwrap.api.exporter.ExplodedExporter} exports {@link ArchiveAsset}s in parent * archive as exploded directories. Since we need to export them as archives, we convert them to * {@link ByteArrayAsset}s. * * @param a Archive to fix * @param parentDir Directory to scan for {@link ArchiveAsset}s */ private static void fixArchiveAssets(Archive<?> a, String parentDir) { Node n = a.get(parentDir); Archive<?> tmp = ShrinkWrap.create(JavaArchive.class); List<ArchivePath> pathsToDelete = new ArrayList<>(); for (Node child : n.getChildren()) { Asset childAsset = child.getAsset(); if (childAsset instanceof ArchiveAsset && child.getPath().get().endsWith(".jar")) { LOG.fine("Converting archive " + child.getPath().get() + " to ByteArrayAsset"); ArchiveAsset archiveAsset = (ArchiveAsset) childAsset; ByteArrayAsset bas = new ByteArrayAsset(archiveAsset.openStream()); pathsToDelete.add(child.getPath()); tmp.add(bas, child.getPath()); } } for (ArchivePath ap : pathsToDelete) { a.delete(ap); } a.merge(tmp); }