Copy files recursively on create

This commit is contained in:
jbertram 2015-12-09 15:19:23 -06:00
parent 2729bd613d
commit 9cae390645
1 changed files with 26 additions and 12 deletions

View File

@ -274,19 +274,9 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin {
if (list != null) {
getLog().debug("************************************************");
getLog().debug("Replacing configuration files:");
getLog().debug("Copying configuration files:");
for (String file : configuration.list()) {
Path target = instance.toPath().resolve("etc").resolve(file);
getLog().debug("Replacing " + file + " into " + target);
Path originalFile = configuration.toPath().resolve(file);
Files.copy(originalFile, target, StandardCopyOption.REPLACE_EXISTING);
commandLineStream.println("");
commandLineStream.println("# replacing " + originalFile.getFileName() + " on the default configuration");
commandLineStream.println("cp " + originalFile + " " + target);
}
copyConfigurationFiles(list, configuration.toPath(), instance.toPath().resolve("etc"), commandLineStream);
}
}
@ -317,6 +307,30 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin {
}
}
private void copyConfigurationFiles(String[] list, Path sourcePath, Path targetPath, PrintStream commandLineStream) throws IOException {
for (String file : list) {
Path target = targetPath.resolve(file);
Path originalFile = sourcePath.resolve(file);
Files.copy(originalFile, target, StandardCopyOption.REPLACE_EXISTING);
commandLineStream.println("");
if (originalFile.toFile().isDirectory()) {
getLog().debug("Creating directory " + target);
commandLineStream.println("# creating directory " + originalFile.getFileName());
commandLineStream.println("mkdir " + target);
copyConfigurationFiles(originalFile.toFile().list(), originalFile, target, commandLineStream);
}
else {
getLog().debug("Copying " + file + " to " + target);
commandLineStream.println("# copying config file " + originalFile.getFileName());
commandLineStream.println("cp " + originalFile + " " + target);
}
}
}
private String getCommandline(ArrayList<String> listCommands) {
StringBuffer buffer = new StringBuffer();
buffer.append(home.getAbsolutePath() + "/bin/artemis ");