DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(sourcesXmlFile);
final WroModel model = new WroModel();
Group closureDepsGroup = new Group(GROUP_NAME_CLOSURE_DEPS);
final NodeList includeNodes = doc.getElementsByTagName(INCLUDE_EL);
for (int i = 0; i < includeNodes.getLength(); i++) {
Element include = (Element) includeNodes.item(i);
if (!include.hasAttribute(FILE_ATT)) {
throw new AssertionError("include elements must have a " + FILE_ATT + " attribute");
}
Collection<IncludesStream> streams = null;
try {
streams = openIncludesStream(parentSourcesXmlFile, include.getAttribute(FILE_ATT));
for (IncludesStream is : streams) {
InputStream stream = is.stream;
WroModel includedModel = createModel(is.locationLoadedFrom, stream);
for (Group group : includedModel.getGroups()) {
if (GROUP_NAME_CLOSURE_DEPS.equals(group.getName())) {
for (Resource resource : group.getResources()) {
closureDepsGroup.addResource(resource);
}
} else {
model.addGroup(group);
}
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (streams != null) {
for (IncludesStream stream : streams) {
IOUtils.closeQuietly(stream.stream);
}
}
}
}
final NodeList requireNodes = doc.getElementsByTagName(REQUIRE_EL);
for (int i = 0; i < requireNodes.getLength(); i++) {
Element require = (Element) requireNodes.item(i);
loadGroupsUsingRequireDependencyManagement(require, model, closureDepsGroup);
}
if (!closureDepsGroup.getResources().isEmpty()) {
model.addGroup(closureDepsGroup);
}
final NodeList declareNodes = doc.getElementsByTagName(DECLARATIVE_EL);
for (int i = 0; i < declareNodes.getLength(); i++) {