diff --git a/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskCopyLocalFrontendFiles.java b/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskCopyLocalFrontendFiles.java index 762985e4d71..d97bc51313c 100644 --- a/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskCopyLocalFrontendFiles.java +++ b/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskCopyLocalFrontendFiles.java @@ -29,7 +29,6 @@ import java.util.stream.Stream; import org.apache.commons.io.FileUtils; -import org.apache.commons.io.filefilter.FileFilterUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,6 +54,11 @@ public class TaskCopyLocalFrontendFiles this.options = options; } + private static boolean shouldApplyWriteableFlag() { + return !Boolean.parseBoolean(System.getProperty( + "vaadin.frontend.disableWritableFlagCheckOnCopy", "false")); + } + @Override public void execute() { File target = options.getJarFrontendResourcesFolder(); @@ -96,16 +100,22 @@ static Set copyLocalResources(File source, File target, return Collections.emptySet(); } try { + long start = System.nanoTime(); Set handledFiles = new HashSet<>(TaskCopyFrontendFiles .getFilesInDirectory(source, relativePathExclusions)); FileUtils.copyDirectory(source, target, withoutExclusions(source, relativePathExclusions)); - try (Stream fileStream = Files - .walk(Paths.get(target.getPath()))) { - // used with try-with-resources as defined in walk API note - fileStream.filter(file -> !Files.isWritable(file)).forEach( - filePath -> filePath.toFile().setWritable(true)); + if (shouldApplyWriteableFlag()) { + try (Stream fileStream = Files + .walk(Paths.get(target.getPath()))) { + // used with try-with-resources as defined in walk API note + fileStream.filter(file -> !Files.isWritable(file)).forEach( + filePath -> filePath.toFile().setWritable(true)); + } } + long ms = (System.nanoTime() - start) / 1000000; + log().info("Copied {} local frontend files. Took {} ms.", + handledFiles.size(), ms); return handledFiles; } catch (IOException e) { throw new UncheckedIOException(String.format(