use of com.synopsys.integration.detectable.detectables.maven.parsing.parse.PomDependenciesHandler in project synopsys-detect by blackducksoftware.
the class MavenParseExtractor method extract.
public Extraction extract(File pomXmlFile, MavenParseOptions mavenParseOptions) {
try (InputStream pomXmlInputStream = new FileInputStream(pomXmlFile)) {
// we have to create a new handler or the state of all handlers would be shared.
// we could create a handler factory or some other indirection so it could be injected but for now we make a new one.
PomDependenciesHandler pomDependenciesHandler = new PomDependenciesHandler(mavenParseOptions.isIncludePlugins());
saxParser.parse(pomXmlInputStream, pomDependenciesHandler);
List<Dependency> dependencies = pomDependenciesHandler.getDependencies();
DependencyGraph dependencyGraph = new BasicDependencyGraph();
dependencyGraph.addChildrenToRoot(dependencies);
CodeLocation codeLocation = new CodeLocation(dependencyGraph);
return Extraction.success(codeLocation);
} catch (Exception e) {
return new Extraction.Builder().exception(e).build();
}
}
Aggregations