Search in sources :

Example 1 with DependenciesContainer

use of org.wildfly.swarm.spi.api.DependenciesContainer in project wildfly-swarm by wildfly-swarm.

the class DefaultRarDeploymentFactory method setupUsingMaven.

@Override
public boolean setupUsingMaven(final Archive<?> givenArchive) throws Exception {
    final DependenciesContainer<?> archive = (DependenciesContainer<?>) givenArchive;
    FileSystemLayout fsLayout = FileSystemLayout.create();
    final Path classes = fsLayout.resolveBuildClassesDir();
    boolean success = false;
    if (Files.exists(classes)) {
        success = true;
        Files.walkFileTree(classes, new SimpleFileVisitor<Path>() {

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                Path simple = classes.relativize(file);
                archive.add(new FileAsset(file.toFile()), "WEB-INF/classes/" + convertSeparators(simple));
                if (simple.toString().contains("WEB-INF")) {
                    archive.add(new FileAsset(file.toFile()), convertSeparators(simple));
                }
                return super.visitFile(file, attrs);
            }
        });
    }
    final Path webapp = fsLayout.resolveSrcWebAppDir();
    if (Files.exists(webapp)) {
        success = true;
        Files.walkFileTree(webapp, new SimpleFileVisitor<Path>() {

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                Path simple = webapp.relativize(file);
                archive.add(new FileAsset(file.toFile()), convertSeparators(simple));
                return super.visitFile(file, attrs);
            }
        });
    }
    archive.addAllDependencies();
    return success;
}
Also used : Path(java.nio.file.Path) FileAsset(org.jboss.shrinkwrap.api.asset.FileAsset) DependenciesContainer(org.wildfly.swarm.spi.api.DependenciesContainer) FileSystemLayout(org.wildfly.swarm.internal.FileSystemLayout) FileVisitResult(java.nio.file.FileVisitResult) IOException(java.io.IOException) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes)

Example 2 with DependenciesContainer

use of org.wildfly.swarm.spi.api.DependenciesContainer in project wildfly-swarm by wildfly-swarm.

the class UberjarSimpleContainer method start.

@Override
public void start(Archive<?> archive) throws Exception {
    archive.add(EmptyAsset.INSTANCE, "META-INF/arquillian-testable");
    ContextRoot contextRoot = null;
    if (archive.getName().endsWith(".war")) {
        contextRoot = new ContextRoot("/");
        Node jbossWebNode = archive.as(WebArchive.class).get("WEB-INF/jboss-web.xml");
        if (jbossWebNode != null) {
            if (jbossWebNode.getAsset() != null) {
                try (BufferedReader reader = new BufferedReader(new InputStreamReader(jbossWebNode.getAsset().openStream()))) {
                    String content = String.join("\n", reader.lines().collect(Collectors.toList()));
                    Pattern pattern = Pattern.compile("<context-root>(.+)</context-root>");
                    Matcher matcher = pattern.matcher(content);
                    if (matcher.find()) {
                        contextRoot = new ContextRoot(matcher.group(1));
                    }
                }
            }
        }
        this.deploymentContext.getObjectStore().add(ContextRoot.class, contextRoot);
    }
    MainSpecifier mainSpecifier = containerContext.getObjectStore().get(MainSpecifier.class);
    boolean annotatedCreateSwarm = false;
    Method swarmMethod = getAnnotatedMethodWithAnnotation(this.testClass, CreateSwarm.class);
    List<Class<?>> types = determineTypes(this.testClass);
    // preflight check it
    if (swarmMethod != null) {
        if (Modifier.isStatic(swarmMethod.getModifiers())) {
            // good to go
            annotatedCreateSwarm = true;
            types.add(CreateSwarm.class);
            types.add(AnnotationBasedMain.class);
            archive.as(JARArchive.class).addModule("org.wildfly.swarm.container");
            archive.as(JARArchive.class).addModule("org.wildfly.swarm.configuration");
        } else {
            throw new IllegalArgumentException(String.format("Method annotated with %s is %s but it is not static", CreateSwarm.class.getSimpleName(), swarmMethod));
        }
    }
    if (types.size() > 0) {
        try {
            ((ClassContainer<?>) archive).addClasses(types.toArray(new Class[types.size()]));
        } catch (UnsupportedOperationException e) {
            // TODO Remove the try/catch when SHRINKWRAP-510 is resolved and we update to latest SW
            archive.as(JARArchive.class).addClasses(types.toArray(new Class[types.size()]));
        }
    }
    final ShrinkwrapArtifactResolvingHelper resolvingHelper = ShrinkwrapArtifactResolvingHelper.defaultInstance();
    BuildTool tool = new BuildTool(resolvingHelper).fractionDetectionMode(BuildTool.FractionDetectionMode.when_missing).bundleDependencies(false);
    String additionalModules = System.getProperty(SwarmInternalProperties.BUILD_MODULES);
    // See https://issues.jboss.org/browse/SWARM-571
    if (null == additionalModules) {
        // see if we can find it
        File modulesDir = new File("target/classes/modules");
        additionalModules = modulesDir.exists() ? modulesDir.getAbsolutePath() : null;
    }
    if (additionalModules != null) {
        tool.additionalModules(Stream.of(additionalModules.split(":")).map(File::new).filter(File::exists).map(File::getAbsolutePath).collect(Collectors.toList()));
    }
    final SwarmExecutor executor = new SwarmExecutor().withDefaultSystemProperties();
    if (annotatedCreateSwarm) {
        executor.withProperty(AnnotationBasedMain.ANNOTATED_CLASS_NAME, this.testClass.getName());
    }
    if (contextRoot != null) {
        executor.withProperty(SwarmProperties.CONTEXT_PATH, contextRoot.context());
    }
    executor.withProperty("swarm.inhibit.auto-stop", "true");
    String additionalRepos = System.getProperty(SwarmInternalProperties.BUILD_REPOS);
    if (additionalRepos != null) {
        additionalRepos = additionalRepos + ",";
    } else {
        additionalRepos = "";
    }
    additionalRepos = additionalRepos + "https://repository.jboss.org/nexus/content/groups/public/";
    executor.withProperty("remote.maven.repo", additionalRepos);
    // project dependencies
    FileSystemLayout fsLayout = FileSystemLayout.create();
    DeclaredDependencies declaredDependencies = DependencyDeclarationFactory.newInstance(fsLayout).create(fsLayout, resolvingHelper);
    tool.declaredDependencies(declaredDependencies);
    // see DependenciesContainer#addAllDependencies()
    if (archive instanceof DependenciesContainer) {
        DependenciesContainer<?> depContainer = (DependenciesContainer<?>) archive;
        if (depContainer.hasMarker(DependenciesContainer.ALL_DEPENDENCIES_MARKER)) {
            munge(depContainer, declaredDependencies);
        }
    } else if (archive instanceof WebArchive) {
        // Handle the default deployment of type WAR
        WebArchive webArchive = (WebArchive) archive;
        if (MarkerContainer.hasMarker(webArchive, DependenciesContainer.ALL_DEPENDENCIES_MARKER)) {
            munge(webArchive, declaredDependencies);
        }
    }
    tool.projectArchive(archive);
    final String debug = System.getProperty(SwarmProperties.DEBUG_PORT);
    if (debug != null) {
        try {
            executor.withDebug(Integer.parseInt(debug));
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException(String.format("Failed to parse %s of \"%s\"", SwarmProperties.DEBUG_PORT, debug), e);
        }
    }
    if (mainSpecifier != null) {
        tool.mainClass(mainSpecifier.getClassName());
        String[] args = mainSpecifier.getArgs();
        for (String arg : args) {
            executor.withArgument(arg);
        }
    } else if (annotatedCreateSwarm) {
        tool.mainClass(AnnotationBasedMain.class.getName());
    } else {
        Optional<String> mainClassName = Optional.empty();
        Node node = archive.get("META-INF/arquillian-main-class");
        if (node != null && node.getAsset() != null) {
            try (BufferedReader reader = new BufferedReader(new InputStreamReader(node.getAsset().openStream()))) {
                mainClassName = reader.lines().findFirst();
            }
        }
        tool.mainClass(mainClassName.orElse(Swarm.class.getName()));
    }
    if (this.testClass != null) {
        tool.testClass(this.testClass.getName());
    }
    Archive<?> wrapped = null;
    try {
        wrapped = tool.build();
    } catch (Throwable t) {
        t.printStackTrace();
        throw t;
    }
    if (BootstrapProperties.flagIsSet(SwarmInternalProperties.EXPORT_UBERJAR)) {
        final File out = new File(wrapped.getName());
        System.err.println("Exporting swarm jar to " + out.getAbsolutePath());
        wrapped.as(ZipExporter.class).exportTo(out, true);
    }
    /* for (Map.Entry<ArchivePath, Node> each : wrapped.getContent().entrySet()) {
                System.err.println("-> " + each.getKey());
            }*/
    File executable = File.createTempFile(TempFileManager.WFSWARM_TMP_PREFIX + "arquillian", "-swarm.jar");
    wrapped.as(ZipExporter.class).exportTo(executable, true);
    executable.deleteOnExit();
    String mavenRepoLocal = System.getProperty("maven.repo.local");
    if (mavenRepoLocal != null) {
        executor.withProperty("maven.repo.local", mavenRepoLocal);
    }
    executor.withProperty("java.net.preferIPv4Stack", "true");
    File processFile = File.createTempFile(TempFileManager.WFSWARM_TMP_PREFIX + "mainprocessfile", null);
    executor.withProcessFile(processFile);
    executor.withJVMArguments(getJavaVmArgumentsList());
    executor.withExecutableJar(executable.toPath());
    workingDirectory = TempFileManager.INSTANCE.newTempDirectory("arquillian", null);
    executor.withWorkingDirectory(workingDirectory.toPath());
    this.process = executor.execute();
    this.process.getOutputStream().close();
    this.process.awaitReadiness(2, TimeUnit.MINUTES);
    if (!this.process.isAlive()) {
        throw new DeploymentException("Process failed to start");
    }
    if (this.process.getError() != null) {
        throw new DeploymentException("Error starting process", this.process.getError());
    }
}
Also used : Matcher(java.util.regex.Matcher) ClassContainer(org.jboss.shrinkwrap.api.container.ClassContainer) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) Node(org.jboss.shrinkwrap.api.Node) FileSystemLayout(org.wildfly.swarm.internal.FileSystemLayout) Swarm(org.wildfly.swarm.Swarm) CreateSwarm(org.wildfly.swarm.arquillian.CreateSwarm) ShrinkwrapArtifactResolvingHelper(org.wildfly.swarm.arquillian.resolver.ShrinkwrapArtifactResolvingHelper) ContextRoot(org.wildfly.swarm.arquillian.adapter.resources.ContextRoot) JARArchive(org.wildfly.swarm.spi.api.JARArchive) Pattern(java.util.regex.Pattern) InputStreamReader(java.io.InputStreamReader) Optional(java.util.Optional) SwarmExecutor(org.wildfly.swarm.tools.exec.SwarmExecutor) DependenciesContainer(org.wildfly.swarm.spi.api.DependenciesContainer) DeclaredDependencies(org.wildfly.swarm.tools.DeclaredDependencies) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) Method(java.lang.reflect.Method) BuildTool(org.wildfly.swarm.tools.BuildTool) BufferedReader(java.io.BufferedReader) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) File(java.io.File)

Example 3 with DependenciesContainer

use of org.wildfly.swarm.spi.api.DependenciesContainer in project wildfly-swarm by wildfly-swarm.

the class DefaultVDBDeploymentFactory method setupUsingMaven.

@Override
public boolean setupUsingMaven(final Archive<?> givenArchive) throws Exception {
    final DependenciesContainer<?> archive = (DependenciesContainer<?>) givenArchive;
    FileSystemLayout fsLayout = FileSystemLayout.create();
    final Path classes = fsLayout.resolveBuildClassesDir();
    boolean success = false;
    if (Files.exists(classes)) {
        success = true;
        Files.walkFileTree(classes, new SimpleFileVisitor<Path>() {

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                Path simple = classes.relativize(file);
                archive.add(new FileAsset(file.toFile()), "classes/" + convertSeparators(simple));
                if (simple.toString().contains("config")) {
                    archive.add(new FileAsset(file.toFile()), convertSeparators(simple));
                }
                return super.visitFile(file, attrs);
            }
        });
    }
    archive.addAllDependencies();
    return success;
}
Also used : Path(java.nio.file.Path) FileAsset(org.jboss.shrinkwrap.api.asset.FileAsset) DependenciesContainer(org.wildfly.swarm.spi.api.DependenciesContainer) FileSystemLayout(org.wildfly.swarm.internal.FileSystemLayout) FileVisitResult(java.nio.file.FileVisitResult) IOException(java.io.IOException) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes)

Example 4 with DependenciesContainer

use of org.wildfly.swarm.spi.api.DependenciesContainer in project wildfly-swarm by wildfly-swarm.

the class RuntimeDeployer method deploy.

public void deploy(Archive<?> deployment, String asName) throws DeploymentException {
    if (deployment.getName().endsWith(".rar")) {
        // Track any .rar deployments
        this.rarDeploymentNames.add(deployment.getName());
    } else if (!this.rarDeploymentNames.isEmpty()) {
        // Add any previous .rar deployments as dependencies
        // of any non-.rar deployments.
        JARArchive mutable = deployment.as(JARArchive.class);
        this.rarDeploymentNames.forEach(e -> {
            mutable.addModule("deployment." + e);
        });
    }
    try (AutoCloseable deploymentTimer = Performance.time("deployment: " + deployment.getName())) {
        // see DependenciesContainer#addAllDependencies()
        if (deployment instanceof DependenciesContainer) {
            DependenciesContainer<?> depContainer = (DependenciesContainer) deployment;
            if (depContainer.hasMarker(DependenciesContainer.ALL_DEPENDENCIES_MARKER)) {
                if (!depContainer.hasMarker(ALL_DEPENDENCIES_ADDED_MARKER)) {
                    ApplicationEnvironment appEnv = ApplicationEnvironment.get();
                    if (ApplicationEnvironment.Mode.UBERJAR == appEnv.getMode()) {
                        ArtifactLookup artifactLookup = ArtifactLookup.get();
                        for (String gav : appEnv.getDependencies()) {
                            depContainer.addAsLibrary(artifactLookup.artifact(gav));
                        }
                    } else {
                        Set<String> paths = appEnv.resolveDependencies(Collections.emptyList());
                        for (String path : paths) {
                            final File pathFile = new File(path);
                            if (path.endsWith(".jar")) {
                                depContainer.addAsLibrary(pathFile);
                            } else if (pathFile.isDirectory()) {
                                depContainer.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class).importDirectory(pathFile).as(GenericArchive.class), "/WEB-INF/classes", Filters.includeAll());
                            }
                        }
                    }
                    depContainer.addMarker(ALL_DEPENDENCIES_ADDED_MARKER);
                }
            }
        }
        this.deploymentContext.activate(deployment, asName, !this.implicitDeploymentsComplete);
        // 2. give fractions a chance to handle the deployment
        for (DeploymentProcessor processor : this.deploymentProcessors) {
            processor.process();
        }
        this.deploymentContext.deactivate();
        if (DeployerMessages.MESSAGES.isDebugEnabled()) {
            DeployerMessages.MESSAGES.deploying(deployment.getName());
            Map<ArchivePath, Node> ctx = deployment.getContent();
            for (Map.Entry<ArchivePath, Node> each : ctx.entrySet()) {
                DeployerMessages.MESSAGES.deploymentContent(each.getKey().toString());
            }
        }
        if (BootstrapProperties.flagIsSet(SwarmProperties.EXPORT_DEPLOYMENT)) {
            String exportLocation = System.getProperty(SwarmProperties.EXPORT_DEPLOYMENT);
            if (exportLocation != null) {
                Path archivePath = null;
                if (exportLocation.toLowerCase().equals("true")) {
                    archivePath = Paths.get(deployment.getName());
                } else {
                    Path exportDir = Paths.get(exportLocation);
                    Files.createDirectories(exportDir);
                    archivePath = exportDir.resolve(deployment.getName());
                }
                final File out = archivePath.toFile();
                DeployerMessages.MESSAGES.exportingDeployment(out.getAbsolutePath());
                deployment.as(ZipExporter.class).exportTo(out, true);
            }
        }
        byte[] hash = this.contentRepository.addContent(deployment);
        final ModelNode deploymentAdd = new ModelNode();
        deploymentAdd.get(OP).set(ADD);
        deploymentAdd.get(OP_ADDR).set("deployment", deployment.getName());
        deploymentAdd.get(RUNTIME_NAME).set(deployment.getName());
        deploymentAdd.get(ENABLED).set(true);
        deploymentAdd.get(PERSISTENT).set(true);
        ModelNode content = deploymentAdd.get(CONTENT).add();
        content.get(HASH).set(hash);
        int deploymentTimeout = Integer.getInteger(SwarmProperties.DEPLOYMENT_TIMEOUT, 300);
        final ModelNode opHeaders = new ModelNode();
        opHeaders.get(BLOCKING_TIMEOUT).set(deploymentTimeout);
        deploymentAdd.get(OPERATION_HEADERS).set(opHeaders);
        BootstrapLogger.logger("org.wildfly.swarm.runtime.deployer").info("deploying " + deployment.getName());
        System.setProperty(SwarmInternalProperties.CURRENT_DEPLOYMENT, deployment.getName());
        try {
            ModelNode result = client.execute(deploymentAdd);
            ModelNode outcome = result.get("outcome");
            if (outcome.asString().equals("success")) {
                return;
            }
            ModelNode description = result.get("failure-description");
            throw new DeploymentException(deployment, SwarmMessages.MESSAGES.deploymentFailed(description.asString()));
        } catch (IOException e) {
            throw SwarmMessages.MESSAGES.deploymentFailed(e, deployment);
        }
    } catch (Exception e) {
        throw new DeploymentException(deployment, e);
    }
}
Also used : ApplicationEnvironment(org.wildfly.swarm.bootstrap.env.ApplicationEnvironment) ADD(org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD) DefaultDeploymentCreator(org.wildfly.swarm.container.runtime.deployments.DefaultDeploymentCreator) DependenciesContainer(org.wildfly.swarm.spi.api.DependenciesContainer) Node(org.jboss.shrinkwrap.api.Node) PreDestroy(javax.annotation.PreDestroy) BLOCKING_TIMEOUT(org.jboss.as.controller.descriptions.ModelDescriptionConstants.BLOCKING_TIMEOUT) Map(java.util.Map) BootstrapLogger(org.wildfly.swarm.bootstrap.logging.BootstrapLogger) ENABLED(org.jboss.as.controller.descriptions.ModelDescriptionConstants.ENABLED) Any(javax.enterprise.inject.Any) Path(java.nio.file.Path) DeploymentContext(org.wildfly.swarm.container.runtime.cdi.DeploymentContext) Instance(javax.enterprise.inject.Instance) ZipImporter(org.jboss.shrinkwrap.api.importer.ZipImporter) Collection(java.util.Collection) SwarmInternalProperties(org.wildfly.swarm.spi.api.internal.SwarmInternalProperties) Set(java.util.Set) JARArchive(org.wildfly.swarm.spi.api.JARArchive) GenericArchive(org.jboss.shrinkwrap.api.GenericArchive) DeploymentException(org.wildfly.swarm.container.DeploymentException) FileSystemLayout(org.wildfly.swarm.internal.FileSystemLayout) List(java.util.List) OP(org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP) Stream(java.util.stream.Stream) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) CONTENT(org.jboss.as.controller.descriptions.ModelDescriptionConstants.CONTENT) ApplicationScoped(javax.enterprise.context.ApplicationScoped) ModelNode(org.jboss.dmr.ModelNode) SwarmProperties(org.wildfly.swarm.spi.api.SwarmProperties) RUNTIME_NAME(org.jboss.as.controller.descriptions.ModelDescriptionConstants.RUNTIME_NAME) DeploymentProcessor(org.wildfly.swarm.spi.api.DeploymentProcessor) TempFileProvider(org.jboss.vfs.TempFileProvider) Performance(org.wildfly.swarm.bootstrap.performance.Performance) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Deployer(org.wildfly.swarm.container.internal.Deployer) ArchivePath(org.jboss.shrinkwrap.api.ArchivePath) DeployerMessages(org.wildfly.swarm.internal.DeployerMessages) ArtifactLookup(org.wildfly.swarm.spi.api.ArtifactLookup) ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) OPERATION_HEADERS(org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_HEADERS) OP_ADDR(org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR) PERSISTENT(org.jboss.as.controller.descriptions.ModelDescriptionConstants.PERSISTENT) ShrinkWrap(org.jboss.shrinkwrap.api.ShrinkWrap) Files(java.nio.file.Files) BootstrapProperties(org.wildfly.swarm.bootstrap.util.BootstrapProperties) ExplodedImporter(org.jboss.shrinkwrap.api.importer.ExplodedImporter) SwarmMessages(org.wildfly.swarm.internal.SwarmMessages) IOException(java.io.IOException) Filters(org.jboss.shrinkwrap.api.Filters) Archive(org.jboss.shrinkwrap.api.Archive) SwarmContentRepository(org.wildfly.swarm.container.runtime.wildfly.SwarmContentRepository) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) File(java.io.File) HASH(org.jboss.as.controller.descriptions.ModelDescriptionConstants.HASH) Paths(java.nio.file.Paths) Collections(java.util.Collections) ArtifactLookup(org.wildfly.swarm.spi.api.ArtifactLookup) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) Node(org.jboss.shrinkwrap.api.Node) ModelNode(org.jboss.dmr.ModelNode) ArchivePath(org.jboss.shrinkwrap.api.ArchivePath) DeploymentProcessor(org.wildfly.swarm.spi.api.DeploymentProcessor) JARArchive(org.wildfly.swarm.spi.api.JARArchive) Path(java.nio.file.Path) ArchivePath(org.jboss.shrinkwrap.api.ArchivePath) DependenciesContainer(org.wildfly.swarm.spi.api.DependenciesContainer) IOException(java.io.IOException) ApplicationEnvironment(org.wildfly.swarm.bootstrap.env.ApplicationEnvironment) DeploymentException(org.wildfly.swarm.container.DeploymentException) IOException(java.io.IOException) GenericArchive(org.jboss.shrinkwrap.api.GenericArchive) DeploymentException(org.wildfly.swarm.container.DeploymentException) ModelNode(org.jboss.dmr.ModelNode) File(java.io.File) Map(java.util.Map)

Example 5 with DependenciesContainer

use of org.wildfly.swarm.spi.api.DependenciesContainer in project wildfly-swarm by wildfly-swarm.

the class DefaultWarDeploymentFactory method setupUsingMaven.

public boolean setupUsingMaven(final Archive<?> givenArchive) throws Exception {
    final DependenciesContainer<?> archive = (DependenciesContainer<?>) givenArchive;
    FileSystemLayout fsLayout = FileSystemLayout.create();
    final Path classes = fsLayout.resolveBuildClassesDir();
    boolean success = false;
    if (Files.exists(classes)) {
        success = true;
        addFilesToArchive(classes, archive);
    }
    // If it a gradle project, the reources are seperated from the class files.
    final Path resources = fsLayout.resolveBuildResourcesDir();
    if (!Files.isSameFile(resources, classes) && Files.exists(resources)) {
        success = true;
        addFilesToArchive(resources, archive);
    }
    final Path webapp = fsLayout.resolveSrcWebAppDir();
    if (Files.exists(webapp)) {
        success = true;
        Files.walkFileTree(webapp, new SimpleFileVisitor<Path>() {

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                Path simple = webapp.relativize(file);
                archive.add(new FileAsset(file.toFile()), convertSeparators(simple));
                return super.visitFile(file, attrs);
            }
        });
    }
    archive.addAllDependencies();
    return success;
}
Also used : Path(java.nio.file.Path) FileAsset(org.jboss.shrinkwrap.api.asset.FileAsset) DependenciesContainer(org.wildfly.swarm.spi.api.DependenciesContainer) FileSystemLayout(org.wildfly.swarm.internal.FileSystemLayout) FileVisitResult(java.nio.file.FileVisitResult) IOException(java.io.IOException) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes)

Aggregations

FileSystemLayout (org.wildfly.swarm.internal.FileSystemLayout)5 DependenciesContainer (org.wildfly.swarm.spi.api.DependenciesContainer)5 IOException (java.io.IOException)4 Path (java.nio.file.Path)4 FileVisitResult (java.nio.file.FileVisitResult)3 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)3 FileAsset (org.jboss.shrinkwrap.api.asset.FileAsset)3 File (java.io.File)2 Node (org.jboss.shrinkwrap.api.Node)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 Method (java.lang.reflect.Method)1 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1