diff --git a/deployment/src/main/java/io/quarkiverse/quinoa/deployment/QuinoaProcessor.java b/deployment/src/main/java/io/quarkiverse/quinoa/deployment/QuinoaProcessor.java index df14aff1..becc3b30 100644 --- a/deployment/src/main/java/io/quarkiverse/quinoa/deployment/QuinoaProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/quinoa/deployment/QuinoaProcessor.java @@ -11,9 +11,13 @@ import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT; import java.io.IOException; +import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.StandardCopyOption; +import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -175,7 +179,8 @@ && isDevServerMode(configuredQuinoa.resolvedConfig())) { } final Path targetBuildDir = outputTarget.getOutputDirectory().resolve(TARGET_DIR_NAME); FileUtil.deleteDirectory(targetBuildDir); - Files.move(buildDir, targetBuildDir); + LOG.infof("Copy build directory: %s to target directory: %s", buildDir, targetBuildDir); + copyDirectory(buildDir, targetBuildDir); liveReload.setContextObject(QuinoaLiveContext.class, new QuinoaLiveContext(targetBuildDir)); return new TargetDirBuildItem(targetBuildDir); } @@ -365,6 +370,23 @@ static Path findProjectRoot(Path outputDirectory) { } while (true); } + public static void copyDirectory(Path source, Path target) throws IOException { + Files.walkFileTree(source, new SimpleFileVisitor() { + @Override + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { + Path targetDir = target.resolve(source.relativize(dir)); + Files.createDirectories(targetDir); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + Files.copy(file, target.resolve(source.relativize(file)), StandardCopyOption.REPLACE_EXISTING); + return FileVisitResult.CONTINUE; + } + }); + } + private static boolean isCI() { String ci; if (System.getProperties().containsKey("CI")) {