public void copyFiles(DynamicSubBuild run, DynamicBuild parent, String outputFiles, BuildListener listener) throws IOException {
String baseWorkSpace;
try {
listener.getLogger().println("Copying files :" + outputFiles);
FilePath workspacePath = run.getWorkspace();
FilePath targetPath = parent.getWorkspace();
if (workspacePath != null && targetPath != null) {
baseWorkSpace = workspacePath.toURI().toString();
for (FilePath file : workspacePath.list(outputFiles)) {
String dir = file.toURI().toString().replaceAll(baseWorkSpace, "").replaceAll(file.getName(), "");
FilePath targetChildDir = targetPath.child(dir);
if (!targetChildDir.exists()) {
targetChildDir.mkdirs();
}
file.copyTo(targetChildDir.child(file.getName()));
}
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}