dependencies.clear();
logger.info("Loading dependency graph");
// Parse the deps.js file.
ErrorManager errorManager = new LoggerErrorManager(logger);
DepsFileParser parser =
new DepsFileParser(errorManager);
List<DependencyInfo> depInfos =
parser.parseFile(getName(), getContent());
// Ensure the parse succeeded.
if (!parser.didParseSucceed()) {
throw new ServiceException("Problem parsing " + getName()
+ ". See logs for details.");
}
// Incorporate the dependencies into our maps.
for (DependencyInfo depInfo : depInfos) {
for (String provide : depInfo.getProvides()) {
DependencyInfo existing = dependencies.get(provide);
if (existing != null && !existing.equals(depInfo)) {
throw new ServiceException("Duplicate provide of " + provide
+ ". Was provided by " + existing.getPathRelativeToClosureBase()
+ " and " + depInfo.getPathRelativeToClosureBase());
}
dependencies.put(provide, depInfo);
}
}
// Add implicit base.js entry.
dependencies.put(CLOSURE_BASE_PROVIDE,
new SimpleDependencyInfo(CLOSURE_BASE, CLOSURE_BASE,
Lists.newArrayList(CLOSURE_BASE_PROVIDE),
Collections.<String>emptyList(), false));
errorManager.generateReport();
logger.info("Dependencies loaded");
}