Skip to content

Commit

Permalink
Fix quarkiverse#516: Copy build files instead of move
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Sep 25, 2023
1 parent acceb8c commit b99ac08
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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<Path>() {
@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")) {
Expand Down

0 comments on commit b99ac08

Please sign in to comment.