use of com.synopsys.integration.detectable.detectables.sbt.parse.model.SbtReport in project synopsys-detect by blackducksoftware.
the class SbtReportParser method parseReportFromXml.
public SbtReport parseReportFromXml(Document xmlReport) {
Node ivyReport = XmlUtil.getNode(IVY_REPORT_NODE_KEY, xmlReport);
Node infoNode = XmlUtil.getNode(INFO_NODE_KEY, ivyReport);
Node dependenciesNode = XmlUtil.getNode(DEPENDENCIES_NODE_KEY, ivyReport);
List<Node> xmlModules = XmlUtil.getNodeList(MODULE_NODE_KEY, dependenciesNode);
String organisation = XmlUtil.getAttribute(ORGANISATION_NODE_KEY, infoNode);
String module = XmlUtil.getAttribute(MODULE_NODE_KEY, infoNode);
String revision = XmlUtil.getAttribute(REVISION_NODE_KEY, infoNode);
String configuration = XmlUtil.getAttribute(CONFIGURATION_NODE_KEY, infoNode);
List<SbtModule> dependencies = xmlModules.stream().map(this::createModule).collect(Collectors.toList());
return new SbtReport(organisation, module, revision, configuration, dependencies);
}
use of com.synopsys.integration.detectable.detectables.sbt.parse.model.SbtReport in project synopsys-detect by blackducksoftware.
the class SbtResolutionCacheExtractor method makeModuleAggregate.
private List<SbtDependencyModule> makeModuleAggregate(List<File> reportFiles, List<String> include, List<String> exclude) throws SAXException, IOException, ParserConfigurationException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
SbtReportParser parser = new SbtReportParser();
SbtDependencyResolver resolver = new SbtDependencyResolver(externalIdFactory);
ExcludedIncludedWildcardFilter filter = ExcludedIncludedWildcardFilter.fromCollections(exclude, include);
SbtModuleAggregator aggregator = new SbtModuleAggregator();
List<SbtDependencyModule> modules = new ArrayList<>();
for (File reportFile : reportFiles) {
Document xml = builder.parse(reportFile);
logger.debug(String.format("Parsing SBT report file: %s", reportFile.getCanonicalPath()));
SbtReport report = parser.parseReportFromXml(xml);
SbtDependencyModule tree = resolver.resolveReport(report);
modules.add(tree);
}
List<SbtDependencyModule> includedModules = modules.stream().filter(module -> filter.shouldInclude(module.getConfiguration())).collect(Collectors.toList());
if (modules.isEmpty()) {
logger.warn("No sbt configurations were found in report folder.");
return null;
} else if (includedModules.isEmpty()) {
logger.warn(String.format("Although %s configs were found, none were included.", modules.size()));
return null;
}
return aggregator.aggregateModules(includedModules);
}
Aggregations