Skip to content

Commit

Permalink
Use StandardCopyOption.REPLACE_EXISTING when File.copy, unchain the m…
Browse files Browse the repository at this point in the history
…ethod calls
  • Loading branch information
rhamedy committed Apr 17, 2019
1 parent a9aca3b commit f00f100
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -58,14 +59,16 @@ public void performAction() {
templateFile.getParentFile().mkdirs();

try (InputStream resourceTemplate = this.getClass().getResourceAsStream("/" + descriptorOutput.getName())) {
Files.copy(resourceTemplate, templateFile.toPath());
Files.copy(resourceTemplate, templateFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
throw new RuntimeException(e);
}

project.copy(copyArg -> {
copyArg.from(templateFile.getParentFile()).include(descriptorOutput.getName())
.into(descriptorOutput.getParentFile()).expand(this.generateSubstitutions());
copyArg.from(templateFile.getParentFile());
copyArg.include(descriptorOutput.getName());
copyArg.into(descriptorOutput.getParentFile());
copyArg.expand(this.generateSubstitutions());
});
}

Expand Down

0 comments on commit f00f100

Please sign in to comment.