Search in sources :

Example 6 with FileSystemLayout

use of org.wildfly.swarm.internal.FileSystemLayout 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)6 IOException (java.io.IOException)4 FileVisitResult (java.nio.file.FileVisitResult)4 Path (java.nio.file.Path)4 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)4 FileAsset (org.jboss.shrinkwrap.api.asset.FileAsset)4 DependenciesContainer (org.wildfly.swarm.spi.api.DependenciesContainer)4 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 InputStreamReader (java.io.InputStreamReader)1 Method (java.lang.reflect.Method)1 Optional (java.util.Optional)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 DeploymentException (org.jboss.arquillian.container.spi.client.container.DeploymentException)1 Node (org.jboss.shrinkwrap.api.Node)1 ClassContainer (org.jboss.shrinkwrap.api.container.ClassContainer)1 ZipExporter (org.jboss.shrinkwrap.api.exporter.ZipExporter)1 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)1 Swarm (org.wildfly.swarm.Swarm)1