public Collection<File> downloadDependencies(Iterable<Metadata> metadatas, File importedModulesDir,
Diagnostic result) throws IOException {
Set<Dependency> unresolvedCollector = new HashSet<Dependency>();
Set<Metadata> releasesToDownload = resolveDependencies(metadatas, unresolvedCollector);
for(Dependency unresolved : unresolvedCollector)
result.addChild(new Diagnostic(WARNING, FORGE, String.format(
"Unable to resolve dependency: %s:%s", unresolved.getName(),
unresolved.getVersionRequirement().toString())));
if(!releasesToDownload.isEmpty()) {
importedModulesDir.mkdirs();
List<File> importedModuleLocations = new ArrayList<File>();
StringBuilder bld = new StringBuilder("Installing dependent module ");
int pfxLen = bld.length();
for(Metadata release : releasesToDownload) {
bld.setLength(pfxLen);
release.getName().toString(bld);
bld.append(':');
release.getVersion().toString(bld);
result.addChild(new Diagnostic(INFO, FORGE, bld.toString()));
bld.setLength(0);
ModuleUtils.buildFileName(release.getName(), release.getVersion(), bld);
File moduleDir = new File(importedModulesDir, bld.toString());
install(release, moduleDir, true, false);
importedModuleLocations.add(moduleDir);
}
return importedModuleLocations;
}
if(unresolvedCollector.isEmpty())
result.addChild(new Diagnostic(INFO, FORGE, "No additional dependencies were detected"));
return Collections.emptyList();
}