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;
}
Aggregations