Java Code Examples for org.jboss.shrinkwrap.api.Node#getChildren()

The following examples show how to use org.jboss.shrinkwrap.api.Node#getChildren() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileDeploymentUtils.java    From camel-spring-boot with Apache License 2.0 6 votes vote down vote up
public static void materializeSubdirectories(File entryDirectory, Node node) throws DeploymentException, IOException {
    for (Node child : node.getChildren()) {
        if (child.getAsset() == null) {
            materializeSubdirectories(entryDirectory, child);
        } else {
            if (ClassPathDirectory.isMarkerFileArchivePath(child.getPath())) {
                // Do not materialize the marker file
                continue;
            }
            // E.g. META-INF/my-super-descriptor.xml
            File resourceFile = new File(entryDirectory, child.getPath().get().replace(DELIMITER_RESOURCE_PATH, File.separatorChar));
            File resoureDirectory = resourceFile.getParentFile();
            if (!resoureDirectory.exists() && !resoureDirectory.mkdirs()) {
                throw new DeploymentException("Could not create class path directory: " + entryDirectory);
            }
            resourceFile.createNewFile();
            try (InputStream in = child.getAsset().openStream(); OutputStream out = new FileOutputStream(resourceFile)) {
                copy(in, out);
            }
            child.getPath().get();
        }
    }
}
 
Example 2
Source File: ConfigApplicationArchiveProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Override
public void process(Archive<?> applicationArchive, TestClass testClass) {
    if (applicationArchive instanceof WebArchive) {
        WebArchive war = applicationArchive.as(WebArchive.class);
        Node libNode = war.get(PATH_LIBRARY);
        if (libNode != null) {
            for (Node child : libNode.getChildren()) {
                Asset childAsset = child.getAsset();
                if (childAsset instanceof ArchiveAsset) {
                    ArchiveAsset archiveAsset = (ArchiveAsset) childAsset;
                    if (archiveAsset.getArchive() instanceof JavaArchive) {
                        JavaArchive libArchive = (JavaArchive) archiveAsset.getArchive();
                        libArchive.deleteClass(testClass.getName());
                    }
                }
            }
        }
    }
}
 
Example 3
Source File: GaeApplicationArchiveProcessor.java    From appengine-tck with Apache License 2.0 6 votes vote down vote up
protected void handleWebArchive(WebArchive war) {
    final Node lib = war.get("WEB-INF/lib");
    if (lib != null) {
        final Set<Node> libs = lib.getChildren();
        for (Node jar : libs) {
            if (jar.getPath().get().contains("appengine-api"))
                return;
        }
    }

    // do not add GAE jar; e.g. CapeDwarf can work off GAE module
    boolean ignoreGaeJar = Boolean.getBoolean("ignore.gae.jar");
    if (ignoreGaeJar == false) {
        war.addAsLibraries(Maven.resolver()
            .loadPomFromFile("pom.xml")
            .resolve("com.google.appengine:appengine-api-1.0-sdk")
            .withTransitivity()
            .as(File.class)
        );
    }
}
 
Example 4
Source File: WebInfLibFilteringArchive.java    From thorntail with Apache License 2.0 5 votes vote down vote up
protected void filter(Set<ArchivePath> remove, Node node, ResolvedDependencies resolvedDependencies) {
    String path = node.getPath().get();
    if (path.startsWith("/WEB-INF/lib") && path.endsWith(".jar")) {
        if (path.contains("thorntail-runner")) {
            remove.add(node.getPath());
        }
        if (resolvedDependencies.isRemovable(node)) {
            remove.add(node.getPath());
        }
    }

    for (Node each : node.getChildren()) {
        filter(remove, each, resolvedDependencies);
    }
}