for (Map.Entry<String, Parser> entry : entries) {
String uri = entry.getKey();
if (uri.startsWith("fab:")) {
uri = uri.substring(4);
}
Parser parser = entry.getValue();
File file = files.get(uri);
if (file == null) {
LOG.warn("Could not find file for " + uri + " in files map when has parser: " + parser);
continue;
}
String fileName = parser.getArtifactPath();
File outputDir;
if (fileName.toLowerCase().endsWith(".jar")) {
outputDir = uploadLibDir;
libFileCount++;
}
else {
outputDir = uploadDeployDir;
deployFileCount++;
}
outputDir.mkdirs();
File outFile = new File(outputDir, fileName);
outFile.getParentFile().mkdirs();
Files.copy(file, outFile);
}
// lets make sure there's all the feature files too
Set<String> processedFeatureXmls = new HashSet<>();
for (Profile profile : profileList) {
List<String> repositories = profile.getRepositories();
for (String repository : repositories) {
if (processedFeatureXmls.add(repository)) {
if (repository.contains("$")) {
Map<String, Map<String, String>> configurations = Profiles.getOverlayConfigurations(fabric, profileList);
repository = VersionPropertyPointerResolver.replaceVersions(fabric, configurations, repository);
}
Parser parser = null;
URL url = null;
try {
parser = Parser.parsePathWithSchemePrefix(repository);
} catch (MalformedURLException e) {
LOG.warn("Could not parse maven coords in features repository: " + repository + ". " + e, e);
}
try {
url = new URL(repository);
} catch (MalformedURLException e) {
LOG.warn("Could not parse URL for feature repository: " + repository + ". " + e, e);
}
if (parser != null && url != null) {
InputStream inputStream = null;
try {
inputStream = url.openStream();
if (inputStream == null) {
LOG.warn("Could not load URL for feature repository: " + repository);
continue;
}
} catch (IOException e) {
LOG.warn("Could not load URL for feature repository: " + repository + ". " + e, e);
continue;
}
String fileName = parser.getArtifactPath();
uploadLibDir.mkdirs();
File outFile = new File(uploadLibDir, fileName);
outFile.getParentFile().mkdirs();
try {
Files.copy(inputStream, new FileOutputStream(outFile));